Making one PDF file from multiple PDFs or Tex?

You might be looking for the subfiles package. You have one main tex-file (main.tex for example) with the entire preamble you want in each file. Here you choose the documentclass you like and use the package subfiles: \usepackage{subfiles}. Between \begin{document} and \end{document} you use \subfile{chapter1.tex} to include chapter1.tex.

In your seperate files (for example chapter1.tex, chapter2.tex, chapter3.tex) you write the following: \documentclass[main.tex]{subfiles}. This way you can create seperate pdfs from each chapter (just compile the chapter1.tex file for example) and you can create a main.pdf.

A minimal example:

main.tex

\documentclass{report}
\usepackage{subfiles}

\begin{document}
\tableofcontents
\subfile{chapter1.tex}
\end{document}

chapter1.tex

\documentclass[main.tex]{subfiles}
\begin{document}
Here comes some text
\end{document}

I have found that this works:

\documentclass{report}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{doc1.pdf}
\includepdf[pages=-]{doc2.pdf}
%... continue for all docs
\end{document}

This will insert your documents into one file in the order specified.


The commands \input and \include are good for splitting a single TeX document into several files, but the combined text should look like a single document (i.e., only one preamble, and definitions get continued from one text to the next. Since you have several independent files, these commands aren't for you.

You don't make it entirely clear what you want, so here's two scenarios:

a) You simply want to bind the PDFs together into a single PDF, without any changes. In that case, pdfpages is your friend. Create a simple document that loads pdfpages and simply includes each component pdf with \includepdf{docname}. See the pdfpages documentation for more details and options (e.g., partial inclusion).

b) You want to combine the independent documents and compile them as a singe TeX document. In that case, use docmute as explained in this answer.

Tags:

Combine