[Tex/LaTex] Combining Independent Latex Files

combineimport

I have loads of latex files in a directory, each having (basically the same) preamble. That is, they use the same packages, the same documentclass, and they each define the same newcommands; there might be slight differences.

Is there some package out there that allows me to import all the files into one file without too much fuss?

What I'm essentially after is that some of the files are very short and only take up about a quarter of a page. When I print all this out, I'd rather it format such that it makes the most of every page — that is, immediately start the next latex file on the same page.

Best Answer

edit: improved answer based on comments.

This sounds like a job for the standalone package. After loading the package, you can use the \input command to load the documents.

The full preamble line would be \usepackage[print,sort]{standalone}; the print,sort options need to be set in order to combine all of the preambles into a .stp file. You can then copy the combined preamble from the .stp file into your main document. Perhaps there is a way to automate the process of copying the .stp file contents into the preamble, but I don't know of one.

Related Question