Document Structure

How to Change Page Margins in LaTeX with geometry

Change LaTeX page margins with the geometry package: set all sides at once or separately, use inner and outer margins, and change them mid-document.

On this page
  1. Set all four margins at once
  2. Set each side separately
  3. Two-sided documents
  4. Check margins with showframe
  5. Change margins partway through a document
  6. Troubleshooting

The geometry package is the usual way to set page margins in LaTeX. It works with the standard classes, such as article, report, and book. This guide shows how to set all four margins at once, set each side separately, handle two-sided documents, and change margins partway through a file.

Set all four margins at once

Pass the margin option to geometry. It sets the same margin on all four sides:

\documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}

\begin{document}
Your text goes here.
\end{document}

The paper size is set with an option too. Use a4paper for A4 or letterpaper for US Letter. Units include in, cm, mm, and pt. One inch is about 2.54 cm.

Set each side separately

Use top, bottom, left, and right for different margins on each side:

\usepackage[top=2cm, bottom=2.5cm, left=3cm, right=2cm]{geometry}

You can combine both approaches. For example, margin=2cm followed by left=3cm sets all sides to 2 cm except the left, which is 3 cm.

Two-sided documents

In a two-sided document, the left and right margins swap on facing pages. The inner margin is next to the spine, and the outer margin is at the edge of the page. Use these options instead of left and right:

\documentclass{book}
\usepackage[inner=3cm, outer=2cm, top=2.5cm, bottom=2.5cm]{geometry}

geometry picks up the two-sided setting from the class, so book works without extra options. Other classes need the twoside class option.

Check margins with showframe

The showframe option draws a border around the text block and the margins. It shows you the layout before you print:

\usepackage[showframe, margin=1in]{geometry}

Remove the option once the layout looks right.

Change margins partway through a document

To use different margins for one part of a document, such as a wide table, use \newgeometry and \restoregeometry:

% standard margins here
\newgeometry{margin=0.5in}
% content that needs narrower margins, such as a wide table
\restoregeometry
% back to the original margins

Both commands start a new page, so place them where a page break is acceptable.

Troubleshooting

  • The margins do not change. Check that the \usepackage[...]{geometry} line is in the preamble, before \begin{document}.
  • The layout looks different from what you set. Another package or class option may also set the margins. Keep one method, and avoid loading two packages that both set margins.
  • Headers overlap the text. Load geometry before fancyhdr, as the fancyhdr documentation recommends. For header-specific fixes, see headers, footers and two-sided layouts in LaTeX.
  • Page numbers sit too close to the edge. Check the bottom margin and the footer space. The page numbering guide covers footer placement.

The complete guide to document structure

Chapters in LaTeX: Document Classes and Chapter Styles
Read the guide

Keep exploring

Guides from other topics

All topics →