Multiple Document Compilation #
Author: Erhua
Keywords: Multiple Document Compilation
In this section, we discuss multiple document compilation.
If we are typesetting a small article, just a few pages, then using a single compilation file is sufficient. However, if we need to typeset a document that is dozens or even hundreds of pages long, it is better to use multiple sub-documents for compilation. We can divide the document into several sections or parts according to the chapters or logic of the file, and write them separately in different tex files, and finally integrate them into one document.
Method 1:
Page break method: generally used between different parts or chapters.
\include{filename(without the .tex extension)}% Note: this starts a new page before and after the inclusion
The filename is the name of the new module to be included.
This method can import external tex documents and start a new page before and after the inclusion.
\includeonly{document list(can be multiple)}% Put in the preamble
The purpose is to include multiple documents in the main text, but only compile the ones that are needed. Just fill in the names of the needed documents.
Example:
\documentclass[]{article}
\usepackage{ctex}
\includeonly{1.tex, 2.tex} % Only compile 1 and 2
\begin{document}
\include{1.tex}
\include{2.tex}
\include{3.tex}
\end{document}
Method 2:
Insert as is, without any formatting effects (no page break).
\input{filename}
This method can be used to include things in the main document that may appear complicated and affect the aesthetics of the document, such as configuration in the preamble, or complex tables.