6

How can I put "Chapter" and "Page" below Table of Contents title like shown in picture? And I also have to carry these into next pages in my thesis if toc is more than one page.Thanks,

And it would be great if they are not hyperlinked

6

My initial answer was written using etoc.

The main idea though, was taken over from karlkoeller answer: using afterpage. The difference is that the method now is compatible with a TOC on many pages.

I figured next that it could be done in a simpler manner. Thus, I provide here two codes: one not using etoc at all. But the formatting of the toc will have to be done by some package, like tocloft. The second uses etoc to facilitate both the OP's constraint on the chapter headline and some formatting customisation. This second code sample has a somewhat more complicated document body. And on this occasion one sees something is not perfect for the last (fourth) toc page. I have not yet investigated which aspect of afterpage is causing this.

% without etoc
\documentclass{book}
\usepackage[textheight=10cm]{geometry}% small page height for testing!
\usepackage{hyperref}
\usepackage{afterpage}

\newif\ifintoc

\newcommand*{\PrintChapterTocHeadline}
  {\hbox to \linewidth{\textbf{Chapter}\hfill\textbf{Page}}\bigskip
   \SetupNextPage}

\newcommand*{\SetupNextPage}
  {\afterpage {\ifintoc\PrintChapterTocHeadline\fi}}

\addtocontents{toc}{\protect\PrintChapterTocHeadline}

\begin{document}

\begingroup\intoctrue
\tableofcontents
\endgroup

\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}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}

\end{document} 

toc page 1

toc page 2

toc page 3

toc page 4


As this is done with Roman Numerals for chapters, some rather big spaces are used on the left.

% solution using etoc

