GeneralControlling header on tableofcontents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
bombcar
Posts: 22
Joined: Tue Oct 28, 2008 10:18 pm

Controlling header on tableofcontents

Post by bombcar »

If my table of contents is less than three pages, it works the way I want it to. However, if it goes beyond three pages I get "CONTENTS" in my header instead of "Contents".

Here is the code that shows this (the repeating is necessary to get it to 3 pages of contents):

Code: Select all

\documentclass[12pt,letterpaper,oneside]{book}
\usepackage{makeidx}
\usepackage{multirow}
\usepackage{multicol}
\usepackage[pdftex]{xcolor,graphicx}
\usepackage{ulem}
\usepackage{calc}
\usepackage{fancyhdr}
\usepackage{wrapfig}
\usepackage{hyperref}

\pagestyle{fancy}
\fancyhead[LE,LO]{Confidential}
\fancyfoot{}
\fancyfoot[LE,LO]{\today}
\fancyfoot[CE,CO]{Revision 0.0}
\fancyfoot[RE,RO]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\frontmatter
\title{\Huge\textsf{Title}}
\date{\today}
\maketitle
\tableofcontents{\markboth{Contents}{}\thispagestyle{fancy}}
\pagebreak{}
\markboth{Revision History}{}
\section*{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addtocounter{section}{1}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\addcontentsline{toc}{section}{Revision History}
\end{document}
If I remove a bunch of the addcontentsline it will show the headers how I want them; basically, what appears on the third page of the TOC is what I want on the second and following (or even on all pages of the TOC), but for some reason CONTENTS appears on the second page. What am I missing? I've tried setting markboth and moving it around, and changing \fancyhead but it still gives me a capital CONTENTS.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Controlling header on tableofcontents

Post by Stefan Kottwitz »

Hi,

a quick workaround is to temporarily disable \MakeUppercase:

Code: Select all

\let\stdtoc\tableofcontents
\renewcommand*\tableofcontents{{%
\renewcommand*\MakeUppercase[1]{##1}\stdtoc}}
If you don't like this hack let me know.

Stefan
LaTeX.org admin
bombcar
Posts: 22
Joined: Tue Oct 28, 2008 10:18 pm

Re: Controlling header on tableofcontents

Post by bombcar »

Thanks, that works well enough for me.
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Controlling header on tableofcontents

Post by php1ic »

I've been searching how to do that for ages, thanks Stefan_K.

Do you know how to do the same for the bibliography? I've tried simply swapping stdtoc for stdbib or just bib, but then I get this error message

Code: Select all

! Argument of \bib has an extra }.
<inserted text> 
                \par 
l.134 \bibliography
                   {thesis}
? 
and the word thesis is written below the bibliography, or if I start from scratch with just the tex and bib files then no bibliography is written.

Looks like it doesn't like that I have given \bibliography an "argument"

Any ideas?
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Controlling header on tableofcontents

Post by daleif »

I would recommend using a better class than book.

In memoir you can loose the uppercase stuff by just using

\nouppercaseheads
\pagestyle{headings}

and that applies to the TOC, bibliography and index
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Controlling header on tableofcontents

Post by php1ic »

Sorry, should have searched the forums a little more thoroughly. Reading this thread

http://www.latex-community.org/forum/vi ... =47&t=3735

gave me the idea to look in the report.cls file, and line 670 looked like this

Code: Select all

\@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
copying it to the main directory of my document and changing it to

Code: Select all

\@mkboth{\MakeUppercase\bibname}{\bibname}%
did exactly what I wanted, BIBLIOGRAPHY is now Bibliography in the header.

I was going to try and do the same with the table of contents entry but could find it. I'm totally new to playing with the 'workings' of latex, so if I have done something bad can someone please say so.

EDIT: Once I put my glasses on I found line 600 which is almost identical to 670 but relating to the table of contents.
Last edited by php1ic on Wed Jan 28, 2009 9:29 pm, edited 1 time in total.
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: Controlling header on tableofcontents

Post by php1ic »

Hi daleif,

I was writing the above post when you posted your suggestion. I'll give memoir a try.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Controlling header on tableofcontents

Post by gmedina »

daleif wrote:I would recommend using a better class than book.

In memoir you can loose the uppercase stuff by just using

\nouppercaseheads
\pagestyle{headings}

and that applies to the TOC, bibliography and index
Well, if you are going to suggest a different document class for such a minor change, the classes offered by the KOMA-Script bundle can be a sensible option too.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply