I want to make my Table of Contents pages show "Table of Contents" in their headers with package fancyhdr
. Right now, according to the MWE below, this is what it shows:
And this is what I want it to show:
The header, in this case, was done via \fancyhead[RE,LO]{Table of Contents}
. This affects all other pages though, which is definitely not what I want.
Below is my MWE:
\documentclass[10pt,openany]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE,LO]{Part \thepart\enspace--\enspace Chapter \thechapter}
\fancyhead[LE,RO]{\thepage}
\fancyfoot[C]{My Book}
\begin{document}
\tableofcontents
\part{One}
\chapter{1}
\chapter{2}
\part{Two}
\chapter{3}
\chapter{4}
\chapter{5}
\chapter{6}
\chapter{7}
\part{Three}
\chapter{8}
\chapter{9}
\chapter{10}
\chapter{11}
\chapter{12}
\part{Four}
\chapter{13}
\chapter{14}
\part{Five}
\chapter{15}
\chapter{16}
\chapter{17}
\chapter{18}
\chapter{19}
\chapter{20}
\part{Six}
\chapter{21}
\chapter{22}
\chapter{23}
\chapter{24}
\end{document}
EDIT: My environment is MikTeX 2.9 and Command-Line pdflatex
(with the help of Neovim) on Windows 10.
MORE EDIT: I want to be able to change the stuff that goes in the header/footer, so even though \pagestyle{fancy}
does print TABLE OF CONTENTS for ToC pages, I'd like to avoid that option unless absolutely necessary.
Best Answer
Well, you can for example define two own styles to be used:
Style
styletoc
is then only used for the table of contents part, stylestylenor
for the other parts. Please sse that you should also define a new styleplain
:to get rid of the headrule without any other datas and the standard page number in the center of the footer ...
With the following mwe
you get the following wished result:
and for chapter 1 etc: