[Tex/LaTex] Removing page number from ToC while maintaining header/footer information

header-footerpage-numberingtable of contents

I am editing a document that was created by someone else. The original document has a custom header/footer and the page numbering was commented out. All I wanted to do was to turn the page numbering on. I figured out how to do that, however, in doing so, the ToC (which also uses the header/footer) now shows page numbering as well. The document has a cover page, a blank page, a title page, then the ToC. Because I don't care to show the header/footer on the first 3 pages, I can use the \thispagestyle{empty} command and thus not show any page numbers. However, I do want to maintain the header footer information (minus the page numbering) in the ToC. FYI, the ToC itself is 6 pages long. The page numbering on the first page of the ToC starts with page 4. How can I suppress the page numbering on all 6 ToC pages while still maintaining the rest of the header/footer information?

Best Answer

If you only want to remove page numbers for the first segment of your document while leaving the rest of your header/footer unchanged, redefine \thepage to display nothing at the start of your document and restore its original definition after the first segment (and a page break).

\documentclass{article}

\pagestyle{headings}

\begin{document}
\renewcommand*{\thepage}{}

\tableofcontents

\clearpage
\renewcommand*{\thepage}{\arabic{page}}

\section{foo}

\subsection{foobar}

Some text.

\end{document}
Related Question