I have a document I want to split up into individual sections. I'd like each individual section to be independently compilable, but of course I also need the whole document to compile.
The trouble is, each of my individual sections requires a large preface (\usepackage calls, command definitions, etc.) that I am including with either \input or \include. The preface includes the \documentclass command, so I end up getting ! LaTeX Error: Can be used only in preamble. if I try to compile the whole document.
I'm already using \usepackage{subfiles}, but it doesn't seem to solve the problem.
standalonepackage and class. It works great for me. I you might want to collect all your packages and preamble into a separate file so that this file can be included both in the main document and the sub documents. There are numerous examples on this site. – Peter Grill Nov 12 '12 at 20:28