Page Numbering in LaTeX: \pagenumbering, fancyhdr and Starting Pages
Updated December 1, 2026
Quick answer
- Roman, then arabic:
\pagenumbering{roman}for the front matter, then\clearpageand\pagenumbering{arabic}, which restarts at 1. - Start at a given page number:
\setcounter{page}{1}(any number), after\pagenumbering. - No page number:
\thispagestyle{empty}for one page (after\maketitle),\pagestyle{empty}for all. - Built-in styles:
\pagestyle{plain}(number centred in the footer),headings(number in the header),empty. - Move the page number:
\usepackage{fancyhdr},\pagestyle{fancy},\fancyhf{}, then\fancyfoot[C]{\thepage}(or[R],[L],\fancyhead). - Page X of Y:
\usepackage{lastpage}and\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}.
How Page Numbering in LaTeX Works by Default
\thepage prints the page counter. In article the first page is 1, the number is printed centred in the footer (page style plain), and the title made by \maketitle is numbered like any other page. In book and report the title page is a page of its own without a number. report keeps the plain style, while bookdefaults to headings: the number sits in the outer corner of the header next to the running chapter or section title.
Roman and Arabic Page Numbering: \pagenumbering
\pagenumbering{style} switches the numeral style and resets the counter to 1. The five built-in styles are:
\pagenumbering{arabic} % 1, 2, 3 (default)
\pagenumbering{roman} % i, ii, iii
\pagenumbering{Roman} % I, II, III
\pagenumbering{alph} % a, b, c (only up to 26 pages)
\pagenumbering{Alph} % A, B, CBecause the counter is reset, you normally issue the command right after a page break. The classic article layout with a roman-numbered table of contents and an arabic-numbered body looks like this:
\documentclass{article}
\title{Report}
\author{A. Author}
\begin{document}
\pagenumbering{roman} % i, ii, ...
\maketitle
\tableofcontents
\clearpage
\pagenumbering{arabic} % back to 1, 2, ...
\section{Introduction}
Body text starts on page 1.
\end{document}Always put \clearpage (or \cleardoublepage in two-sided documents) before the switch. The page counter is read when a page is shipped out, so changing the style mid-page would affect the page you are still on.
Front Matter and Main Matter in book
The book class has three commands that do the switching for you and also control chapter numbering:
\documentclass{book}
\title{Thesis}
\author{A. Author}
\begin{document}
\frontmatter % roman page numbers; \chapter is unnumbered
\maketitle
\tableofcontents
\chapter{Preface}
\mainmatter % arabic page numbers restart at 1; chapters numbered
\chapter{Introduction}
\appendix % chapters lettered A, B, ...; page numbers continue
\chapter{Data Tables}
\backmatter % chapters unnumbered again; page numbers continue
\chapter{Bibliography}
\end{document}\frontmatter calls \pagenumbering{roman}, \mainmatter calls \pagenumbering{arabic}, and both start with \cleardoublepage. The report and article classes do not define these commands; use the manual \pagenumbering sequence above, or load the memoir class, which has them.
Start Page Numbering at a Specific Page: \setcounter
To start a chapter extracted from a larger work at page 37, or to continue the numbering of a previous volume, set the counter directly. Do it after \pagenumbering, because that command resets the counter:
\clearpage
\pagenumbering{arabic}
\setcounter{page}{37} % this page is numbered 37A common variant is a document whose title page is counted but not printed. With \setcounter{page}{0} before a hand-made title page the first body page comes out as 1 (\maketitle in book and report resets the counter itself, so this trick does not work there); with \setcounter{page}{2} after the title page the title is implicitly page 1.
Remove the Page Number in LaTeX
On the title page
\thispagestyle{empty} removes header and footer from the current page only. In article, \maketitle sets the page style of the title page itself, so the command has to come after it:
\maketitle
\thispagestyle{empty} % after \maketitle, not beforeWith the titlepage class option, or in book and report, the title page is already empty. The same trick works for a hand-made titlepage environment, a dedication, or any page that should carry no number.
On chapter opening pages
\chapter issues \thispagestyle{plain} for its first page, which is why chapter openers show a centred number even when the rest of the document uses headings or fancy. To change what those pages look like, redefine the plain style rather than fighting each chapter. With fancyhdr:
\usepackage{fancyhdr}
\fancypagestyle{plain}{%
\fancyhf{}% % clear header and footer
\renewcommand{\headrulewidth}{0pt}% % no rule
}That makes every chapter opener completely blank. To keep the number but drop the header, add \fancyfoot[C]{\thepage} inside the definition.
Everywhere
\pagestyle{empty} % no headers or footers in the whole documentThe Built-in Page Styles
| Style | Header | Footer |
|---|---|---|
empty | nothing | nothing |
plain | nothing | page number, centred |
headings | running title and page number | nothing |
myheadings | text you set with \markboth/\markright, and the page number | nothing |
\pagestyle{...} applies from the current page onward; \thispagestyle{...} affects one page. For myheadings, set the text with \markboth{left header}{right header} (two-sided) or \markright{header} (one-sided). Anything beyond these four styles is the job of fancyhdr.
Page Number Position in LaTeX: Bottom, Top, Left or Right
The built-in styles only offer two positions: centred in the footer (plain) or in the header next to the running title (headings). For any other position, load fancyhdr, clear its defaults and put \thepage in the slot you want. \fancyfoot is the footer, \fancyhead the header, and [L], [C], [R] pick left, centre and right:
\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear header and footer
\fancyfoot[R]{\thepage} % page number bottom right
% \fancyhead[R]{\thepage} % ...or top right instead
\renewcommand{\headrulewidth}{0pt} % no line under the header
% Title and chapter pages use the plain style: give it the same footer
\fancypagestyle{plain}{\fancyhf{}\fancyfoot[R]{\thepage}}
\title{Notes}
\author{A. Author}
\begin{document}
\maketitle
\section{Introduction}
The number sits in the bottom right corner of every page.
\end{document}The \fancypagestyle{plain} line matters: without it the title page still shows the default centred number, because \maketitle and \chapter switch that page to plain. Formatting goes inside the slot too, for example \fancyfoot[C]{\textbf{\thepage}} or \fancyfoot[C]{-- \thepage\ --}.
Custom Headers and Footers with fancyhdr
fancyhdr gives you six slots: left, centre and right in both header and footer. Start by clearing them with \fancyhf{}, then fill the ones you need:
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all six fields
\fancyhead[L]{\leftmark} % chapter or section title
\fancyhead[R]{Draft, October 2026}
\fancyfoot[C]{\thepage} % page number, centred footer
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}\leftmark holds the current chapter title (or section title in article) and \rightmark the current section (or subsection). The default fancy style uppercases them; wrap the mark in \nouppercase if you prefer mixed case.
Two-sided documents: E and O
With the twoside class option the slot letters can be combined with E (even pages) and O (odd pages). The usual book layout puts the page number on the outer edge:
\documentclass[twoside]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage} % outer corner: left on even, right on odd
\fancyhead[RE]{\nouppercase{\leftmark}} % chapter on even pages
\fancyhead[LO]{\nouppercase{\rightmark}} % section on odd pages“Page X of Y” with lastpage
The lastpage package writes a label on the final page, so the total is \pageref{LastPage}. It needs two compilations to settle, and with hyperref you will usually want the unlinked \pageref*:
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{hyperref}
\pagestyle{fancy}
\fancyfoot[C]{Page \thepage\ of \pageref*{LastPage}}LastPage reports the number as printed on the last page, not the physical PDF page count. A book with six roman front-matter pages and twenty arabic pages ends at 20, not 26. Show only the roman page number in the front matter and enable “Page X of Y” in the main matter, as in the complete example below. This assumes arabic numbering continues through the final page; resetting it for an appendix makes LastPage unsuitable as a body total.
\headheight
Headers taller than the default 12pt trigger the warning “\headheight is too small (12.0pt): Make it at least 14.5pt”. Set the length once in the preamble, either directly or through geometry:
\setlength{\headheight}{15pt}
% or
\usepackage[a4paper, margin=2.5cm, headheight=15pt]{geometry}Custom Number Formats: Redefining \thepage
\pagenumbering is really two things: a reset of the counter and a redefinition of \thepage. If you want a different format without restarting at 1, redefine \thepage yourself. The same technique produces prefixed numbers for appendices or supplements:
% Switch to Roman numerals but keep counting
\renewcommand{\thepage}{\Roman{page}}
% Appendix pages as A-1, A-2, ... (page counter restarted)
\appendix
\clearpage
\setcounter{page}{1}
\renewcommand{\thepage}{A-\arabic{page}}With hyperref, \thepage must produce a different string for every page, otherwise you get “destination with the same identifier has been already used” warnings and links that jump to the wrong page. The prefix in the example above keeps the labels unique.
Numbering Across \include and \input Files
A document assembled from several files with \include or \input has one page counter, so numbering continues from file to file with no extra work. Two things break it: a \pagenumbering or \setcounter{page} left at the top of a chapter file, and compiling a chapter on its own with the subfiles package, where the counter naturally starts at 1 because nothing precedes it. With \includeonly the page numbers of the skipped files are taken from their .aux files, so the compiled chapters keep their final numbers after one full run.
Fix duplicate page destinations with hyperref
A printed page number and a PDF destination are different things. Restarting Arabic numbering can create two destinations named page.1, even when the first number is hidden with an empty page style. A warning about an identifier already being used means a link may land on the earlier page. Hiding the footer does not remove its anchor.
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\begin{document}
\hypersetup{pageanchor=false}
\begin{titlepage}
\centering
A report without a numbered cover
\end{titlepage}
\clearpage
\hypersetup{pageanchor=true}
\pagenumbering{roman}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\section{Results}
See page~\pageref{sec:data}.
\clearpage
\section{Data}\label{sec:data}
The second body page.
\end{document}Here only the cover has page anchors disabled. Roman front matter and Arabic body pages have distinct names under hyperref's default settings. Re-enable anchors before content that needs page links, and finish the cover before changing the setting. Do not disable anchors for the whole document just to suppress a warning: that sacrifices useful page destinations.
Compile twice and inspect both the log and the linked page reference. If a template intentionally repeats printed numbers, consult its hyperref configuration; hypertexnames=false uses artificial destination names but changes how page anchors are named and can affect index links. Do not apply it blindly to a document with an index. Also distinguish the PDF viewer's physical page count from the logical page label: the third PDF page can correctly be printed as page 1.
Common Errors
| Symptom | Cause | Fix |
|---|---|---|
| No page number on the first page, numbers elsewhere | The first page uses plain (set by \maketitle or \chapter) while your fancy style puts the number in the header | Redefine plain with \fancypagestyle, or write \thispagestyle{fancy} after \maketitle |
Title page shows a number although \thispagestyle{empty} is present | The command came before \maketitle, which sets plain afterwards | Move it after \maketitle |
| destination with the same identifier (name{page.1}) has been already used | Two pages print the same \thepage, typically a counted title page and body page 1 | Use roman numbering for the front matter, or \hypersetup{pageanchor=false} on the unnumbered pages |
Complete Example
A two-sided book with roman front matter, arabic main matter, running heads, a “Page X of Y” footer and clean chapter openers:
\documentclass[11pt, twoside]{book}
\usepackage[a4paper, margin=2.5cm, headheight=15pt]{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{hyperref}
\newcommand{\pagefooter}{\thepage}
\pagestyle{fancy}
% fancyhdr's \chaptermark ignores \frontmatter, so front-matter chapters
% would get "Chapter 0." in the running head; this version checks it
\makeatletter
\renewcommand{\chaptermark}[1]{%
\markboth{\if@mainmatter\@chapapp\ \thechapter.\ \fi #1}{}}
\makeatother
\fancyhf{}
\fancyhead[LE]{\nouppercase{\leftmark}} % chapter title on even pages
\fancyhead[RO]{\nouppercase{\rightmark}} % section title on odd pages
\fancyfoot[C]{\pagefooter}
\renewcommand{\headrulewidth}{0.4pt}
% Chapter opening pages: footer only, no header rule
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\pagefooter}%
\renewcommand{\headrulewidth}{0pt}%
}
\title{Page Numbering in Practice}
\author{A. Author}
\begin{document}
\frontmatter % i, ii, iii ...
\maketitle % unnumbered title page in book
\tableofcontents
\chapter{Preface}
Front-matter pages carry lowercase roman numerals.
\mainmatter % 1, 2, 3 ...
\renewcommand{\pagefooter}{Page \thepage\ of \pageref*{LastPage}}
\chapter{Introduction}
The opening page of each chapter uses the redefined \texttt{plain}
style; every other page uses \texttt{fancy}.
\section{Running Heads}
Even pages show the chapter, odd pages show the section.
\appendix
\chapter{Extra Material}
Appendix pages continue the arabic sequence.
\end{document}Frequently Asked Questions
How do I start page numbering at a specific number?
Finish the previous page with \clearpage, select the numbering style with \pagenumbering{arabic}, then use \setcounter{page}{37}. Changing the style resets the counter, so set the number afterward.
How do I hide a page number without restarting it?
Use \thispagestyle{empty} for one page or \pagestyle{empty} for following pages. These hide the header and footer but do not stop the page counter or remove hyperref page anchors.
Why does hyperref warn about a duplicate page.1 destination?
Restarted numbering can reuse a PDF destination even if the earlier number was hidden. Give front matter roman numbering or disable page anchors only for an unnumbered cover, then restore them before linked content.
Does Page X of Y count every physical PDF page?
Not necessarily. \pageref{LastPage} reports the label of the last page, which may differ from the physical total when numbering restarts. Compile twice and decide whether you need a logical final label or a physical page count.
Next Steps
Page numbers sorted? Keep working on the layout:
- Table of Contents in LaTeX –
\tableofcontents, depth, roman-numbered contents pages and tocloft styling - Page Size & Margins – Paper size, margins and
headheightwith the geometry package - Horizontal Lines in LaTeX – Header and footer rules,
\hrule,\ruleand table rules - LaTeX Hyperlinks – hyperref, link colors and the duplicate page anchor warning
Documentation and a place to test
Consult the hyperref documentation and fancyhdr documentation for supported options. Test a complete example in LaTeX Preview, then check the PDF with your final document class.
Fix page numbering faster with AI
Open the complete example in Octree and compare the roman front matter with the arabic body pages. Ask the AI assistant to explain a numbering warning, then check the title page, chapter openers and final footer in the compiled PDF.
Open Octree →