목차의 일부 수준에 부록을 표시하는 방법은 무엇입니까?

목차의 일부 수준에 부록을 표시하는 방법은 무엇입니까?

문서 클래스 에서 book파트 수준의 목차에 나타나는 부록을 갖고 싶습니다. TOC는 다음과 같아야 합니다.

Preface
Part title
  Chapter title
  Chapter title
Part title
  Chapter title
  Chapter title
Appendix: Some title
Bibliography
Index

나는 참고문헌과 색인을 포함하는 방법을 알고 있으며 PDF에서 올바른 위치를 가리키도록 하는 방법 \addcontentsline{toc}{part}{...}도 알고 있습니다 .\phantomsection

그런데 부록이 partTOC 수준으로 올라가도록 어떻게 설득할 수 있을까요? chapter마지막 부분 아래로 갑니다 .

나는 "손으로" 부록을 만들어도 상관하지 않는다. 즉, \appendix를 사용하지 않고 말이다. 그건 그렇고, 나는 \titlesec장과 부분 형식을 사용자 정의하는 데 사용하고 있습니다.

답변1

부록이 하나뿐이므로 "원샷 해킹"이면 충분합니다.

\documentclass{book}

\usepackage{etoolbox}
\makeatletter
\newcommand{\appchapter}[1]{%
  \begingroup
  \patchcmd{\@chapter}
   {\addcontentsline{toc}{chapter}}
   {\addcontentsline{toc}{part}}
   {}{}
  \patchcmd{\@chapter}
   {\addcontentsline{toc}{chapter}}
   {\addcontentsline{toc}{part}}
   {}{}
  \chapter{#1}
  \endgroup
}
\makeatother

\begin{document}

\frontmatter
\tableofcontents

\mainmatter

\chapter{Preface}

\part{Part title}
\chapter{Chapter title}
\chapter{Chapter title}

\part{Part title}
\chapter{Chapter title}
\chapter{Chapter title}

\backmatter
\appendix
\appchapter{Appendix: Some title}

\chapter{Bibliography}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보