![목차의 일부 수준에 부록을 표시하는 방법은 무엇입니까?](https://rvso.com/image/266424/%EB%AA%A9%EC%B0%A8%EC%9D%98%20%EC%9D%BC%EB%B6%80%20%EC%88%98%EC%A4%80%EC%97%90%20%EB%B6%80%EB%A1%9D%EC%9D%84%20%ED%91%9C%EC%8B%9C%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
문서 클래스 에서 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
그런데 부록이 part
TOC 수준으로 올라가도록 어떻게 설득할 수 있을까요? 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}