[Tex/LaTex] Plain/Empty page style for multipage ToC with package fancyhdr

fancyhdrheader-footertable of contents

(edit) Added MWE at the end of the question.

Maybe it has something to do with redefining \thepage?
If so, I don't know how to make sure otherwise that all pages other than ToC, \chapter and \part are in the new fancyhrd style.


I am trying to get rid of the fancyhdr header (including the page number in my definition) for my table of content, which is 3 pages long.

I've already tried multiple related answers, but none of them seem to work in my case. For example, I tried:

\begingroup
\makeatletter
\let\ps@fancy\ps@emptystyle
\tableofcontents
\clearpage
\endgroup

suggested here, but it doesn't seem to do anything.

I also tried:

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

suggested here, which works in removing the fancyhdr header from page 1 and 3 of the ToC, but not the second.

Any idea what else can I try to get this working?


\documentclass[11pt, a4paper, final]{report}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{hyperref}
\hypersetup{hidelinks}
\usepackage[capitalise,noabbrev,nameinlink]{cleveref}

\usepackage{fancyhdr} 

\pagestyle{fancy}
\fancyhead[R]{\thepage}
\fancyhead[L]{\textit{\nouppercase{\leftmark}}} 
\fancyfoot{} 

\fancypagestyle{plain}{ 
    \fancyhf{}
    \fancyhead[R]{\thepage}
    \fancyfoot{}}

\begin{document}

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

\setcounter{page}{0}

\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument
\Blinddocument

\end{document}

Best Answer

If you can load package tocbasic, then you can use

\usepackage{tocbasic}
\addtotoclist[report.cls]{toc}
\renewcommand*{\tableofcontents}{\listoftoc[{\contentsname}]{toc}}% ToC under control of tocbasic
\AfterTOCHead[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

enter image description here

Note that tocbasic can not be used together with tocloft.

Code:

\documentclass[11pt, a4paper, final]{report}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[capitalise,noabbrev,nameinlink]{cleveref}

\usepackage{fancyhdr} 
\setlength\headheight{13.6pt}% as suggested by fancyhdr
\pagestyle{fancy}
\fancyhead[R]{\thepage}
\fancyhead[L]{\textit{\nouppercase{\leftmark}}} 
\fancyfoot{} 

\fancypagestyle{plain}{ 
    \fancyhf{}
    \fancyhead[R]{\thepage}
    \fancyfoot{}}

\usepackage{tocbasic}
\addtotoclist[report.cls]{toc}
\renewcommand*{\tableofcontents}{\listoftoc[{\contentsname}]{toc}}% ToC under control of tocbasic
\AfterTOCHead[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

\usepackage{hyperref}
\hypersetup{hidelinks}
\begin{document}
\pagenumbering{roman}% use a different numbering scheme to avoide the same identifier problem
\tableofcontents

\cleardoublepage
\pagenumbering{arabic}
\Blinddocument\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\end{document}