Monday, March 07, 2011

Split large LaTeX files

When your paper/report is getting too large it becomes a little complicated/frustrated to maintain it in one big file.

It's possible to split a big .tex file and setup a hierarchical file tree with a small portion of the text on each file.This is achieved using the \include directives.

There are three main LaTeX commands that manage multiple input files.

  • \includeonly which specifies a list of files that will be included by the \include command. If this command exists and file in \include is not listed here, it will not be included
  • \include as it's name says, it include a file in a new page. Used with \includeonly, it can include files selectively. Note: This command can't be nested
    • It's equivalent to \clearpage \input{file} \clearpage
  • \input This is the most simple include scheme and it is equivalent tot a plain C's #include
So your big file 
\section{foo}
% lot of text, figures and equations
\section{bar}
%lot of text and subsections>
can be simplified as
\include{foo}
\include{bar} 
where there is a foo.tex an bar.tex sub-files containing the section text.

If you want to get another layer of simplifications, it's possible to just use \input in the sub-files.

[1] http://www.kfunigraz.ac.at/~binder/texhelp/ltx-165.html

No comments:

Post a Comment