Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
The best package for this is the standalone package 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
    
@PeterGrill make that an answer, it works –  keflavich Nov 13 '12 at 0:38
add comment

1 Answer

up vote 1 down vote accepted

The best package for this is the standalone package and class. There are numerous examples on this site.

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.