如何製作目錄,列出不是由同一 TeX 檔案產生的 PDF?

如何製作目錄,列出不是由同一 TeX 檔案產生的 PDF?

假設有五篇論文需要 30 頁的 PDF,沒有來源 TeX 文件,我如何製作一個目錄來用 LaTeX 列出每一篇論文?此外,如何為每個包含的PDF分配頁碼?

答案1

使用 tocloft 包,然後將其新增\tableofcontents至您希望目錄出現在主文檔中的任何位置。

若要將某個部分新增至目錄中,如果未自動選取它們,您可以使用下面的程式碼。只需將其新增至您希望出現在目錄中的每個章節標題下方,並替換章節標題的「section_name」即可。

\addcontentsline{toc}{Chapter}{\protect\numberline{}section_name}

章可以替換為其他節類型(例如節或小節),以定義它在目錄中出現的層級。

如果你沒有明確定義的部分,那麼就使用類似的東西

\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{section_name}

將為目錄提供一個錨點,並新增section_name作為目錄的參考點。

答案2

使用套件pdfpages包含 PDF,並在命令pagecommand選項中包含分段或新增至內容命令\includepdf

例如,假設您有一個基本.tex文件和兩個要附加在pdfs子目錄中的 PDF。 (一定要編譯兩次。)

\documentclass{article}
\usepackage{pdfpages}

\begin{document}

\tableofcontents

\section{Main Text}

Two attachments follow. % I show two different ways below.

% (1) With a section command in the main file 
% (the heading will be printed on a separate page, 
%  but will not overlap with inserted PDF content)

\clearpage\section{First Attachment}
\includepdf[pages=-]{pdfs/doc1} % pages=- means all pages

% (2) With a pagecommand (heading will be printed ON 
% the inserted PDF, so may overlap with content)

\includepdf[pages=1, pagecommand={\section{Second Attachment}}]{pdfs/doc2}
\includepdf[pages=2-last]{pdfs/doc2}

\end{document}

PDF 1(從 pdfs/doc1.tex 編譯)

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1-19]
\end{document}

PDF 2(從 pdfs/doc2.tex 編譯)

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[20-29]
\end{document}

在此輸入影像描述

相關內容