Set page margins in LaTeX (geometry)

Load the geometry package with the margins as options: \usepackage[margin=2.5cm]{geometry} sets all four margins to 2.5 cm.

The same margin on all sides

margin sets the left, right, top and bottom margin at once. a4paper sets the paper size; without a paper option the standard classes lay out the page for US letter.

This goes into the preamble.

\usepackage[a4paper, margin=2.5cm]{geometry}

Open in the editor

A different margin on each side

left, right, top and bottom set one margin each. hmargin=3cm sets left and right together, vmargin=2cm top and bottom. The header and the footer sit inside the top and bottom margin.

This goes into the preamble.

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

Open in the editor

Margins for two-sided printing

With twoside, inner is the margin at the spine and outer the margin at the open edge; they swap between odd and even pages. bindingoffset adds the strip that disappears in the binding.

This goes into the preamble.

\usepackage[a4paper, twoside, inner=3cm, outer=2cm, bindingoffset=5mm]{geometry}

Open in the editor

Other margins for a few pages

\newgeometry{...} starts a new page with the margins you give, and \restoregeometry starts another new page with the margins from the preamble.

Complete document:

\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\begin{document}
Text with the margins from the preamble.

\newgeometry{margin=1cm}
A page with narrow margins, for example for a wide table.

\restoregeometry
Text with the margins from the preamble again.
\end{document}
Result
Page 1 of the compiled examplePage 1
Page 2 of the compiled examplePage 2
Page 3 of the compiled examplePage 3

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages