Aubrey Blumsohn 给出了“使用 titlesec 包时在目录中的编号前添加‘Part’”的答案。但是,对于附录,Part 编号无法显示。以下是 MWE:
\documentclass{book}
\usepackage{titlesec,titletoc}
\usepackage[titletoc]{appendix}
\titlecontents{part}%
[0pt]{\sffamily\bfseries\large\protect\addvspace{15pt}\titlerule\addvspace{1.5ex}}%remove rule if you like
{}{\partname~}
{\hfill\contentspage}%replaced with {} if don't want page number for parts
[\addvspace{0.7ex}\titlerule\addvspace{1.5ex}]%remove rule if you like
\begin{document}
\tableofcontents
\part{Beginnings}
\chapter{Things}
\chapter{More Things}
\appendixpage
\appendix
\addcontentsline{toc}{part}{Appendices}
\addtocontents{toc}{\protect\renewcommand\protect\chaptername{\protect\appendixname}}
\chapter{Second Thoughts}
\end{document}
输出如下: