24

How can I make produce a table of contents by \tableofcontents with page style empty? It doesn't work with \thispagestyle{empty} or \pagestyle{empty}.

Stefan Kottwitz
  • 231,401
Regis Santos
  • 14,463

3 Answers3

22

You could use this in your preamble to change the first (otherwise commonly plain) TOC page to empty style:

\AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} 

The other pages behave like expected if you use \pagestyle{empty} like you firstly did. So your document may look like

\documentclass{book}
\AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} 
\begin{document}
\pagestyle{empty}
\tableofcontents
\cleardoublepage
\pagestyle{headings}
...
Stefan Kottwitz
  • 231,401
  • 5
    Am I missing something, or does this only work for single-page ToC's? – lockstep Nov 22 '10 at 20:34
  • 1
    @lockstep: you're right, the originally used \pagestyle{empty} which Regis used is still required before \tableofcontents. The line posted by me is an addition which modifies the first TOC page which would otherwise might keep plain page style. Thanks for pointing that out. – Stefan Kottwitz Nov 22 '10 at 21:04
  • 3
    @StefanKottwitz I have Table of Contents that is 3 pages long. With your solution, as well as other solutions, even after using \pagestyle{empty} next to \tableofcontents middle (second) page of table of contents still does have page number in the footer. So it looks like your solution removes page numbers only from first and last page. Do you have any idea for on removing middle page footer as well? – Rafal Dec 07 '13 at 12:33
  • This solution solved my problem! 2 page TOC, first page didn't show formatting properly but second page did - after adding this it worked! – Prevost Sep 29 '17 at 23:33
  • This answer should be the accepted one. This is a 1-line addition and it solves the problem directly – XaWin Aug 22 '18 at 06:35
  • @Rafal Just add \addtocontents{toc}{\protect\thispagestyle{empty}} in the content. If the second page of toc is starting from chapter-11, just add the above code inside content of chapter 11. – Kevin Siji Feb 20 '21 at 14:01
  • 1
    @KevinSiji Thanks. Back in 2013 I figured this out and added this to the macro I am using to create chapter headings (so it gets added below each chapter heading, making sure all TOC pages will not have the page number) to avoid manual work. – Rafal Feb 20 '21 at 22:28
6

If you use the fancyhdr package, you can remove the page numbering for a multiple-page table of contents as follows:

\clearpage                       % Otherwise \pagestyle affects the previous page.
{                                % Enclosed in braces so that re-definition is temporary.
  \pagestyle{empty}              % Removes numbers from middle pages.
  \fancypagestyle{plain}         % Re-definition removes numbers from first page.
  {
    \fancyhf{}%                       % Clear all header and footer fields.
    \renewcommand{\headrulewidth}{0pt}% Clear rules (remove these two lines if not desired).
    \renewcommand{\footrulewidth}{0pt}%
  }
  \tableofcontents
  \thispagestyle{empty}          % Removes numbers from last page.
}

It seems there are three headers that need to be altered separately:

  1. The first page, which always uses the plain style, no matter what. (Therefore, it needs to be redefined manually.)
  2. The middle pages, which follow the current pagestyle.
  3. The last page, which has to be altered with thispagestyle.

You can add the fancyhdr package by adding the following line in the preamble:

\usepackage{fancyhdr}

The advantage of this solution is that it preserves page numbering as you would expect.

Another option, if all you are using is a plain page number, is to remove it using

\clearpage
\pagenumbering{gobble}
\tableofcontents

You could then restore it (if you are using Arabic numerals) with

\pagenumbering{arabic}

(Valid options include arabic, roman, Roman, alph, and Alph.)

If, when using this option, for some reason you want the page numbering to continue before and after the table of contents, you will need to save the page number and restore it:

\newcounter{savepage}             % Creates a counter for saving the page
\setcounter{savepage}{\thepage}   % Saves the page
\clearpage                        % Table of contents, without numbering
\pagenumbering{gobble}
\tableofcontents
\clearpage                        % New section, with numbering
\pagenumbering{arabic}
\setcounter{page}{\thesavepage}   % Restores the old page number
\addtocounter{page}{1}            % Upticks the page number by one to continue the numbering
4

Using tocloft,

\usepackage{tocloft}

it is as simple as placing this line:

\tocloftpagestyle{empty}

somewhere in the preamble.

mk12
  • 1,847
  • 2
  • 15
  • 17