# Format ToC for thesis

I apologize for the unspecified and broad question but I have no way to be specific. I'm looking to generate the TOC and List of Figure, List of Table according to the format required by my school.

I have been trying with titlesec but I can't get some details working. Specifically the followings:

• no bold-face;

• The line 'CHAPTER Page' has to appear on every page of the ToC. Same with the line 'Figure Page' for the LoF and 'TABLE Page' for the LoT;

• Single spacing between chapter and its section but double spacing between chapters

• If the title is more than one line long, it should follow the format in Figure 2.1, i.e there are spaces before 1884

-
Which document class are you using? –  Gonzalo Medina Jun 16 '12 at 16:54
As your four issues cover four separate problems, please remove three of them from this question and post them as new questions. This way, other users looking for help can find solutions more easily. (The fact that they're all for the same project you're working on doesn't really matter here.) Also don't forget to provide a minimal working example (MWE) for each question. Before posting, make sure the questions haven't been asked on here already via searching. –  doncherry Jun 16 '12 at 16:57
@GonzaloMedina I'm using \documentclass[a4paper, 12pt]{report} –  knguyen Jun 16 '12 at 17:14
Can you switch to the book document class? –  Gonzalo Medina Jun 16 '12 at 17:27
How should a regular chapter heading look like? –  Gonzalo Medina Jun 16 '12 at 18:08

Here's a possible solution.

1. I used the titletoc and tocloft packages to customize the ToC, LoF and LoT titles and entries as required. Firther customization might be required for the titles, but this might depend on the general layout for the chapter titles and this information was not provided in the question.
2. The tocbibind packge was used to automatically include the LoF and the LoT in the table of contents.
3. The afterpage package can be used to produce the corresponding headings in every page of the ToC, the LoF and the LoT; since these lists typically span few pages, one can use

\addtocontents{toc}{\protect\afterpage{tocheading}}


respectively, in the appropriate locations in the body of the document.

4. I used the book document class (instead of using report) to profit from the \frontmatter, \mainmatter (and \backmatter) commands.

The code:

\documentclass{book}
\usepackage{titletoc}
\usepackage{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage{afterpage}

% Change the name of the ToC
\AtBeginDocument{%

% Headings for every page of ToC, LoF and Lot

% Centering titles for the ToC, Lof and Lot
\renewcommand{\cfttoctitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterloftitle}{\hfill}
\renewcommand{\cftlottitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterlottitle}{\hfill}

% Chapter entries formatting for frontmatter chapters
\newcommand\frontmatterchaptoc{%
\titlecontents{chapter}
{\contentslabel{1.5em}\MakeUppercase}
{\hspace*{-1.5em}\MakeUppercase}
{\titlerule*[1pc]{.}\contentspage}
}

% Chapter entries formatting for mainmatter chapters
\newcommand\mainmatterchaptoc{%
\titlecontents{chapter}
{\contentslabel{3em}\hspace*{-1em}\MakeUppercase}
{\MakeUppercase}
{\titlerule*[1pc]{.}\contentspage}
}

% Section, subsection, table and figure entries formatting
\titlecontents{section}
[7em]{}{\hspace{-1em}}{}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}
[7.5em]{}{\hspace{-1em}}{}{\titlerule*[1pc]{.}\contentspage}
\titlecontents{figure}
[5em]{}
{\contentslabel{3em}\hspace*{-1em}}{}
{\titlerule*[1pc]{.}\contentspage}
\titlecontents{table}
[5em]{}
{\contentslabel{3em}\hspace*{-1em}}{}
{\titlerule*[1pc]{.}\contentspage}

\begin{document}

\frontmatter
\frontmatterchaptoc % activation of chapter entries formatting in the frontmatter

\chapter{Acknowledgements}

\cleardoublepage
\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\cleardoublepage

\mainmatter

\mainmatterchaptoc% activation of chapter entries formatting in the mainmatter

\chapter{Introduction}
\section{Section One One}
\begin{figure}
\centering
A
\caption{Test figure one}
\label{fig:test}
\end{figure}
\section{Section Two One}
\begin{figure}
\centering
A
\caption{William Adolphe Bouguereau, \emph{Youth of Bacchus}  (initial sketch), 1884}
\label{fig:wab}
\end{figure}
\subsection{Section Two One One}

\end{document}


An image of the obtained ToC:

an Image of the obtained LoF:

-
WOW. This is awesome. Thank you so much for taking time with my problem. I'm getting this error when I compile. Package tocloft Note: The document has chapter divisions. ! LaTeX Error: Command \c@lofdepth already defined. Or name \end... illegal, see p.192 of the manual. I'm using these packages pastebin.com/2C4A2dQC (due to limit character) –  knguyen Jun 16 '12 at 22:32
@knguyen you're using the obslote subfigure package (in fact, you are loading it twice in the preamble); this package shouldn't be used anymore; you can use subfig or even better, subcaption instead. –  Gonzalo Medina Jun 17 '12 at 1:23

Hoping to save future thesis editors some Googling time.

-
Using \afterpage would isolate the heading fix to only the following page. What if the ToC spans 3 (or more) pages? –  Werner Mar 5 at 21:59
I had this exact problem. The "ugly" hack I ended up using was compiling it once, seeing which chapter heading was the last one on page 2 (or 3, etc), then throwing in another one of these commands after the \chapter call. It will correctly format the TOC as desired, but the behavior will change if the document gets significantly longer/shorter in places. It's not pretty, but it works. I would welcome a more elegant solution if anyone has one. –  user47384 Mar 7 at 0:53
A better way would be to use everyshi or atbegshi which is executed at every \shipout to insert content (perhaps using afterpage). Then, once the ToC is completed, to stop the insertion. For example, see Table of Contents with headings on every page. –  Werner Mar 7 at 2:45