표시되지 않는 그림 목록

표시되지 않는 그림 목록

다음 코드를 사용할 때마다

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

목차에 개별 부록을 나열하는 것을 피하기 위해 그림 목록(lof)이 사라집니다. lof가 나타나는 부록에서 위 명령을 제거했는지 확인했습니다.

답변1

tocdepth다음을 사용하여 부록 이후에 카운터를 복원해야 합니다 \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}

부록이 문서의 맨 끝이라고 가정하면(아마도~ 아니다그렇다면 여기서 조심하세요) 다음과 같이 문서의 끝 부분을 패치할 수 있습니다.

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

그런 다음 파일

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

위와 같은 결과가 나옵니다. \appendix문서 본문을 깨끗하게 유지하기 위해 패치도 진행 중입니다 .

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

어쨌든 이 작업은 수행되어야 합니다. 마지막으로 부록이 문서의 결론 부분이 아닌 경우 끝 표시를 갖기 위해 부록을 환경으로 감싸는 것을 고려할 수 있습니다. 따라서 연결할 적절한 위치(예: 명령을 사용하여 \def\endappendix{\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}})를 지정한 다음 다음과 같이 말합니다.

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

이는 표준 인터페이스의 변경 사항이라는 점에 유의하세요!

관련 정보