Given that there are, say five papers taking 30 pages of PDFs WITHOUT source TeX files, how do I make a table of contents to list each of them by LaTeX? Moreover, how to assign page numbers to each included PDFs?

• You can always add stuff to the toc using addcontensline and it's related commands. – Johannes_B Oct 3 '14 at 9:39

Use the package tocloft then add \tableofcontents to wherever you want the table of contents to appear in the master doc.

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


Chapter can be substituted for another section type such as section or subsection to define the level it appears in the table of contents.

If you don't have well defined sections then using something like

\clearpage


• Can you elaborate why package tocloft should be loaded? It leads to some incompatibilities with KOMA-script. – Johannes_B Oct 3 '14 at 11:12
• It just provides additional functionality but is not essential. What are the incompatibilities it causes? – James Oct 3 '14 at 12:05
• KOMA comes with package tocstyle to style the appearance of the toc. tocloft, listoffigures, listof=totoc, KOMA: not in tableofcontents and Parts and tocloft compatibility – Johannes_B Oct 3 '14 at 13:39
• Thank you so much for the answer. However, I do not understand the proposal. My question is: Given that there are, say 30 pages of PDF without source file, how do I make a table of contents of them by LaTeX? – Benicio Oct 3 '14 at 14:20
• @Comeseeconquer Well, explain yourself, sir. Is this one pdf document with different sections? Or is every pdf-document a section of its own? – Johannes_B Oct 3 '14 at 14:27

Use the package pdfpages to include the PDFs, and include a sectioning or add-to-contents command in the pagecommand option of the \includepdf command.

For example, assuming you have a base .tex file and two PDFs to attach in a pdfs subdirectory. (Be sure to compile twice.)

\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 (compile from pdfs/doc1.tex)

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


PDF 2 (compile from pdfs/doc2.tex)

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


• What to do with standalone pdf-documents coming with their own title? – Johannes_B Oct 3 '14 at 14:40
• You could manually add them to the contents as the other answer shows, or just repeat the title in the section command (like a cover page for each attachment). – musarithmia Oct 3 '14 at 14:41
• @Johannes_B I see you have just suggested something similar. – musarithmia Oct 3 '14 at 14:42
• Pardon me, would you mind showing me an output? – Benicio Oct 3 '14 at 14:52
• @Comeseeconquer I edited to show the first page; also I added a \clearpage before the first PDF heading so that the title appears on its own page as a cover page before the attached PDF (in the first method described). – musarithmia Oct 3 '14 at 14:59