Page Size and Margins in LaTeX
One package, geometry, sets the paper size and the margins. This guide gives you the lines to copy for A4, thesis binding margins, headers and landscape pages.
The short answer
\usepackage[a4paper, margin=2.5cm]{geometry}Put it in the preamble. That gives A4 paper with 2.5 cm on every side. Without it, LaTeX may default to US Letter, depending on the installation, and its own margins are wide because they are tuned for short lines of text, not for a report.
You can also list the options on separate lines, which is easier to read and edit:
\usepackage{geometry}
\geometry{
a4paper,
left=3cm,
right=2.5cm,
top=2.5cm,
bottom=2.5cm
}Paper size
| Option | Size | Used for |
|---|---|---|
a4paper | 210 × 297 mm | Reports and theses outside North America |
letterpaper | 8.5 × 11 in | US and Canada |
a5paper | 148 × 210 mm | Booklets |
b5paper | 176 × 250 mm | Books |
a3paper | 297 × 420 mm | Posters, large tables |
For any other size, give the dimensions:
\usepackage[paperwidth=16cm, paperheight=24cm, margin=2cm]{geometry}Margins
Set all four with margin, each one with left, right, top and bottom, or pairs with hmargin (left and right) and vmargin (top and bottom). Units can be mm, cm, in or pt.
\geometry{a4paper, hmargin=2.5cm, vmargin=3cm}Binding margin for a printed report
A bound report loses a few millimetres to the binding, so the margin on that side should be wider. For single-sided printing, make left wider. For double-sided printing, use the twoside class option and set inner (the binding side) and outer:
\documentclass[12pt, twoside]{report}
\usepackage{geometry}
\geometry{
a4paper,
inner=3.5cm, % binding side
outer=2.5cm,
top=2.5cm,
bottom=3cm
}Check your school's guidelines first: many give exact margins for the PFE report, and the jury notices.
Headers and footers
If you add running headers with fancyhdr, it may warn that \headheight is too small and print the value it needs. Give geometry that value, and adjust the gaps around the header and footer if you want:
\geometry{
a4paper,
margin=2.5cm,
headheight=15pt, % room for the header text
headsep=8mm, % gap between header and text
footskip=12mm % from the last line of text to the footer
}By default the header and footer sit in the top and bottom margins. Add includeheadfoot if your guidelines measure the margins from the header and footer instead of from the text.
Landscape pages
For a whole document in landscape, add the option to geometry:
\usepackage[a4paper, landscape, margin=2cm]{geometry}More often you need one landscape page for a wide table inside a portrait report. Use pdflscape: it rotates the page in the PDF viewer too, so readers do not have to turn their heads.
\usepackage{pdflscape} % preamble
\begin{landscape}
\begin{table}[htbp]
\centering
\caption{Monthly results}
\begin{tabular}{lcccccccc}
Item & Jan & Feb & Mar & Apr & May & Jun & Jul & Aug \\
Sales & 120 & 135 & 150 & 142 & 160 & 175 & 180 & 190 \\
\end{tabular}
\end{table}
\end{landscape}Different margins for part of the document
\newgeometry changes the layout from the next page on, and \restoregeometry goes back to the preamble settings. Both start a new page, so use them at natural breaks such as a title page or an appendix.
\newgeometry{margin=1.5cm}
% title page, or a wide appendix
\restoregeometryQuick reference
| Option | Sets |
|---|---|
margin | All four margins |
left, right, top, bottom | One margin each |
hmargin, vmargin | Left and right, top and bottom |
inner, outer | Binding and outside margins (with twoside) |
headheight, headsep, footskip | Header and footer spacing |
includeheadfoot | Counts header and footer inside the margins |
landscape | Turns the whole document sideways |
paperwidth, paperheight | A custom paper size |
textwidth, textheight | The text block directly, margins follow |
Where to go next
- Tables, including tables that span several pages
- Learn LaTeX for a full report skeleton
- Common LaTeX mistakes in PFE reports