In a root file, referencing chapter file can be done using either the include or the input commands.
When referencing external chapters to include them in the output stream while generating a LaTeX document, you can use either \input or \include.
The following provided an explanation of the difference between using the \input{filename}
and include{filename}
.
Note: For more information about input and include and their differences, see this topic on tex.stackexchange.com: When should I use input vs. include
Using the input Command
The command \input{filename}
imports the commands from filename.tex
into the target file. It’s equivalent to typing all the commands from filename.tex
into the current file at the location of the \input
line.
1
\input{filename}
For example, the following list of chapters use the \input
command to insert the files into the typesetting stream for output.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
%% Chapters inputs
\input{MANUAL/manual-ch01-preface.tex}
\input{MANUAL/manual-ch02-overvew.tex}
\input{MANUAL/manual-ch03.tex}
\input{MANUAL/manual-ch04.tex}
\input{MANUAL/manual-ch05.tex}
\input{MANUAL/manual-ch06.tex}
\input{MANUAL/manual-ch07.tex}
\input{MANUAL/manual-ch08.tex}
\input{MANUAL/manual-ch09.tex}
\input{MANUAL/manual-ch10.tex}
\input{MANUAL/manual-ch11-troubleshooting.tex}
\input{MANUAL/manual-ch12-tutorials.tex}
\input{MANUAL/manual-ch13-faq.tex}
\input{MANUAL/manual-ch14-release-notes}
For most purposes, the \input
command is sufficient. If you want more control over placement of content, then use the \include
command.
Using the include Command
The command include{filename}
add a \clearpage
before and after the insertion of the LaTex file into the typesetting stream. This results in the chapter starting on a new page.
1
\include{filename}
Here is an example list of chapters which use the \include
command to insert the files into the typesetting stream for output.
1
2
3
4
5
\include{tex/preface}
\include{tex/intro}
\include{tex/chap01}
\include{tex/chap02}
\include{tex/summary}
There is much more to these commands, so let Google be your guide.