Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}.

share|improve this question
add comment

3 Answers

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}
...
share|improve this answer
4  
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
    
@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 7 '13 at 12:33
add comment

Using tocloft,

\usepackage{tocloft}

it is as simple as placing this line:

\tocloftpagestyle{empty}

somewhere in the preamble.

share|improve this answer
    
Same as with Stefan solution, using tocloft empty option does not remove middle page numbers in 3-page ToC. –  Rafal Dec 7 '13 at 12:35
add comment

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
share|improve this answer
    
This wouldn't remove headers. –  egreg Apr 25 at 12:41
    
You are right. Edited to reflect this fact. –  AthanasiusOfAlex Apr 25 at 14:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.