\documentclass{book}
\usepackage[textheight=10cm]{geometry}
\usepackage{hyperref}
\usepackage{etoc}
\usepackage{afterpage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% doing the thing for the chapter  headline one each page.
%%%% here, using etoc.
\newif\ifintoc

\newcommand*{\PrintChapterTocHeadline}
  {\hbox to \linewidth{\textbf{Chapter}\hfill\textbf{Page}}\bigskip
   \afterpage {\ifintoc\PrintChapterTocHeadline\fi}}

% after title hook will take care of the first chapter headline
% nothing is written to the .toc file, hence other TOCs in the
% document can be done, not using that extra thing. Naturally
% the hook will have to be redefined
\renewcommand{\etocaftertitlehook}
             {\parindent 0pt 
              \leftskip  0cm 
              \rightskip \tocright
              \parfillskip -\rightskip
              \PrintChapterTocHeadline
              \intoctrue }
% etoc always typesets TOCs in a group. Thus the \ifintoc boolean
% will be false after the TOC completes.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Now using etoc also to customize the formatting itself.
%%%% I take this opportunity to write down some rather general
%%%% etoc line style definitions, for a look somewhat like the
%%%% standard looks, but customisable.

%%%% some dimensions are hard-coded, but for some I already define
%%%% associated lengths

\newlength{\tocright}
\setlength{\tocright}{0.75cm}

\newlength{\toclefti}
\setlength{\toclefti}{1.25cm}
\newlength{\tocleftii}
\setlength{\tocleftii}{2.75cm}
\newlength{\tocleftiii}
\setlength{\tocleftiii}{4.25cm}

% Code for page numbers on the right side.

\renewcommand*\etoctoclineleaders
 {\hbox{\normalfont\normalsize\hbox to .6ex {\hss.\hss}}}

\newcommand*{\EndParWithPagenoInMarginAndLeaders}
 {\nobreak\leaders\etoctoclineleaders\hfill
 \nobreak\makebox[\tocright][r]{\mdseries\normalsize\etocpage}%
 \par }

% version with no dot leaders:
\newcommand*{\EndParWithPagenoInMargin}
 {\nobreak\hfill
 \nobreak\makebox[\tocright][r]{\mdseries\normalsize\etocpage}%
 \par}

\etocsetstyle{chapter}
{}
{\leavevmode\leftskip \toclefti }
{\llap{\makebox[\toclefti][l]{\bfseries\etocnumber.}}%
 \etoclink{\bfseries\MakeUppercase{\etocthename}}% roman uppercase
 \EndParWithPagenoInMargin}
{}

\etocsetstyle {section}
{}
{\leavevmode\leftskip \tocleftii }
{\llap{\makebox[\dimexpr\tocleftii-\toclefti\relax][l]{\etocnumber.}}%
 \textsc{\etocname}% small caps
 \EndParWithPagenoInMarginAndLeaders}
{\medskip}

\etocsetstyle {subsection}
{}
{\leavevmode\leftskip \tocleftiii }
{\llap{\makebox[\dimexpr\tocleftiii-\tocleftii\relax][l]{\etocnumber.}}%
 \etocname
 \EndParWithPagenoInMarginAndLeaders}
{\smallskip}

%\renewcommand*{\etoctoprule}{\hrule height 0pt\relax}
%\etocruledstyle [1]{\MakeUppercase{\contentsname}}
\etocsettocstyle
  {\hbox to \linewidth{\hss \MakeUppercase{\contentsname}\hss}\bigskip}
  {}


\renewcommand{\thechapter}{\Roman{chapter}}

\begin{document}

\tableofcontents

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

\end{document} 

toc page 1

toc page 2

toc page 3

toc page 4

13
  • Thanks. I follow your code and put the subsection and it is working great. Could you also share how to make uppercase for section?
    – Aung
    Feb 10 '14 at 8:09
  • @Aung are you using the first code sample (above the images) or the second one (below the images)? do you want also the sections to appear in uppercase? and finally do you prefer uppercase (in the roman font) or small caps (\textsc)?
    – user4686
    Feb 10 '14 at 8:38
  • @karlkoeller forgot to credit your afterpage idea! Later today I will rewrite the answer to more clearly explain how to achieve this without using etoc. Also, even with using etoc (which I employed initially also because of the formatting requirements of @Aung), the initial code can be simplified to work as in the sample below the images. I can't do that now for lack of time.
    – user4686
    Feb 10 '14 at 9:12
  • @jfbu , I just found out the second one is amazing. It is really clean. The second one works without needing to add for subsection. That's really cool. I have an issue in Roman chapter Name. It is overlapped with the titles after chapter number six. If you don't mind , I would like to ask about chapter title in regular caps. I was able to get \MakeUppercase for "CHAPTER" but the chapter title still in standard form unless I use \uppercase{my title}. Thanks for the help.
    – Aung
    Feb 10 '14 at 10:18
  • 1
    @Aung thus \addtocontents{toc}{\protect\PrintChapterTocHeadline} becomes \addtocontents{lof}{\protect\PrintLOFheadline} etc...
    – user4686
    Feb 17 '14 at 18:55
4

Hoping your ToC won't span more than two pages, this works.

Add the following lines just before your first chapter

\addtocontents{toc}{\protect\contentsline{chapter}{Chapter}{Page}{}}
\addtocontents{toc}{\protect\vspace*{15pt}}
\addtocontents{toc}{\protect\afterpage{\hspace*{-1.3em}\bfseries Chapter\hfill Page}}
\addtocontents{toc}{\protect\afterpage{\vspace*{25pt}}}

The first two lines add the required stuff in the first page of the ToC, while the latter two (with the help of the command \afterpage from the same package) add it in the second page of the ToC.

MWE:

\documentclass{book}
\usepackage{hyperref}
\usepackage{afterpage}

\begin{document}

\tableofcontents

\addtocontents{toc}{\protect\contentsline{chapter}{Chapter}{Page}{}}
\addtocontents{toc}{\protect\vspace*{15pt}}
\addtocontents{toc}{\protect\afterpage{\hspace*{-1.3em}\bfseries Chapter\hfill Page}}
\addtocontents{toc}{\protect\afterpage{\vspace*{25pt}}}

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

\end{document} 

Output:

enter image description here

2
  • Thanks. That would help. I think people behind the thesis guidelines don't use latex. :)
    – Aung
    Feb 8 '14 at 23:20
  • @Aung I've edited the answer. Probably now it's what you were looking for. Feb 9 '14 at 15:59

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.