如何更改目录内的格式?

如何更改目录内的格式?

我正在用该类写一本书book。在目录中,我想要

第 1 部分 无论第 1 章 无论...然后切换到附录

附录 附录 A 无论...

我似乎无法LaTeX识别\renewcommand从部分到空白以及从章节到附录的更改。我似乎无法摆脱PART" before APPENDICES without getting rid of it on all the other sections, or to change“章节”到“附录”

我还想删除第 1、9 和 15 页的页码。我尝试将它们放在\thispagestyle{empty}文档的各个位置,但都无济于事。

这是我的代码:

\documentclass[11pt]{book}
\usepackage[toc,page]{appendix}
\usepackage{tocloft}
\begin{document}
\renewcommand{\cftpartfont}{\bfseries}
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftpartpresnum}{PART~}
\renewcommand{\cftpartaftersnum}{:}
\renewcommand{\cftpartnumwidth}{6em}

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{Chapter~}
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{6em}



\frontmatter
\thispagestyle{empty}
\setcounter{tocdepth}{1}
\tableofcontents

\mainmatter
\renewcommand\partname{PART}
\part{Theory of Junk}
\input{Ch1}
\input{Ch2}
\input{Ch3}

\part{Theory of Garbage}
\input{Ch4}
\input{Ch5}


\renewcommand\partname{}
\renewcommand\thepart{\null}
\renewcommand{\cftpartpresnum}{}

\part{APPENDICES}
\appendix
\renewcommand{\cftchappresnum}{Appendix~}
\input{A1}
\input{A2}


\backmatter
\end{document}

答案1

您必须使用以下方法将更改写入目录\addtocontents

\addtocontents{toc}{%
  \protect\renewcommand{\protect\cftpartpresnum}{}%
  \protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
  \protect\renewcommand{\protect\cftchapnumwidth}{7em}%
}%

无包装示例appendix

\documentclass[11pt]{book}
\usepackage{blindtext}% only for dummy text
%\usepackage[toc,page]{appendix}% not used in the example
\usepackage{tocloft}

\renewcommand{\cftpartfont}{\bfseries}
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftpartpresnum}{PART~}
\renewcommand{\cftpartaftersnum}{:}
\renewcommand{\cftpartnumwidth}{6em}

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{Chapter~}
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{6em}

\renewcommand{\partname}{PART}

\newcommand{\originalappendix}{}
\let\originalappendix\appendix
\renewcommand{\appendix}{%
  \originalappendix
  \addtocontents{toc}{%
    \protect\renewcommand{\protect\cftpartpresnum}{}%
    \protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
    \protect\renewcommand{\protect\cftchapnumwidth}{7em}%
  }%
  \cleardoublepage
  \addcontentsline{toc}{part}{APPENDICES}%
  \part*{APPENDICES}%
}

\begin{document}
\frontmatter
\thispagestyle{empty}
\setcounter{tocdepth}{1}
\tableofcontents

\mainmatter
\part{Theory of Junk}
\blinddocument
\blinddocument
\blinddocument
\part{Theory of Garbage}
\blinddocument
\blinddocument

\appendix
\blinddocument
\blinddocument

%\backmatter
\end{document}

在此处输入图片描述

相关内容