如何不显示文档中的章节而只显示目录中的章节

如何不显示文档中的章节而只显示目录中的章节

我想在附录中创建章节,但不希望它们出现在报告本身中。我只希望它们出现在目录中。我还希望“附录”不提供页码。这可以吗?

\documentclass[11 pt, twoside, openright, tikz]{report}
\usepackage{tocloft}
\begin{document}
{\let\cleardoublepage\clearpage\tableofcontents}
\begin{appendices}
\addtocontents{toc}{\cftpagenumbersoff{chapter}}
\chapter{appendix 1}
\chapter{appendix 2}
\end{appendices}
\end{document}

提前致谢。

附言:原因是,我有一些附件。但我的 LaTeX 文件中没有它们。所以我想单独打印它们,但仍在我的目录中看到它们。

答案1

您需要运行一次以下命令来创建所需的辅助文件。取消注释后,\includeonly{chapter2}它将仅显示目录和第二章,但第 2 章将像以前一样从第 5 页开始。

注意:我仅用于filecontents简化在一个 MWE 中创建 3 个文件。

\begin{filecontents}{chapter1}
\chapter{first}
\end{filecontents}
%
\begin{filecontents}{chapter2}
\chapter{second}
\end{filecontents}
%
\documentclass{book}
%\includeonly{chapter2}
\begin{document}
\tableofcontents
\include{chapter1}
\include{chapter2}
\end{document}

相关内容