If you want to change the \chapter
heading of all the chapters use the titlesec
package. I would not recommend that you change the contents heading on its own. If you realy wants it, you can add
\renewcommand*\cfttoctitlefont{\Huge\bfseries\hfill\MakeUppercase}
\renewcommand*\cftaftertoctitle{\hfill}
The following will give more or less wat you want, execpt for the linebreak after Chapter 1. That will cause chaos if you include sections.
\documentclass{book}
\usepackage{tocloft}
\newlength\mylenprt
\newlength\mylenchp
\newlength\mylenapp
\renewcommand*\cftpartpresnum{\partname~}
\renewcommand*\cftchappresnum{\chaptername~}
\renewcommand*\cftchapaftersnum{.}
\renewcommand*\cftchapdotsep{\cftdotsep}
\settowidth\mylenprt{\cftpartfont\cftpartpresnum\cftpartaftersnum}
\settowidth\mylenchp{\cftchapfont\cftchappresnum\cftchapaftersnum}
\settowidth\mylenapp{\cftchapfont\appendixname~\cftchapaftersnum}
\addtolength\mylenprt{\cftpartnumwidth}
\addtolength\mylenchp{\cftchapnumwidth}
\addtolength\mylenapp{\cftchapnumwidth}
\setlength\cftpartnumwidth{\mylenprt}
\setlength\cftchapnumwidth{\mylenchp}
\begin{document}
\frontmatter
\tableofcontents
\chapter{ILLUSTRATIONS}
\makeatletter\@starttoc{lof}\makeatother
\chapter{TABLES}
\makeatletter\@starttoc{lot}\makeatother
\chapter{ACKNOWLEDGEMENT}
\chapter{ABSTRACT}
\mainmatter
\chapter{INTRODUCTION}
\begin{figure}
\caption{Fig test}
\end{figure}
\begin{table}
\caption{Tab Test}
\end{table}
\appendix
\addtocontents{toc}{% NB!!! must be inside the first \include
\protect\renewcommand\protect\cftchappresnum{\appendixname~}%
\protect\setlength{\cftchapnumwidth}{\mylenapp}}%
\backmatter
\end{document}
The problem is in the way that you redefine \@chapter
, which is incompatible with hyperref
. You can see this immediately if you comment out the line loading hyperref
, just before \begin{document}
.
The hyperref
package plays a lot with everything containing references; lines in the table of contents are just one such thing. It achieves this by redefining commands such as \addcontentsline
, effectively adding hyperlinks to all references. After hyperref
is loaded, the command \contentsline
(which normally takes 3 arguments) requires also a fourth argument: the anchor where the line links to. In your case, your definition of \@chapter
uses \contentsline
directly and only provides three arguments. The fourth one will never be introduced by hyperref
, thus latex complains that it's missing when reading the toc
file.
An immediate solution that works is to replace the following line (occurring three times) in your definition of \@chapter
:
\addtocontents{toc}{\string\contentsline {chapter}%
{\hbox to .65in{Chapter}\protect\numberline{\thechapter}#1}{\thepage}}%
with an equivalent one that does not explicitly use \contentsline
:
\addcontentsline{toc}{chapter}%
{\hbox to .68in{Chapter}\protect\numberline{\thechapter}#1}
(I changed the width here to avoid an overfull \hbox
.) This will give hyperref
the chance to properly introduce the fourth argument to \contentsline
. Now, hyperref
(in fact the PDF driver) will warn you that you shouldn't be using \hbox
in content lines, but you can live with it.
Of course, to see the table of contents, you need to invoke pdflatex
multiple times. I recommend the latexmk
utility: by running latexmk -pdf yourfile.tex
your PDF will be made automatically.
I understand that the only change you want, over what book.cls
normally does, is to introduce the word "Chapter" before chapter titles in the table of contents. If this is so, a probably better solution would be to leave the definitions of \chapter
and \@chapter
untouched and to redefine \l@chapter
(which is used by \contentsline
) to suit your needs.
An even better solution, as you already use the titlesec
package, is to also use titletoc
in order to introduce the word "Chapter" in the table of contents.
Best Answer
If you don't want to look for the right lengths to give as parameters to
tocloft
ortitletoc
commands, you can also patch the\l@section
command to use the same leaders as the other commands instead of blank space: