I am creating a lab manual that contains a dozen or so different labs. I want to create each lab manual as their own compilable standalone document and in a main.tex
file I would like to put them all in order.
I have looked into the \input
, \include
, and \import
commands. \input
is clearly not what I want. \include
has not worked for reasons about preamble commands located not in the preamble. The answer may be in \import
somewhere and I don't know how to use it. (It would be great if someone could show me.)
Also I could combine the PDFs with a shell script, but if that is the answer I am not sure how to combine the PDFs.
Best Answer
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 includechapter1.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 thechapter1.tex
file for example) and you can create amain.pdf
.A minimal example:
main.tex
chapter1.tex