I just implemented Mike Renfro's solution from here, but the content in the list of appendices also gets listed in the toc, which should not be the case. How would one ensure this is avoided? Below is the code I've used. The report
class has been used because I want to have chapters in the document.
\documentclass[12pt]{report}
\usepackage{lipsum}\usepackage{tocloft}
\newcommand{\listappendixname}{List of Appendices}
\newlistof{appendix}{app}{\listappendixname}
\setcounter{appdepth}{2}
\renewcommand{\theappendix}{\Alph{appendix}}
\renewcommand{\cftappendixpresnum}{Appendix\space}
\setlength{\cftbeforeappendixskip}{\baselineskip}
\setlength{\cftappendixnumwidth}{1in}
\newlistentry[appendix]{subappendix}{app}{1}
\renewcommand{\thesubappendix}{\theappendix.\arabic{subappendix}}
\renewcommand{\cftsubappendixpresnum}{Appendix\space}
\setlength{\cftsubappendixnumwidth}{1in}
\setlength{\cftsubappendixindent}{0em}
\renewcommand{\appendix}[1]{%
\refstepcounter{appendix}%
\chapter{\theappendix\space #1}%
\addcontentsline{app}{appendix}{\protect\numberline{\theappendix}#1}%
\par
}
\newcommand{\subappendix}[1]{%
\refstepcounter{subappendix}%
\section{\thesubappendix\space #1}%sub
\addcontentsline{app}{subappendix}{\protect\numberline{\thesubappendix}#1}%
}
\usepackage{fmtcount,etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\Numberstring{chapter}}{}{}
\patchcmd{\chaptermark}{\thechapter}{\NUMBERstring{chapter}}{}{}
\makeatother
\newcommand{\thetocchap}{\NUMBERstring{chapter}}
\begin{document}
\tableofcontents
\listofappendix
\chapter{Foo} \lipsum[1]
\section{Bar} \lipsum[2]%sub
\chapter{Additional Foo} \lipsum[3]
\section{Additional Bar} \lipsum[4]%sub
\begin{appendices}
\appendix{Baz} \lipsum[5]
\subappendix{Qux} \lipsum[6]
\appendix{Additional Baz} \lipsum[7]
\subappendix{Additional Qux} \lipsum[8]
\end{appendices}
\end{document}
Best Answer
Add
\addtocontents{toc}{\protect\setcounter{tocdepth}{-2}}
in the document body immediately before\begin{appendices}
. (And don't forget to load theappendix
package.)