2

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.

2
  • 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. Nov 12, 2012 at 20:28
  • @PeterGrill make that an answer, it works
    – keflavich
    Nov 13, 2012 at 0:38

1 Answer 1

1

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.

You must log in to answer this question.

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