[Tex/LaTex] Separate table of contents for appendices

appendicesmemoirtable of contents

Is it possible to make two seperate table of contents in one report? I want one for the main document and another for the appendices.

I'm writing in the memoir report enviroment.

Best Answer

This ought to do it. I included the Appendices entry in the first toc as I would think this would be better for users.

The idea is to add hooks into the TOC file at certain places, such that we can execute code that these places. We then fill in these hooks with code that alter how far down in the toc structure we would like to typeset.

\documentclass[a4paper]{memoir}
% just to provide sample code
\usepackage{kantlipsum}
\newcounter{tst}
\newcommand\xxx{\stepcounter{tst}\chapter{Test \thetst} \kant[1]}

% disable everything after the POST hook
\cftinsertcode{POST}{
\setcounter{tocdepth}{-1}
}

\newcommand\tableofcontentsapps{
\begingroup
% disable first part
\cftinsertcode{PRE}{
\setcounter{tocdepth}{-10}
}
% enable down to subsection within appendices
\cftinsertcode{POST}{
\setcounter{tocdepth}{2}
}
\renewcommand\contentsname{List of appendices}
\tableofcontents*
\endgroup
}


\begin{document}

\tableofcontents*

\cftinserthook{toc}{PRE}

\xxx\xxx\xxx

\appendix
\appendixpage

\tableofcontentsapps

\cftinserthook{toc}{POST}

\xxx\xxx\xxx


\end{document}