# How to hide page numbers but still be able to use them in TOC

How to hide page numbers in my document and still be able to display them in table of contents?

Obviously, \pagenumbering{gobble} does work, but they are no more visible in the table of contents either.

Any help is appreciated.

• What \documentclass are you using? Are you using something like fancyhdr? – Werner Nov 29 '15 at 20:21
• Welcome! Is the aim to confuse and frustrate your readers? – cfr Nov 29 '15 at 20:27
• Why you like to inform reader, that it can find something on the page xy, but this page number is not presented? – Zarko Nov 29 '15 at 20:29
• @Werner I am using \documentclass{article}, am not using fancyhdr.@Zarko The page numbers must be hidden, as it is an assignment to rewrite a word document in LaTeX and the word document does not have page numbers. – Matt Nov 29 '15 at 20:38
• @Matt: Your assignment is to make a full copy of a Word document? – user31729 Nov 29 '15 at 20:51

Since there's no special header or footer apparently, I would suggest to use \pagestyle{empty}, but as cfr and Zarko already noted: This is confusing -- does one have to count the pages oneself during reading (either on screen or using a hardcopy?)

\documentclass{article}

\usepackage{blindtext}

\pagestyle{empty}
\begin{document}
\tableofcontents
\section{First}
\blindtext[10]
\section{Second}
\blindtext[10]

\end{document}


Update Removing the page number from title page as well

The \maketitle command uses \thispagestyle{plain} explicitly. Redefining \maketitle is too much work (or patching as well). Since pagestyles are defined in \ps@.... macros, it's easier to use

\makeatletter
\let\ps@plain\ps@empty
\makeatother


i.e. making the plain style a copy of empty.

\documentclass{article}

\usepackage{blindtext}

\title{Theory of Brontosaurs}
\author{Ann Elk (Misses)}

\pagestyle{empty}
\makeatletter
\let\ps@plain\ps@empty
\makeatother
\begin{document}
\maketitle
\clearpage
\tableofcontents
\clearpage
\section{First}
\blindtext[10]
\section{Second}
\blindtext[10]

\end{document}

• Okay, \pagestyle{empty} seems to work almost as desired, just with one small problem: the title page (made with \maketitle) still shows up as number one, is there a way to get rid of that as well? – Matt Nov 29 '15 at 21:54
• @Matt: See the update please! – user31729 Nov 29 '15 at 22:00

One simple way to do this is to use fancyhdr to clear the page numbers.

% in preamble
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % removes the horizontal bar at the top


Note that if you have a title, you need to fix the title page as well, by calling \thispagestyle{fancy}.
% in document body

Part of this hinges on the fact that you're using the article document class, which has no default header or footer except for the page number. If you wanted to use a different class, such as amsart, this would clear the default header, which also contains your title, so you'd want to use fancyhdr to put the title back.
If you used a document class with chapters, such as book, you'd need to call \thispagestyle{fancy} at the start of each chapter, and again, specifics would depend on your document class.