I'm using this code to get word Chapter in TOC before each chapter.


\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}





This code also adds Chapter word before appendix. I wonder how to get word Appendix before the appendix in TOC.

  • Related: tex.stackexchange.com/questions/56839/… – lockstep Jun 10 '12 at 20:45
  • 1
    Notice that you use files Appendix.tex and Intro.tex and you do not post them. You should have made your code simpler if you just made examples of a \chapter before and inside the appendices environment, without the need of extra files. – yo' Jun 10 '12 at 20:45

You have to do the changes while reading the .toc file: this is an example of how to do it. The double \unexpanded is because the toc entry is first written in the .aux file and then in the .toc, so we have to protect it twice. One could add several \protect, but this is surely easier to write.


      \renewcommand{\cftchappresnum}{#1 }%
      \setlength\cftchapnumwidth{\widthof{\bfseries #1 }}%










The \setupname command might be integrated in \mainmatter and in \appendix, but this is left as an exercise. :)

  • It must be added that \setupname must be added to the included file if \include is used, otherwise it will only be inserted after the included file. It is therefor doubtfull if you can make a foolproof integration with \mainmatter and \appendix because a shipout is needed before the \addtocontents is written to the AUX file. – Danie Els Jun 12 '12 at 1:09
  • @DanieEls I never use \include, but you're right. ;-) – egreg Jun 12 '12 at 7:51

Add this line after \begin{appendices}:

\addtocontents{toc}{\def\protect\cftchappresnum{\appendixname{} }}

It adds a line to the TOC file that changes the title of the chapters (you ought to run twice). You might as well want to change the label width, so put Appendix instead of Chapter in the \AtBeginDocument... line.


The answers using tocloft works fine if you are not using the \include command. The problem is the delayed write mechanism used inside the \addtocontents to put stuff in the toc usualy ends up after the include contents. Solutions that works under all conditions are:

(1) It is the default behaviour of the amsbook class

(2) With memoir it can be obtain by putting the following in your preamble:

\renewcommand*{\cftchapteraftersnum}{.}% dot after the number

(3) With the standard book class you need a lot of changes. The following is from c.t.t. and was the basis of the code that ended up in memoir

%% Add a conditional to \appendix. Could also use \@chapp.

%% User defined number width in TOC (\tocchpnumwdth)
%% Add inserts for Chapter and Appendix. Define to
%% \relax if standard output is needed.

%% Small change in \@chapter. Write write different contents
%% line for Chapter and Appendix. Add inerts to \numberline.
    \ifnum \c@secnumdepth >\m@ne
             \addcontentsline{toc}{appendix}%<-- THIS IS NEW

%% Creates a \l@appendix identical to \l@chapter. Add the
%% width of the inserts to the width of the \numberline
%% box (\@tempdima).
\newcommand*\l@appendix{\l@@chapter{\tocappinsert}}%<-- NEW

   \ifnum \c@tocdepth >\m@ne
     \vskip 1.0em \@plus\p@
       \parindent \z@ \rightskip \@pnumwidth
       \parfillskip -\@pnumwidth
       \leavevmode \bfseries
       \settowidth{\@tempdima}{#1}%           <- change
       \addtolength\@tempdima{\tocchpnumwdth}%<- change
       \hskip -\leftskip
       #2\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #3}\par

%% Keep hyperref happy

\usepackage[breaklinks=true, % for long names
    \chapter{First Chapter}
    \section{First Section}
    \chapter{First Appendix}
    \section{First Appendix Section}
    \chapter{Data Tables}

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.