如何使用文档类书籍在目录中添加文字章节和附录?

如何使用文档类书籍在目录中添加文字章节和附录?

我正在使用代尔夫特理工大学论文模板:http://www.tudelft.nl/thema/handleiding-huisstijl/downloads/ 目录中只显示章节编号和附录,但我希望同时显示章节和附录这两个字。但我不希望标题本身\mainmatter包含这两个字。在标题中,我只希望数字和字母\appendix 目前情况如下

答案1

我假设你使用dissertation.cls来自在此 zip 档案中在您链接到的网页上,它将加载类book和(除其他外)包titletoc。然后,您可以通过在序言中添加以下几行来实现所需的目的:

%%% The following lines add Chapter or Appendix in front of the number
\titlecontents{chapter}%
  [0pt]%
  {\vspace{1ex}}%
  {\bfseries\chapappname\ \thecontentslabel\quad}%
  {\bfseries}%
  {\bfseries\hfill\contentspage}
%%% Initially, for the main part of the document, set the label to "Chapter"
\let\chapappname\chaptername

此外,在\appendix命令后添加以下行

%%% Sets the label in the table of contents to "Appendix"
\addtocontents{toc}{\string\let\string\chapappname\string\appendixname}

但有一个问题:由于 LaTeX 错误,您可能无法使用\include它来包含附录的代码。相反,请\input直接使用或将其写入主文件。

%%% The appendices have to be included with `\input`, not `\include`
%%% due to a bug in LaTeX, otherwise the appendices will also be
%%% labeled "Chapter"
\input{appendix-a/appendix-a}
%%% Wrong: \include{appendix-a/appendix-a}

在此处输入图片描述

\documentclass{dissertation}
%%% The following lines add Chapter or Appendix in front of the number
\titlecontents{chapter}%
  [0pt]%
  {\vspace{1ex}}%
  {\bfseries\chapappname\ \thecontentslabel\quad}%
  {\bfseries}%
  {\bfseries\hfill\contentspage}
%%% Initially, for the main part of the document, set the label to "Chapter"
\let\chapappname\chaptername
\begin{document}

%% Specify the title and author of the thesis. This information will be used on
%% the title page (in title/title.tex) and in the metadata of the final PDF.
\title[Optional Subtitle]{Title}
\author{Albert}{Einstein}

%% Use Roman numerals for the page numbers of the title pages and table of
%% contents.
\frontmatter

\include{title/title}

%% The (optional) dedication can be used to thank someone or display a
%% significant quotation.
\dedication{\epigraph{Science is a wonderful thing \\ if one does not have to earn one's living at it.}{Albert Einstein}}

\tableofcontents

\include{summary/summary}
\include{preface/preface}

%% Use Arabic numerals for the page numbers of the chapters.
\mainmatter

%% Turn on thumb indices.
\thumbtrue

\include{chapter-1/chapter-1}
\include{conclusion/conclusion}
\include{epilogue/epilogue}
\include{acks/acks}

%% Use letters for the chapter numbers of the appendices.
\appendix
%%% Sets the label in the table of contents to "Appendix"
\addtocontents{toc}{\string\let\string\chapappname\string\appendixname}

%%% The appendices have to be included with `\input`, not `\include`
%%% due to a bug in LaTeX, otherwise the appendices will also be
%%% labeled "Chapter"
\input{appendix-a/appendix-a}

%% Turn off thumb indices for unnumbered chapters.
\thumbfalse

\include{cv/cv}
\include{publications/publications}

\end{document}

编辑:为了使章节的目录条目完全为青色,而使(子)部分目录条目完全为黑色(如评论中所要求的),请在序言中添加以下几行(替换上面显示的几行)。

%%% The following lines add Chapter or Appendix in front of the number
\titlecontents{chapter}%
  [0pt]%
  {\vspace{1ex}}%
  {\color{title}\bfseries\chapappname\ \thecontentslabel\quad}%
  {\bfseries}%
  {\bfseries\hfill\contentspage}
%%% Initially, for the main part of the document, set the label to "Chapter"
\let\chapappname\chaptername
\titlecontents{section}
  [3.8em]%
  {}%
  {\colorlet{title}{black}\contentslabel{2.3em}}%
  {\hspace*{-2.3em}}%
  {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}
  [6.8em]%
  {}%
  {\colorlet{title}{black}\contentslabel{3.0em}}%
  {\hspace*{-3.0em}}%
  {\titlerule*[1pc]{.}\contentspage}

在此处输入图片描述

\documentclass{dissertation}
%%% The following lines add Chapter or Appendix in front of the number
\titlecontents{chapter}%
  [0pt]%
  {\vspace{1ex}}%
  {\color{title}\bfseries\chapappname\ \thecontentslabel\quad}%
  {\bfseries}%
  {\bfseries\hfill\contentspage}
%%% Initially, for the main part of the document, set the label to "Chapter"
\let\chapappname\chaptername
\titlecontents{section}
  [3.8em]%
  {}%
  {\colorlet{title}{black}\contentslabel{2.3em}}%
  {\hspace*{-2.3em}}%
  {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}
  [6.8em]%
  {}%
  {\colorlet{title}{black}\contentslabel{3.0em}}%
  {\hspace*{-3.0em}}%
  {\titlerule*[1pc]{.}\contentspage}
\begin{document}

%% Specify the title and author of the thesis. This information will be used on
%% the title page (in title/title.tex) and in the metadata of the final PDF.
\title[Optional Subtitle]{Title}
\author{Albert}{Einstein}

%% Use Roman numerals for the page numbers of the title pages and table of
%% contents.
\frontmatter

\include{title/title}

%% The (optional) dedication can be used to thank someone or display a
%% significant quotation.
\dedication{\epigraph{Science is a wonderful thing \\ if one does not have to earn one's living at it.}{Albert Einstein}}

\tableofcontents

\include{summary/summary}
\include{preface/preface}

%% Use Arabic numerals for the page numbers of the chapters.
\mainmatter

%% Turn on thumb indices.
\thumbtrue

\include{chapter-1/chapter-1}
\include{conclusion/conclusion}
\include{epilogue/epilogue}
\include{acks/acks}

%% Use letters for the chapter numbers of the appendices.
\appendix
%%% Sets the label in the table of contents to "Appendix"
\addtocontents{toc}{\string\let\string\chapappname\string\appendixname}

%%% The appendices have to be included with `\input`, not `\include`
%%% due to a bug in LaTeX, otherwise the appendices will also be
%%% labeled "Chapter"
\input{appendix-a/appendix-a}

%% Turn off thumb indices for unnumbered chapters.
\thumbfalse

\include{cv/cv}
\include{publications/publications}

\end{document}

相关内容