3

In the documentclass report, how do I prevent "CONTENTS" from appearing in the header of the Table of contents?

In the preface I have no header, only page numbers, and in the main part I want chapter in the upper, inner corner and section in the upper, outer corner - but not in the ToC where I only want page numbers.

\documentclass[12pt,a4paper,UKenglish,T1,twoside,openright]{report}

\usepackage[latin1]{inputenc}
\usepackage[bindingoffset=1cm,centering,margin=2.4cm]{geometry}
\usepackage[final]{pdfpages}
\usepackage{lastpage}

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\ #1}{}}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[RO,LE]{\thepage\ of \pageref{LastPage}}

\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}
\fancyfoot[RO,LE]{\thepage\ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}


\begin{document}
\pagenumbering{Roman}
\includepdf[pages={1,{}}]{Tittelside.pdf}
\setcounter{page}{1}
\thispagestyle{plain}
\include{Abstract/abstract}
\newpage
\thispagestyle{plain}
\mbox{}
\newpage
\pagestyle{plain}

\tableofcontents
\clearpage{\pagestyle{plain}\cleardoublepage}

\pagenumbering{arabic}
\pagestyle{plain}
\include{Introduction/introduction}
\include{Futurework/Futurework}

\end{document}

1 Answers1

3

You can delay setting the headers until you get to the first chapter, for example as follows:

Sample start

...next page...

Sample next page

\documentclass{report}

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[RO,LE]{\thepage\ of \pageref{LastPage}}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[RO,LE]{\thepage\ of \pageref{LastPage}}}

\usepackage{blindtext}

\begin{document}
\pagestyle{plain}


\tableofcontents

\clearpage
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\ #1}{}}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[LO,RE]{\leftmark}

\chapter{The beginning}

\blindtext

\section{With more}

\blindtext

\Blinddocument

\Blinddocument

\Blinddocument

\Blinddocument

\Blinddocument
\end{document}

The above redefines the plain page style used on chapter pages etc. to match the page numbering in the footer of the other pages. Otherwise, we set-up fancyhdr as usual, but do not define any header until the appropriate place in the main document. It is important this comes after a command such as \clearpage.

The above document use the blindtext to provide dummy material so I could get a table of contents longer than one page.

Andrew Swann
  • 95,762
  • This solves the problem. However, it will remove the header on each chapter page.

    Although a header on the chapter page was something I wanted earlier, I now find it redundant.

    – user25887 Feb 13 '13 at 17:27
  • 1
    The same idea could be used for that, redefine plain pagestyle just before the first chapter. – Andrew Swann Feb 13 '13 at 17:37