# 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?

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.