在附录标题中保留“附录 #”,但从目录中删除附录

在附录标题中保留“附录 #”,但从目录中删除附录

我正在写一篇博士论文,我的大学要求我将附录列在与主目录 (TOC) 分开的“附录列表”(LOA) 中。我已使用该tocloft包成功创建了 LOA。问题是附录仍然列在目录中。

一个不太令人满意的解决方法是在附录中使用带星号的\chapterand形式\section。除其他原因外,我不喜欢这样做,因为它会从附录的标题页中删除附录字母。

我怎样才能将附录编号保留在 LOA 中,但将其从 TOC 中删除?

我正在使用appendicestocloftquotchap包。

下面是一个最小可编译示例。

\documentclass[12pt,draft,letterpaper]{report}
\usepackage{quotchap}
\usepackage[titles]{tocloft}
\usepackage{appendix}

\newlistof{appendixchapter}{apx}{List of Appendices}

\newcommand{\appendixchapter}[1]{%
  % These three lines are needed to list the appendix letter in the List Of
  % Appendices even when using \chapter*
  \refstepcounter{appendixchapter}%
  \refstepcounter{chapter}%
  \providecommand{\DOTIS}[1]{\DOCH \DOTI{#1}}

  % '*' removes the appendix from the table of contents.
  \chapter*{#1}

  % Lists the appendix in the List of Appendices.
  \addcontentsline{apx}{appendixchapter}{Appendix \protect\numberline{\theappendixchapter}#1}\par%
  \vspace {-1.47cm}}

\renewcommand{\theappendixchapter}{\Alph{appendixchapter}}

\begin{document}

\tableofcontents
\listofappendixchapter\addcontentsline{toc}{section}{List of Appendices}

\chapter{My first chapter}
This is Chapter 1's body.

\appendixchapter{My first appendix}
This is Appendix A's body.

\appendixchapter{My second appendix}
This is Appendix B's body.

\end{document}

答案1

确实没有必要为附录部分的章节定义新命令;您可以在附录之前重新定义命令\@chapter(在 中定义),将附录包含在新列表中,而不是将它们包含在目录中;下面是此类重新定义的一个示例;请注意,在重新定义 时必须使用 的report.cls第二个强制参数(参见标有 的行):\newlistof\chapter%NEW

\documentclass[12pt,draft,letterpaper]{report}
\usepackage{quotchap}
\usepackage[titles]{tocloft}
\usepackage{appendix}

\newlistof{appendixchapter}{apx}{List of Appendices}

\begin{document}

\tableofcontents
\listofappendixchapter
\addcontentsline{toc}{section}{List of Appendices}

\chapter{My first chapter}
This is Chapter 1's body.

\appendix

\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{apx}{chapter}%NEW
                                   {\protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{apx}{chapter}{#1}%NEW
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\makeatother

\chapter{My first appendix}
This is Appendix A's body.

\chapter{My second appendix}
This is Appendix B's body.

\end{document}

最终文档的摘录显示了 ToC 和 LoA:

在此处输入图片描述

在此处输入图片描述

\appendixchapter根据要求,这里是使用新命令(类似于\chapter)作为附录所需的代码;新定义需要两个新命令\appendixchapter\@appendixchapter;文档正文中只会使用第一个命令:

\documentclass[12pt,draft,letterpaper]{report}
\usepackage{quotchap}
\usepackage[titles]{tocloft}
\usepackage{appendix}

\makeatletter
\newcommand\appendixchapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@appendixchapter\@schapter}
\def\@appendixchapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{apx}{chapter}%NEW
                                   {\protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{apx}{chapter}{#1}%NEW
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\makeatother

\newlistof{appendixchapter}{apx}{List of Appendices}

\begin{document}

\tableofcontents
\listofappendixchapter
\addcontentsline{toc}{section}{List of Appendices}

\chapter{My first chapter}
This is Chapter 1's body.

\appendix


\appendixchapter{My first appendix}
This is Appendix A's body.

\appendixchapter{My second appendix}
This is Appendix B's body.

\end{document}

相关内容