I want to build a big PDF of multiple TeX files which will all have the same preamble. They'll have \newcommand and \renewcommand as well as \usepackage and \documentclass because each file should be standalone and compiled as a smaller PDF. But then, I want to take all of the files we have and put them in a main document. I've looked at the other questions:

and the standalone package. I'm not sure I'll be able to do what I want with these.

Each child document needs to stand on it's own, with it's own preamble, and table of contents, etc. But they should be included in a master document with a global table of contents that ignores/copies all preambles.

Below is example code for one of the children files.

\usepackage{amsmath, amsfonts,amssymb,latexsym, multirow}
\usepackage{fullpage, graphicx, subfig, float, hyperref, enumerate}
\usepackage{pdflscape}%for large figures







\noindent \fbox{
  \textbf{Book} \hfill \textbf{Author}
    {\Large Chapter \#} \\[3mm]
\today \hfill Subauthor

  • 2
    The combine package may help. See tex.stackexchange.com/questions/119415/…. You could also consider a master document with include and includeonly. Jun 19, 2013 at 17:43
  • Doesn't that still require that I build up my preamble manually? Jun 19, 2013 at 17:48
  • Both the methods I suggested above allow you to create a preamble once and use it in several contexts. Jun 19, 2013 at 17:56
  • But this is not what I need though. The preamble might vary across chapters, and when I compile a single chapter - it will have its own table of contents. There should be a global table of contents when I compile all chapters at once, rather than individual ones. \include and \includeonly will allow for a global preamble, but I can only compile a master document, not individual ones. Jun 19, 2013 at 18:04
  • Look at the combine package ctan.mackichan.com/macros/latex/contrib/combine/combine.pdf. It should be flexible enough to meet your needs. Jun 19, 2013 at 18:18

2 Answers 2


There are packages to do that kind of combination but if you are worried about unknown artefacts from the command redefinitions you can simply use


. . .


Then when processed on its own the document will work as normal but in a larger document that already has those definitions loaded (and in particular \p defined you can use


Not related to the inclusion question but the boxed heading is lager than the page:

Overfull \hbox (36.87251pt too wide) in paragraph at lines 29--40

The subfiles package does exactly what you are looking for. There are is a great documentation on Overleaf even with live examples. The main document includes the child files as this:

% global preamble

The child files can be compiled individually and even have their own preamble.

% individual preamble

Also cross-references between the files are supported.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .