Aller au contenu

Page numbering in LaTeX uses Arabic numbers by default, but this can be changed to use Roman numerals and/or letters. You can also combine several numbering styles in a single document, this article explains how.

Introduction

Setting a numbering style is straightforward

\documentclass{article}
\usepackage[utf8]{inputenc}

\pagenumbering{roman}

\begin{document}
\tableofcontents

\section{Testing section}
...

\end{document}

PageNumberingEx1.png


The command \pagenumbering{roman} will set the page numbering to lowercase Roman numerals.

  Open an example in ShareLaTeX

Numbering styles

There are several numbering styles, at the introduction the lower-case Roman numerals were presented, let's see a second example:

\documentclass{article}
\usepackage[utf8]{inputenc}

\pagenumbering{alph}

\begin{document}
\tableofcontents

\section{Testing section}
...

\end{document}

PageNumberingEx2.png


As mentioned before, following command is used to set the layout of the page number.

\pagenumbering{num_style}


Below, a list of styles available for page numbering:

  • arabic: arabic numerals
  • roman: lowercase roman numerals
  • Roman: uppercase roman numerals
  • alph: lowercase letters
  • Alph: uppercase letters

The position where the number appear in the page is determined by the page style used in the document. See the Headers and footers section for more information.

  Open an example in ShareLaTeX

Using two page numbering styles in a single document

In books, is customary to use Roman numerals for the pages before the first chapter/section, and Arabic numbers for the rest of the document. There are two commands available in the book document class that accomplish this:

\documentclass{book}
\usepackage[utf8]{inputenc}

\begin{document}

\frontmatter

\addcontentsline{toc}{chapter}{Foreword}
\Some text...

\addcontentsline{toc}{chapter}{Dummy entry}
Some text...

\tableofcontents

\mainmatter

\chapter{First Chapter}

This will be an empty chapter...

\end{document}

PageNumberingEx3.png


The commands that control the page numbering are:

\frontmatter
The pages after this command and before the command \mainmatter, will be numbered with lowercase Roman numerals.
\mainmatter
This will restart the page counter and change the style to Arabic numbers.

  Open an example in ShareLaTeX

If your document class is not book or you need more control over the page counter and the numbering style, see the next example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\pagenumbering{roman}

\begin{document}
\tableofcontents

\section{First section}
\setcounter{page}{3}

Some text here...

\section{Second section}
Some more text here..

\section{Heading on Level 1 (section)}
\pagenumbering{arabic}

More text here...
\end{document}

PageNumberingEx4.png


In the example above the numbering styles are explicitly established and the counter set to a specific number. Below a description of each command is provided:

\pagenumbering{roman}
This command sets the page numbers to lowercase Roman numerals.
\setcounter{page}{3}
This will manually set the page counter to 3 in this page, subsequent pages are numbered starting the count from this one.
\pagenumbering{arabic}
The page numbering is switched to Arabic, this will also restart the page counter.

  Open an example in ShareLaTeX

Customizing numbering styles

With the aid of the package fancyhdr we can customize how the page numbers are displayed. For example, if you want to put the current page number in the context of the page numbers in the whole document (1 of 120, for instance) you can do that as shown below:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{lastpage}

\pagestyle{fancy}
\fancyhf{}

\rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}

\begin{document}

\tableofcontents

\section{First section}
Some text...

\section{Second section}
More text...

\end{document}

PageNumberingEx5.png


Here, the package lastpage is imported by

\usepackage{lastpage}


so we can refer the last page of the document. Then we set fancyhdr to display on the downer right corner the text "Page n of All" where n is the current page and All is the last page. See the article about headers and footers for more concise information and examples about fancyhdr.

  Open an example in ShareLaTeX

Further reading

For more informations see Page numbering in LaTeX

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX