LaTeX
  • How I learn LaTeX?
  • Installation and Customization
    • Online
    • Offline
  • LaTeX Basics
  • Text Manipulation
    • Fonts, Size and Styles
  • Math Manipulation
  • Advanced Math Manipulation
  • Lists
  • Tables
  • Pictures, Figures
  • Unit in LaTeX
  • Document Structure
  • Document Formatting
    • Headers and Footers, Page Numbering
    • Spacing in Paragraphs
    • Page size, Margins
    • Coloring
    • Footnotes
  • Multi-file LaTeX project
Powered by GitBook
On this page
  • The geometry package
  • Understand geometry syntax
  1. Document Formatting

Page size, Margins

The page dimensions in a LaTeX document are highly configurable and there is a package offering a simple way to change the length and layout of various elements in a document.

PreviousSpacing in ParagraphsNextColoring

Last updated 1 year ago

The geometry package

The geometry package offers a simple way to change the length and layout of different elements such as the paper size, margins, footnote, header, orientation, etc.

Let's look at and example: Suppose I want to create a page with a4 paper size, margin of 2 inches, text area should not exceed 6 inches wide and 8 inches high. This is how you do it in LaTeX\LaTeXLATE​X.

\documentclass{article}
\usepackage{blindtext} % Generating dummy text
\usepackage[a4paper, total={6in, 8in}, margin=2in]{geometry}

\begin{document}
\blindtext[2]
\end{document}

And this is the result:

Understand geometry syntax

Before talking about what parameters geometry accepts, let's look at the layout of a standard LaTeX\LaTeXLATE​X document. You can do this by importing the layout package and use \layout in the document environment.

There is also a \layout* command that recalculates the internal values when drawing the graphic, which can be useful if you make changes to LaTeX's page-layout parameters.

Below are parameters that geometry accepts and their visualization:

  • textwidth - element 8

  • textheight - element 7

  • left (lmargin, inner) - change the length of the left margin (element 1 and 3)

  • right (rmargin, outer) - change the length of the right margin (element 9 and 10)

  • top (tmargin) - element 2 and 6

  • bottom (bmargin) - the length between the bottom edge and the document baseline.

  • headheight - height of the header

  • headsep - distance between header and the text body - element 6

  • total - defines the dimension of body

  • paperwidth/paperheight - actually change the size of the paper (for demonstration purpose only)

For reference and example:

https://ctan.org/pkg/geometry?lang=en
https://www.overleaf.com/learn/latex/Page_size_and_margins