Large documents, if all the text is input in the same. in the Tex file, the size of the file is immeasurable, the structure of the file is messy, and the positioning of the text is also a headache. Fortunately, latex provides a structured processing command --- include. The command \ include {filename} (filename does not contain the suffix. Tex) can insert the content of the filename file to the current position during compilation. Key points:
- In the main document (such as main. Tex), write the introduction area, including which macro packages, and define the style, Font, line spacing, and reference of the entire document.
- In the main document body area, use the command \ include {filename} to include the sub-document.
- The sub-document starts with \ chapter {} And \ section {}. You do not need the introduction area, title, author, and other information.
- You can reference tags of other files in any other file.
See the following example:
% !TeX:pdflatex,pdfTeXify
% Test large files split multiple source files for compilation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% main.tex
% Only create the introduction area in main. Tex and include sub-Files
% The subfile does not need the introduction area or begin {document }.
% \ Chapter {}, \ section {}, and so on.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[UTF8]{ctexbook}
\usepackage{graphicx}
\usepackage[CJKbookmarks=true,colorlinks,linkcolor=black,anchorcolor=blue,citecolor=green]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% Text body %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\youyuan
\sffamily
\ Title {source file splitting and compilation}
\author{Lin\TeX9527}
\date{2014--09--04}
\maketitle
\tableofcontents
\include{file1}
\include{file2}
\end{document}
\ Chapter {fruit}
\ Section {grape}
Grape, purple black and purple black, sweet, really sweet.
\ Section {watermelon}
Watermelon, round and round.
\ Section {dog and watermelon}
See Figure \ ref {FIG: Dog} on Page \ pageref {FIG: Dog }.
\ Chapter {animal}
\ Section {persons}
People and people.
\ Section {dog}
Dogs are good friends of humans.
\begin{figure}[htbp]
\centering
% Requires \usepackage{graphicx}
\includegraphics[scale=0.5]{dog}\\
\ Caption {two cute husky} \ label {FIG: Dog}
\end{figure}
The structure file of the entire project:
You can click the compile button in any source file.
From Weizhi note (wiz)
Large file source file split edit compilation \ include {filename}