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.

I am writing my doctoral thesis using LaTeX and now I face the following problems.

On every page of the ToC, the headings must be printed. For example, on the first page and consecutive pages of the ToC, I want the following to be printed:

**Chapter no                Contents                     Page no**

The same applies to List of Figures and List of Tables.

How can I achieve that?

share|improve this question
    
Follow-up question: Table of Contents modifications required –  Werner Sep 22 '12 at 17:33
add comment

2 Answers 2

up vote 4 down vote accepted

The following minimal example creates a report with a \tableofcontents to your specifications using tocloft:

enter image description here

\documentclass{report}
\usepackage[paperheight=30\baselineskip]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tocloft}% http://ctan.org/pkg/tocloft
\usepackage{atbegshi}% http://ctan.org/pkg/atbegshi
\makeatletter
\newcommand{\tocheader}{{%
  \bfseries% Font selection
  \hspace*{\cftchapindent}% Chapter indent
  \makebox[\cftchapnumwidth][l]{Chapter no}% Chapter number heading
  \hfill%
  \contentsname% Title heading
  \hfill%
  \makebox[\@pnumwidth][r]{Page}% Page heading
  \par\kern.5\baselineskip% After heading
  }}
\AtBeginDocument{\renewcommand{\tableofcontents}{%
  \begingroup%
  \parindent\z@\parskip\cftparskip%
  \tocheader%
  \@starttoc{toc}%
  \endgroup%
}}
\renewcommand{\cftaftertoctitle}{\par\kern.5\baselineskip\tocheader}
\newcommand{\AtBeginShipoutClear}{\gdef\AtBegShi@Hook{}}
\makeatother

\begin{document}
\AtBeginShipout{\tocheader}
\tableofcontents
\AtBeginShipoutClear

\chapter{abcd}\section{First}\section{Second}\section{Last}
\chapter{bcde}\section{First}\section{Second}\section{Last}
\chapter{cdef}\section{First}\section{Second}\section{Last}
\chapter{defg}\section{First}\section{Second}\section{Last}
\chapter{efgh}\section{First}\section{Second}\section{Last}
\chapter{fghi}\section{First}\section{Second}\section{Last}
\chapter{ghji}\section{First}\section{Second}\section{Last}
\chapter{hjik}\section{First}\section{Second}\section{Last}
\chapter{jikl}\section{First}\section{Second}\section{Last}
\chapter{iklm}\section{First}\section{Second}\section{Last}
\chapter{klmn}\section{First}\section{Second}\section{Last}
\chapter{lmno}\section{First}\section{Second}\section{Last}
\chapter{mnop}\section{First}\section{Second}\section{Last}
\chapter{nopq}\section{First}\section{Second}\section{Last}
\chapter{opqr}\section{First}\section{Second}\section{Last}
\chapter{pqrs}\section{First}\section{Second}\section{Last}
\chapter{qrst}\section{First}\section{Second}\section{Last}
\chapter{rstu}\section{First}\section{Second}\section{Last}
\chapter{stuv}\section{First}\section{Second}\section{Last}
\chapter{tuvw}\section{First}\section{Second}\section{Last}
\chapter{uvwx}\section{First}\section{Second}\section{Last}
\chapter{vwxy}\section{First}\section{Second}\section{Last}
\chapter{wxyz}\section{First}\section{Second}\section{Last}
\end{document}

\AtBeginShipout{\tocheader} adds \tocheader (the Chapter no...Contents...Page construction) to every page, while \AtBeginShipoutClear removes it from subsequent pages. \tocheader constructs its contents based on the spacing offered by tocloft: An indent of \cftchapindent, followed by the chapter number (of width \cftchapnumwidth), centred heading and page number of width \@pnumwidth. It also possible to do this in a slightly more manual way using afterpage (see Add 'Page' above page numbers in Table of Contents).

The same can be done for \listoffigures and \listoftables, although it would be bizarre to add Chapter no to a contents that doesn't list any chapters.

share|improve this answer
add comment

Here's a possibility using the fancyhdr package to define a page style for the ToC (a similar style can be defined for the LoF and the LoT):

\documentclass{book}
\usepackage[paperwidth=15cm,paperheight=14cm]{geometry}% just for the example
\usepackage{fancyhdr}

% style for the ToC
\fancypagestyle{liststyle}
{
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[L]{\bfseries Chapter No}
\fancyhead[C]{\bfseries\contentsname}
\fancyhead[R]{\bfseries Page No}
}

% style for regular pages
\fancypagestyle{regularstyle}
{
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[L]{}
\fancyhead[C]{}
\fancyhead[R]{\thepage}
}

\makeatletter
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \pagestyle{liststyle}
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }
\makeatother

\begin{document}

\tableofcontents
\clearpage
\pagestyle{regularstyle}

\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}
\chapter{Test}\section{Test}\section{Test}

\end{document}

enter image description here

The dimensions chosen for paperwidth and paperheight through the geometry package are just for convenience in the example and have no relevance in the solution.

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