在索引中创建条目而不创建章节或节标题

在索引中创建条目而不创建章节或节标题

我的论文是关于我在一家公司开发的一个项目。在项目期间,我生成了几份官方文档,并将它们附加在最后(使用 includepdf 包)。这些文档有自己的封面,因此没有必要创建一个几乎空白的页面,只有“附录 A - Lorem ipsum”,但如果我不包含这个,我将在索引中丢失我的参考资料。我该怎么办?提前致谢!

答案1

这应该有效

\clearpage
\addcontentsline{toc}{chapter}{name that appear in the toc}
\includepdf{file.pdf}

第一个选项“toc”表示目录(您将在其中添加条目)。第二个选项让您根据需要在章节或部分之间进行选择。第三个选项是索引中显示的名称

(也许你应该编译两次才能使其工作)

答案2

您可以使用addtotoc包提供的选项pdfpages来获取包含的 pdf:

\documentclass{report}
\usepackage{lipsum}% only for dummy text
\usepackage{pdfpages}

\begin{document}
\tableofcontents
\includepdf[pages=-,addtotoc={1,chapter,0,First included pdf,incl:first}]{dummy.pdf}
\chapter{Another chapter}
\lipsum
\includepdf[pages=-,addtotoc={1,chapter,0,Second included pdf,incl:second}]{dummy.pdf}
\end{document}

或者得到相同的结果:

\documentclass{report}
\usepackage{lipsum}% only for dummy text
\usepackage{pdfpages}

\begin{document}
\tableofcontents
\clearpage
\refstepcounter{chapter}\label{incl:first}
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}{First included pdf}}
\includepdf[pages=-]{dummy.pdf}
\chapter{Another chapter}
\lipsum
\clearpage
\refstepcounter{chapter}\label{incl:second}
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}{First included pdf}}
\includepdf[pages=-]{dummy.pdf}
\end{document}

\clearpage请注意,\addcontentsline和的顺序\includepdf对于在目录中获取正确的页码非常重要。

如果所包含的 pdf 应该有未编号的章节条目:

\documentclass{report}
\usepackage{lipsum}% only for dummy text
\usepackage{pdfpages}

\begin{document}
\tableofcontents
\clearpage
\addcontentsline{toc}{chapter}{First included pdf}
\includepdf[pages=-]{dummy.pdf}
\chapter{Another chapter}
\lipsum
\clearpage
\addcontentsline{toc}{chapter}{Second included pdf}
\includepdf[pages=-]{dummy.pdf}
\end{document}

相关内容