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?

  • 1
    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.

To add a section to your table of contents, if they are not picked up automatically, you can use the code below. Just add it below each section heading you wish to appear in your table of contents, replacing section_name for the section heading.


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


will provide an anchor point for the table of contents and add section_name for a reference point to table of contents.

  • 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.)




\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}


PDF 1 (compile from pdfs/doc1.tex)


PDF 2 (compile from pdfs/doc2.tex)


enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.