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}
  • 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. – Reinstate Monica - M. 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". – Reinstate Monica - M. 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}. – Reinstate Monica - M. Schröder Feb 13 '13 at 14:53
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.

| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.
https://tex.stackexchange.com/questions/98041/how-to-prevent-contents-from-appearing-as-a-header-in-toc?noredirect=1
tex.stackexchange.com
crawl=CC-MAIN-2020-24
153909
application/http; msgtype=response
sha1:JWQG5ULQRLH5SCXE4KIF5HZKHRZE3INX
<urn:uuid:db29feac-49aa-4ab7-a781-978b9df37591>
2020-06-07T10:23:41Z
151.101.65.69
text/html
sha1:32VSQZQFTSTIRYKXUD73JM5DO6SR3WIU
<urn:uuid:25867bbf-9279-4c73-8cad-8302e7eb860a>
https://tex.stackexchange.com/questions/98041/how-to-prevent-contents-from-appearing-as-a-header-in-toc?noredirect=1
response
<urn:uuid:d79368bf-e6d3-4ed9-ab85-ef136de5ba7a>
isPartOf: CC-MAIN-2020-24
publisher: Common Crawl
description: Wide crawl of the web for May/June 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-84.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/