Siempre que uso el siguiente código
\appendix
\addcontentsline{toc}{chapter}{9 \enspace Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
Para evitar enumerar apéndices individuales en el índice, la lista de figuras (lof) desaparece. He comprobado que eliminando el comando anterior del apéndice aparece lof.
Respuesta1
Tienes que restaurar el tocdepth
contador después del apéndice con \addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
:
\documentclass{report}
\begin{document}
\tableofcontents
\listoffigures
\begin{figure}
\caption{figure}
\end{figure}
\appendix
\addcontentsline{toc}{chapter}{9 \enspace Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{Appendix chapter that is not listed in the TOC}
...
%<end of appendix>
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\end{document}
Suponiendo que el apéndice es el final de su documento (lo que podríanosea el caso, así que tenga cuidado aquí) podría parchear el final del documento como
\let\oldenddocument\enddocument
\def\enddocument{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\oldenddocument}
Entonces el archivo
\documentclass{report}
\makeatletter
\g@addto@macro\appendix{%
\addcontentsline{toc}{chapter}{9 \enspace Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}}
\let\ltx@enddocument\enddocument
\def\enddocument{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\ltx@enddocument}
\makeatother
\begin{document}
\tableofcontents
\listoffigures
\begin{figure}
\caption{figure}
\end{figure}
\appendix
\chapter{Appendix chapter that is not listed in the TOC}
\end{document}
producirá el mismo resultado que el anterior. Tenga en cuenta que también se están aplicando parches \appendix
para mantener limpio el cuerpo del documento:
\g@addto@macro\appendix{%
\addcontentsline{toc}{chapter}{9 \enspace Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}}
Esto debería hacerse de todos modos. Finalmente, si el apéndice no es la parte final del documento, se podría considerar envolver el apéndice en un entorno para tener un marcador final, por lo tanto, un lugar apropiado para enganchar (por ejemplo, con la instrucción \def\endappendix{\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}}
) y luego decir
\documentclass{book}
\makeatletter
\g@addto@macro\appendix{%
\addcontentsline{toc}{chapter}{9 \enspace Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}}
\def\endappendix{\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}}
\makeatother
\begin{document}
\tableofcontents
\listoffigures
\begin{figure}
\caption{figure}
\end{figure}
\begin{appendix}
\chapter{Appendix chapter that is not listed in the TOC}
...
\end{appendix}
\backmatter
\chapter{After the appendix}
\end{document}
¡Cabe señalar que este es un cambio de la interfaz estándar!