[Tex/LaTex] List of appendices with tocloft and memoir

appendicesmemoirtable of contentstocloft

I found a very nice example showing how to create a list of appendices here: How to get a list of appendices? but it doesn't seem to work with the memoir document class. I get the error message "Command \appendices already defined."

How can I create the same list of appendices with the memoir class?

Best Answer

Here is one solution using the memoir toc code inserts:

\documentclass[a4paper]{memoir}
% sample data
\newcounter{dlf}
\newcommand\test{%
  \stepcounter{dlf}
  \chapter{Test chapter \thedlf}
  \section{test section \thedlf}}
\cftinsertcode{preapp}{\setcounter{tocdepth}{-10}}
\newcommand\apptoc{
  \begingroup
  \cftinsertcode{prenorm}{\setcounter{tocdepth}{-10}}
  \cftinsertcode{preapp}{\setcounter{tocdepth}{3}}
  \renewcommand\contentsname{List of appendencies}
  \tableofcontents*
 \endgroup
}
\begin{document}
\cftinserthook{toc}{prenorm}

\tableofcontents*

\test\test\test

\appendix
\appendixpage
\cftinserthook{toc}{preapp}

\apptoc

\test\test\test

\end{document}