Page numbering
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}
The command \pagenumbering{roman}
will set the page numbering to lowercase Roman numerals.
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}
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 numeralsroman
: lowercase roman numeralsRoman
: uppercase roman numeralsalph
: lowercase lettersAlph
: 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.
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}
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.
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}
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.
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}
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.
Further reading
For more informations see Page numbering in LaTeX
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips