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 do I clear the \tableofcontents page in book or report?

\documentclass[a4paper]{book}
\usepackage{lipsum}
\begin{document}

% i need clear this page
{\thispagestyle{empty} %but is not work
\tableofcontents}

\chapter{Book tableofcontents without page number}

\lipsum

\end{document}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Use the following in your document preamble:

\documentclass[a4paper]{book}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\tableofcontents}{\@starttoc{toc}}{\thispagestyle{empty}\pagestyle{empty}\@starttoc{toc}}{}{}
\makeatother
\begin{document}

% i need clear this page
\tableofcontents
\clearpage
\pagestyle{headings}% ...or whichever heading style you use
\cleardoublepage
%...
\end{document}

You patch \tableofcontents using etoolbox to set the current page style to empty, as well as the following page styles (if your ToC spans more than one page) to empty. \clearpage flushes the current page (last one of the ToC), after which you can reset your page style to headings (or whatever you like). The additional \cleardoublepage makes sure that there's an additional page flush (if necessary) to make sure the chapter starts on a recto page.

The approach is similar to that followed in Clear tableofcontents page in memoir.

share|improve this answer
    
all odd page are without number too. –  Regis da Silva Dec 20 '11 at 2:00
    
@RegisdaSilva: Look back at your original question. There is no mention that you want odd pages to have numbers and even pages to have no number. Is this what you want? That is, do you want odd pages to have numbers, but even pages have no number? Where should these numbers be? In the header, or the footer? And should this configuration hold for just the ToC? It helps being specific about these things, since a solution will be much more forthcoming that way. –  Werner Dec 20 '11 at 2:18
    
I want numbering on all pages except the tableofcontents, but this is not happening with your code. –  Regis da Silva Dec 20 '11 at 2:28
    
@RegisdaSilva: If I compile my code with a \chapter{Book tableofcontents without page number} \lipsum after \pagestyle{headings}, I get a 4-page document. Page 1 and 2 have no headings (and no page numbers), while page 3 and 4 have the regular plain (for chapter first pages) and headings headings. Do you want page 2 to have headings as well? –  Werner Dec 20 '11 at 2:52
    
yes!!!!!!!!!!!!!!!! –  Regis da Silva Dec 20 '11 at 3:25
show 3 more comments

I would combine \pagestyle and add \thispagestyle to the .tocfile, to have effect on the first page of the ToC.

\documentclass[a4paper]{book}
\usepackage{lipsum}
\begin{document}
\addtocontents{toc}{\protect\thispagestyle{empty}} % at the beginning of your document
     % writes \thispagestyle{empty} into the .toc file`, so here at the beginning
\pagestyle{empty}% switches to empty page style
\tableofcontents
\cleardoublepage% clear the page before changing back the page style
\pagestyle{headings}% switching back to the page style you use in your document
\chapter{Book table of contents without page number}
\lipsum
\end{document}

\protect is used to prevent expansion of \thispagestyle before it's written to the .toc file.

share|improve this answer
    
This is much cleaner and etoolbox-free! –  Werner Dec 20 '11 at 7:21
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.