In a book I am working on, I'd like the TOC entries for chapters to read

Chapter 1: foobar        3

while for Appendices

Appendix 1:  bletch    197

Using tocloft, the lines

\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{: }

(together with a line to control width) in my preface does the trick for the chapter name formatting, but unfortunately those lines seem to need to be in the preface, so I can't later redefine cftchappresnum when starting to process appendices. I've also tried making the definition of cftchappresnum dependent on that boolean:

\renewcommand{\cftchappresnum}{\ifthenelse{\boolean{inappendix}}{Appendix }{Chapter }}

and then issuing \setboolean{inappendix}{true} just after \appendix, but this fails as well (it acts as though inappendix is always false).


The change of \cftchappresnum must be written to the ToC directly to make it effective for the appendix when the .toc file is called, i.e.


will write the change (use \protect to prevent errors during the writing process)


\renewcommand{\cftchapaftersnum}{: }







\chapter{Foo appendix}


I leave the real length specification of \cftchapnumwidth to the O.P.

enter image description here

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.