×

ShareLaTeX guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

The page dimensions in a L a T e X document are highly configurable and 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.

Contents

Introduction

Suppose you have to create a document in a4papper and the text shouldn't exceed 6 in width and 8 in height. To create it with geometry is easy, include this one line in the preamble:

\usepackage[a4paper, total={6in, 8in}]{geometry}

The parameters passed to the command determine the layout. In this case a4paper establishes the paper size and the total parameter determines the size of the text area.


Open an example of the geometry package in ShareLaTeX

Paper size, orientation and margins

Paper size, orientation and margins are the most common page elements that must be changed depending on the type of document. To set the desired values there are two ways, either you pass them as parameters to the \includepackage statement as in the example above, or use a \geometry command in the preamble.

For example, let's create a document with legal paper size, landscape orientation and a 2 in margin:

\usepackage[letterpaper, landscape, margin=2in]{geometry}

Also, you can achieve the same in a slightly different way

\usepackage{geometry}
\geometry{legalpaper, landscape, margin=2in}

As you see, the parameters are comma separated. For a complete list of predefined paper sizes see the reference guide . The second parameter is the orientation, its default value is portrait . Finally, each margin is set to 2 in.

Open an example of the geometry package in ShareLaTeX

Fine tuning your L a T e X page dimensions

The regular L a T e X page dimensions are presented (with example values) in picture at the right of this section.

The geometry package provides a flexible and easy interface to change page dimensions. You can change the page layout with intuitive parameters:

Next is a list of document elements whose length can be changed. The parameters have to be written in the form parameter=value , use standard L a T e X units. (mm, cm, pt, in)

textwidth
Corresponds to element 8 in the figure.
textheight
Element 7 in the figure.
total
Depends on other parameters, by default defines the dimensions of the Body, but can be combined with the includehead , includefoot , includeheadfoot and includemp commands to change the dimensions of Header, the Body, the Footer and the Margin Notes altogether.
left , lmargin , inner
These three parameters change the length of the left margin. Elements 1 and 3 in the figure, combined.
right , rmargin , outer
These three parameters change the length of the right margin. Elements 9 and 10 in the figure, combined.
top , tmargin
These two parameters represent elements 2 and 6 in the figure, combined.
bottom , bmargin
These two parameters set the distance from the bottom edge of the document to its baseline.
headheight
Height of the header
footsep
Separation between the bottom of the text (baseline) and the top of the footnote. Element 11 in the figure.
footskip
Distance between the baseline of the text and the baseline of the footnote.
marginparwidth , marginpar
Width of the margin notes. Element 10 in the figure.

The paper size can be set to any size you need by means of the command papersize={⟨width⟩,⟨height⟩} .

Let's see an example with some of the aforementioned options:

\usepackage{geometry}
 \geometry{
 a4paper,
 total={210mm,297mm},
 left=20mm,
 right=20mm,
 top=20mm,
 bottom=20mm,
 }

Open an example of the geometry package in ShareLaTeX

Reference guide

parameter description values
papersize Determines the size of the paper a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paper,

b0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paper, c0paper, c1paper, c2paper, c3paper, c4paper, c5paper, c6paper, b0j, b1j, b2j, b3j, b4j, b5j, b6j, ansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaper, letterpaper, executivepaper, legalpaper

Further reading

For more information see: