[Tex/LaTex] Table of contents pagestyle

fancyhdrheader-footertable of contents

Consider the following MWE:

\documentclass[a4paper, twoside, 11pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \renewcommand{\sectionmark}[1]{\markright{\thesection~ - ~#1}}
    \renewcommand{\chaptermark}[1]{\markboth{\chaptername~\thechapter~ - ~#1}{}}
    \fancyhead[RO]{\textsc\rightmark}
    \fancyhead[LE]{\textsc\leftmark}
    \fancyfoot[C]{\thepage}
\fancypagestyle{plain}
    {
        \fancyhf{}
        \renewcommand{\headrulewidth}{0pt}
        \fancyfoot[C]{\thepage}
    }
\begin{document}
\begin{titlepage}
Nice titles and all
\end{titlepage}
\thispagestyle{empty}

\cleardoublepage
\pagenumbering{roman}
\begin{abstract}
\thispagestyle{plain}
    This is a very nice abstract.
\end{abstract}
\thispagestyle{plain}
\cleardoublepage
\tableofcontents
\thispagestyle{plain}
\cleardoublepage
\thispagestyle{plain}
\cleardoublepage
\thispagestyle{plain}

There is one problem: after the table of contents (which is now one page and I think will stay one page) the doubleclearpage makes the empty page I want, but it keeps the header with contents in it, even though I tell him to take the plain pagestyle. It seems that tableofcontents likes his own pagestyle. How can I fix this? Note: I have considered other questions regarding similar questions (Table of contents with page style empty) but none of the solutions worked for me.

Best Answer

You can use scrextend. Then you can set the page style used on blank pages (pages inserted by \cleardoublepage) as package option cleardoublepage=<value>. Possible values are empty (default), plain, current or the name of another page style.

The value of the option can be changed inside the document using \KOMAoptions{cleardoublepage=<value>}.

There are also new commands like \cleardoubleemtypage, \cleardoubleplainpage, \cleardoublestandardpage to set the page style just for this single blank page.

In the following example I use option cleardoublepage=plain and a \cleardoubleemptypage after the title page and the abstract.

\documentclass[a4paper, twoside, 11pt]{report}
\usepackage[cleardoublepage=plain]{scrextend}
\usepackage{fancyhdr}
\setlength\headheight{13.6pt}% as suggested by fancyhdr
\pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \renewcommand{\sectionmark}[1]{\markright{\thesection~ - ~#1}}
    \renewcommand{\chaptermark}[1]{\markboth{\chaptername~\thechapter~ - ~#1}{}}
    \fancyhead[RO]{\textsc\rightmark}
    \fancyhead[LE]{\textsc\leftmark}
    \fancyfoot[C]{\thepage}
\fancypagestyle{plain}
    {
        \fancyhf{}
        \renewcommand{\headrulewidth}{0pt}
        \fancyfoot[C]{\thepage}
    }
\usepackage{blindtext}% dummy text
\begin{document}
\begin{titlepage}
Nice titles and all
\end{titlepage}
\cleardoubleemptypage
\pagenumbering{roman}
\begin{abstract}
\thispagestyle{plain}
    This is a very nice abstract.
\end{abstract}
\cleardoubleemptypage
\tableofcontents
\cleardoublepage
\pagenumbering{arabic}
\blinddocument
\end{document}