![目次の一部のレベルで付録を表示するにはどうすればよいですか?](https://rvso.com/image/266424/%E7%9B%AE%E6%AC%A1%E3%81%AE%E4%B8%80%E9%83%A8%E3%81%AE%E3%83%AC%E3%83%99%E3%83%AB%E3%81%A7%E4%BB%98%E9%8C%B2%E3%82%92%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
ドキュメントクラスでは、book
パート レベルの目次に表示される付録が必要です。目次は次のようになります。
Preface
Part title
Chapter title
Chapter title
Part title
Chapter title
Chapter title
Appendix: Some title
Bibliography
Index
参考文献と索引を追加する方法も知っていますし、 PDF 内の適切な場所を指すようにするコツ\addcontentsline{toc}{part}{...}
も知っています。\phantomsection
しかし、付録をpart
目次のレベルまで到達させるにはどうしたらよいでしょうか? 付録はchapter
最後の部分の下にあります。
\appendix を使用せずに「手動で」付録を作成してもかまいません。ちなみに、私は\titlesec
章とパートの書式設定をカスタマイズするために を使用しています。
答え1
付録は 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}