Appendix Chapters typeset as Sections in ToC

I am very new to LaTeX and still more in a trial and error phase than on a real understanding level.

My goal is to have all appendices - which are chapters and I would like to keep it that way - to appear in the TOC as sections, under a 'chapter' appendices.

Here is what I tried, using the tocloft package

\newpage\phantomsection
\addcontentsline{toc}{chapter}{Appendices}
\appendix

\setlength{\cftchapindent}{\cftsecindent}
\renewcommand{\cftchapfont}{\cftsecfont}
\renewcommand{\cftchapleader}{\cftsecleader}

\chapter{chapter title}


So my idea was to just tell LaTeX to write chapters to the TOC as though they were sections. My code has no effect whatsoever. Any ideas/solutions are very much appreciated

-

1 Answer

You had the right idea, but you need to add your changes to the TOC itself rather than in the main document (and because of this you need to \protect some of the commands.) Note that this solution won't look very nice if your appendices have sections.

\documentclass{report}
\usepackage{tocloft}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A section}
\newpage\phantomsection
\addcontentsline{toc}{chapter}{Appendices}
\appendix
\addtocontents{toc}{
\setlength{\cftbeforechapskip}{\cftbeforesecskip}
\setlength{\cftchapindent}{\cftsecindent}
\protect\renewcommand{\cftchapfont}{\cftsecfont}
\protect\renewcommand{\protect\cftchapdotsep}{\cftsecdotsep}
}
\chapter{An Appendix}
\end{document}


-
Thanks a lot. That did the trick. I don't fully grasp yet what is happening at some points in the code, and where what is set. \setlength{\cftbeforechapskip}{\cftbeforesecskip} might be useful in this context, too. I forgot to put it in my question... – D.Roepo Aug 8 '11 at 15:58
I added that to the example. If your appendices don't themselves have sections it definitely leads to a pleasing layout for the TOC compared to the alternative. – Alan Munn Aug 8 '11 at 16:30
What is the best way to have chapters also appear as sections in the bookmarks? I am using the bookmark package and experimented with \bookmarksetup{level=section} or \pdfbookmark[2]{... but the appendices would remain at the same bookmarklevel as Appendices – D.Roepo Jul 13 '13 at 16:00
@D.Roepo Sorry, but I don't have an answer to your question. It looks like a good candidate for a new question. – Alan Munn Jul 13 '13 at 17:36