Include tex-files and compile separately

For a large project, I'd like to write each chapter on it's own. After that, I'd wish (of course) to incorporate all the chapters in a base document (the large project). I've heard ob \include and \input, but they don't seem to do what I'm searching for:

1. Is it possible to include/input only the part between \begin{document} end \end{document} of the chapter files, so that it's possible to compile the chapter files separately (to be able to check and work on the chapter file) before compiling it in the base document? I know this would be possible by simply deleting the preample of the chapter files, but with a dozen of chapter files, I prefer an automated way (if possible).

2. Is it possible to make references to \label and \ref between different chapters, using different chapter files?

• This will help and point to other relevant ones. May 1, 2014 at 6:45
• I'd recommend using the standalone package for #1. For #2 see the xr pacakge, an example of which is Does hyperref work between two files?. May 1, 2014 at 7:09
• \include is designed to do what you say to process just chapter 2 you process the main file and add \includeonly{chapter2} May 1, 2014 at 11:36

While there are packages I'd use the standard latex \include functionality.

Put each chapter in a separate file (starting \chapter not \documentclass) and use \label and \ref freely across chapters. have a main.tex that looks like

\documentclass{book}
% \includeonly{chapter2}
\begin{document}
\include{chapter1}
\include{chapter2}
\end{document}


When you are working on chapter 2 uncomment the \includeonly and just chapter2 will be processed. References to chapter 1 will still work so long as the .aux file from previous runs that included chapter 1 are still around.