LaTeX numbers pages for you, which is fine until a university template asks for roman numerals in the front matter, a journal wants no number on the title page, or a report needs "Page 3 of 12" in the footer. Each of those takes one or two lines once you know which command controls what.
Three things are involved. The page counter holds the number. \pagenumbering chooses how that number is printed and resets it. The page style (plain, empty, or a custom style from the fancyhdr package) decides whether and where it appears.
Short answer
Use \pagenumbering{roman} for the front matter and \pagenumbering{arabic} where the main text starts (each call restarts at 1). Use \thispagestyle{empty} to hide the number on one page and \pagestyle{empty} to hide it everywhere.
Change the numbering style with \pagenumbering
\pagenumbering{style} sets the format of page numbers from that point on and resets the counter to 1. The five styles are:
| Style | Output |
|---|---|
arabic | 1, 2, 3 (the default) |
roman | i, ii, iii |
Roman | I, II, III |
alph | a, b, c |
Alph | A, B, C |
The usual thesis pattern is roman numerals for the abstract and contents, then arabic numerals from the first chapter. Put \clearpage before the switch so the change happens on a fresh page:
\documentclass{article}
\begin{document}
\pagenumbering{roman}
\begin{abstract}
A short abstract on page i.
\end{abstract}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\section{Introduction}
The main text starts on page 1.
\end{document}In the book class you do not need to switch by hand. \frontmatter gives roman numbers and unnumbered chapters, \mainmatter restarts at arabic 1, and \backmatter keeps the numbering but drops chapter numbers for appendices-style material such as the bibliography.
\documentclass{book}
\begin{document}
\frontmatter
\chapter{Preface}
Roman page numbers here.
\tableofcontents
\mainmatter
\chapter{Introduction}
Arabic page numbers start at 1.
\backmatter
\chapter{Notes}
\end{document}Start numbering at a specific page
Set the counter directly with \setcounter{page}{n}. The value applies to the page you are on, so put it at the start of the page whose number you want to change:
\setcounter{page}{25}This is handy when a chapter is compiled on its own but will be printed inside a larger volume, or when a journal gives you a starting page for proofs. To restart from 1 without changing the style, \setcounter{page}{1} does the same job as calling \pagenumbering{arabic} again.
Remove page numbers
Use \pagestyle{empty} in the preamble to remove numbers from every page, or \thispagestyle{empty} to remove the number from the current page only.
The title page is the common trap. \maketitle sets the plain style on its own page, which prints a number, and that overrides an earlier \pagestyle{empty}. Put \thispagestyle{empty} straight after \maketitle:
\documentclass{article}
\title{A Study of Something}
\author{A. Author}
\begin{document}
\maketitle
\thispagestyle{empty}
\section{Introduction}
Text.
\end{document}If you want a separate title page that does not count towards the numbering at all, use the titlepage environment. In a one-sided article, the page after it is numbered 1.
Chapter opening pages in book and report have the same issue, because \chapter also switches to plain for that page. To change those, redefine the plain style with fancyhdr, as in the next section.
Move the page number with fancyhdr
The standard styles put the number in the centre of the footer. The fancyhdr package lets you put it anywhere in the header or footer. \fancyhf{} clears the defaults first, and the letters L, C and R choose left, centre or right:
\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
The number is now at the bottom right.
\end{document}For the top right, use \fancyhead[R]{\thepage} instead. In a two-sided document (\documentclass[twoside]{book}), \fancyfoot[LE,RO]{\thepage} puts the number on the outer edge: left on even pages, right on odd pages.
To make chapter opening pages match, redefine plain the same way:
\documentclass{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[R]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
}
\begin{document}
\chapter{Introduction}
Chapter pages also show the number at the bottom right.
\end{document}Show "Page X of Y"
The lastpage package adds a label called LastPage on the final page, so \pageref{LastPage} prints the last page number. Combine it with fancyhdr:
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
Text on the first page.
\end{document}Compile twice. On the first run LaTeX does not yet know the last page, so you will see "Page 1 of ??". Overleaf and latexmk rerun automatically. LastPagegives the number printed on the last page, so with roman front matter it counts only the arabic pages, which is usually what "Page X of Y" in the main text should show.
Common problems
- A number still appears on the title page:
\maketitleset theplainstyle. Add\thispagestyle{empty}after it. - Numbering restarts at 1 unexpectedly: every
\pagenumberingcall resets the counter. Use\renewcommand{\thepage}{\arabic{page}}if you only want to change the format. - "Page 1 of ??": the document needs a second compile for the
LastPagereference. - Headers look wrong on chapter pages: those use the
plainstyle. Redefine it with\fancypagestyle{plain}. - "Undefined control sequence" on
\fancyheador\fancyfoot: fancyhdr is not loaded. See our guide to fixing undefined control sequence errors.
Frequently Asked Questions
How do I add page numbers in LaTeX?
You do not need to add them. The standard classes number pages automatically in the footer. Use \pagenumbering to change the style and fancyhdr to change the position.
How do I remove the page number from the first page?
Put \thispagestyle{empty} on that page. If the first page is made by \maketitle, put it straight after \maketitle.
How do I use roman numerals for the table of contents?
Call \pagenumbering{roman} before the table of contents and \pagenumbering{arabic} at the start of the main text, after a \clearpage. In the book class, use \frontmatter and \mainmatter.
More LaTeX Guides
Written by Dr. Meng Zhao
Physician-Scientist · Founder, LabCat AI
MD · Former Neurosurgeon · Medical AI Researcher
Dr. Meng Zhao is a former neurosurgeon turned medical-AI researcher. After years in the operating room, he moved into applied AI for clinical workflows and now leads LabCat AI, a medical-AI company working on decision support and research tooling for clinicians. He built Journal Metrics as a free resource for researchers who need reliable journal metrics without paid database subscriptions.
Related Articles
LaTeX Footnotes: Add, Reuse and Customize Footnotes (Including in Tables)
How to use footnotes in LaTeX: \footnote, footnotes in tables and minipages, referring to the same footnote twice, symbols instead of numbers, unnumbered notes and endnotes.
7 min readLaTeXLaTeX Hyperlinks with hyperref: \href, \url, Link Colors and Internal Links
How to add hyperlinks in LaTeX with hyperref: \href and \url, email links, links to sections and pages, colored links instead of boxes, breaking long URLs, and PDF metadata.
7 min readLaTeXLaTeX Two Columns and multicol: Column Layouts, Column Breaks and Figures
How to write in two or more columns in LaTeX: the twocolumn option, the multicol package, column breaks and separation, full-width titles, and how to place figures in columns.
7 min read