Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Welcome to TeX.sx! This question is very similar to Table of contents with page style empty. Please take a look at it as the information there might help you. If so, that's great, and we'll probably close this question as a duplicate just to keep the place tidy and to help people find answers quickly. If not, please edit your question here to explain why so that people can better focus their attention to help you. –  Martin Schröder Feb 13 '13 at 14:06
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. A suggestion: Change your username to something more telling than "user25887". –  Martin Schröder Feb 13 '13 at 14:09
    
I have defined the pagestyle plain and use it in the preface. I tried using \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{plain}}} without luck. This is how TOC is included: \newpage \pagestyle{plain} \tableofcontents \clearpage{\pagestyle{plain}\cleardoublepage} \pagenumbering{arabic} \pagestyle{plain} –  user25887 Feb 13 '13 at 14:21
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Martin Schröder Feb 13 '13 at 14:53
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.