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'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.

share|improve this question
Related: tex.stackexchange.com/questions/56839/… –  lockstep Jun 10 '12 at 20:45
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. –  tohecz Jun 10 '12 at 20:45

3 Answers 3

up vote 5 down vote accepted

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. :)

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

share|improve this answer

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

Your Answer


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.