Liste der NICHT angezeigten Abbildungen

Liste der NICHT angezeigten Abbildungen

Immer wenn ich den folgenden Code verwende

 \appendix
 \addcontentsline{toc}{chapter}{9 \enspace Appendices}
 \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}

um die Auflistung einzelner Anhänge im Inhaltsverzeichnis zu vermeiden, verschwindet das Abbildungsverzeichnis (lof). Ich habe geprüft, ob beim Entfernen des obigen Befehls aus dem Anhang das lof erscheint.

Antwort1

Den Zähler müssen Sie tocdepthnach dem Anhang wiederherstellen mit \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}

Angenommen, der Anhang ist das Ende Ihres Dokuments (wasnichtder Fall sein, also seien Sie hier vorsichtig) Sie könnten das Ende des Dokuments patchen wie

\let\oldenddocument\enddocument
\def\enddocument{%
  \addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
  \oldenddocument}

Dann die Datei

\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}

wird das gleiche Ergebnis wie oben liefern. Beachten Sie, dass auch Patches durchgeführt werden, \appendixum den Dokumenttext sauber zu halten:

\g@addto@macro\appendix{%
  \addcontentsline{toc}{chapter}{9 \enspace Appendices}
  \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}}

Dies sollte auf jeden Fall getan werden. Wenn der Anhang nicht der abschließende Teil des Dokuments ist, könnte man erwägen, den Anhang in eine Umgebung einzubinden, um einen Endmarker zu haben, also eine geeignete Stelle, an der man einhaken kann (z. B. mit der Anweisung \def\endappendix{\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}}), und dann zu sagen:

\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}

Zu beachten ist, dass es sich hierbei um eine Änderung der Standardschnittstelle handelt!

verwandte Informationen