Icon for parent category 'Writing'

Pages Layouts & Margin

Until now we’ve silently accepted the size of the margins LaTeX decides. Not anymore! Let’s look changing the amount of white space around your document. And how to add custom headers, footers and other notes within the margin.

Page Layout

Schematic of all the different lengths and margins used for a default page
Schematic of all the different lengths and margins used for a default page

Remark

This is a right-hand page. The whole schematic is simply mirrored for left-hand pages.

All of these values are defined using regular lengths. This means you can change all of them the way you’re used to. These internal built-in lengths are:

LengthDefaultDescriptionNumber
1 inch + \hoffset72ptTotal offset from left edge1
1 inch + \voffset72ptTotal offset from top edge2
\oddsidemargin31ptMargin at the odd side3
\topmargin20ptMargin at the top4
\headheight12ptHeight of the header5
\headsep25ptDistance between header and text6
\textheight592ptHeight of text7
\textwidth390ptWidth of text8
\marginparsep10ptDistance between margin paragraphs and text9
\marginparwidth35ptWidth of margin paragraph10
\footskip30ptDistance between footer and text11
\marginparpush7ptDistance between two margin paragraphs12
\hoffset0ptExtra horizontal offset from the left13
\voffset0ptExtra vertical offset from the top14
\paperwidth597ptWidth of the actual paper15
\paperheight845ptHeight of the actual paper16

Some properties talk about margin paragraphs. This simply means text written in the margin of the document, which is what we’re discussing next.

Margin Notes

LaTeX supports margin notes by default, with the command

1\marginpar[even side text]{odd side text}

That’s great, but it doesn’t support margin notes at all places. For example, footnotes and headers can’t have notes written in the margin. It also has no optional arguments to remedy this.

The marginnote package solves this. The syntax becomes

1\marginnote[vertical offset]{odd side text}

You can switch around the position of the margins with the \reversemarginpar command.

1Lorem ipsum dolor sit amet, consectetur adipiscing elit. \marginpar[This margin is not displayed, because article document type has only one side for margin notes]{This is a cool margin note on the big, odd side} 
2
3Proin porttitor justo quis dolor hendrerit, at ultricies nibh accumsan. Duis ut urna leo. Quisque in urna non odio suscipit faucibus quis at est. Proin in enim id leo vehicula ultricies nec at justo. Nam mattis, orci nec ullamcorper finibus, metus turpis laoreet leo, ac lacinia erat est quis risus.
Code above > output below
Code above > output below

Headers and Footers

Very early in this course, you saw how to automatically set headers and footers by changing the page style.

Now you’re ready to hear: you can set them to anything you like!

  • Use \markright{text} to set the header for all right-hand pages.
  • Use \markboth{text}{text} to set the header for all pages.

Within them, use these commands to suit your needs.

CommandDescription
\thepageThe current page number.
\leftmarkCurrent chapter name, printed like “CHAPTER X. CHAPTER TITLE”
\rightmarkCurrent section name, printed like “X.Y.Z SECTION TITLE”
\chapternameThe actual word chapter in the document’s language
\thechapterThe number of the current chapter
\thesectionThe number of the current section.
1\section{First Section}
2\pagestyle{headings}
3\markboth
4    {Section \thesection at page \thepage}
5    {Section \thesection \ at page \thepage} 
6
7Lorem ipsum, blabla, you know it by now, I guess.
Code left > output right
Code left > output right
Remark

Most of these are regular counters you’ve already learnt about. As such, you can also use them outside of headers and footers.

Continue with this course
Support me and this website!

Want to support me?

Buy one of my projects. You get something nice, I get something nice.

Donate through a popular platform using the link below.

Simply giving feedback or spreading the word is also worth a lot.