I don't want the header and the footer to appear in my table of contents. I used \thispagestyle{empty} just before \tableofcontents and it works... but just for the first page of my table of contents. But my table of contents is composed of 3 pages and the header and footer appear on the second and third pages. How can I manage to make them disappear ?

Thank you for helping me !

\documentclass[a4paper, 12pt]{book}
\usepackage{fancy}

\begin{document}

\tableofcontents
\thispagestyle{empty}

\chapter{Analysis}

\end{document}

• You could set before the table of contents \pagestyle{empty} and after it reset ist to \pagestyle{plain} or what you have defined before. It would be easier to help you, if you would include a minimal working example. – Martin - マーチン Nov 11 '19 at 14:33
• @Martin-マーチン, that actually won't work because the \chapter command within the \tableofcontents command resets the page style. – dgoodmaniii Nov 11 '19 at 14:38

One possible solution:

\let\originaltableofcontents\tableofcontents
\renewcommand\tableofcontents{%
\cleardoublepage
\pagestyle{empty}%
\originaltableofcontents
\cleardoublepage
\pagestyle{fancy}% <- use the page style of the document
}


MWE:

\documentclass[a4paper, 12pt]{book}
\usepackage{blindtext}% only for dummy text
\usepackage{fancyhdr}
\pagestyle{fancy}

\let\originaltableofcontents\tableofcontents
\renewcommand\tableofcontents{%
\cleardoublepage
\pagestyle{empty}%
\originaltableofcontents
\cleardoublepage
\pagestyle{fancy}% <- use the page style of the document
}

\begin{document}
\tableofcontents

\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument
\end{document}


Or maybe you can use package tocbasic:

\usepackage{tocbasic}
\renewcommand*{\tableofcontents}{\listoftoc[{\contentsname}]{toc}}% ToC under control of tocbasic
\AfterStartingTOC[toc]{\cleardoublepage}


MWE:

\documentclass[a4paper, 12pt]{book}
\usepackage{blindtext}% only for dummy text
\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{tocbasic}
\renewcommand*{\tableofcontents}{\listoftoc[{\contentsname}]{toc}}% ToC under control of tocbasic
\AfterStartingTOC[toc]{\cleardoublepage}

\begin{document}
\tableofcontents

\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument
\end{document}


There are two problems here: first, that \tableofcontents issues a \chapter command, which resets the pagestyle. It does so in two ways, in fact: one, it sets the pagestyle of the first page to plain, then the normal page style to headings. To cancel this out, you'll have to redefine \tableofcontents. If you find book.cls, you can search for it, and then see the changes you'll need to make. Try the following:

\makeatletter
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\thispagestyle{empty}
\@starttoc{toc}%
\pagestyle{empty}
\if@restonecol\twocolumn\fi
}
\makeatother


A MWE using this code produced the desired result: a TOC which consists of pages with the empty pagestyle. Note that you need to do \thispagestyle{empty} before \@starttoc, for the first page; then \pagestyle{empty} after it, for the subsequent pages.