Splitting A Large Document Into Several

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Splitting a Large Document into Several

Files

between the two commands are as


follows:
\input acts as though the contents of the file were typed where the \input
command was. For example, suppose my main file contained the
Previous Next First Last Back Forward Summary Index 33
following:
" Input
Here is a short paragraph.
\input{myfile}
# Input
and suppose the file myfile.tex contained the following lines:
" Input
Here is some sample text.
# Input
then the \input command behaves as though you had simply typed
the following in your main document file:
3 Splitting a Large Document into Several Files
Previous Next First Last Back Forward Summary Index 34
" Input
Here is a short paragraph.
Here is some sample text.
# Input
\include does more than just input the contents of the file. It also starts
a new page (using \clearpage) and creates an auxiliary file associated
with the included file. It also issues another \clearpage once
the file has been read in. Using this approach, you can also govern
which files to include using
\includeonly{⟨file list⟩} Definition
in the preamble, where ⟨file list⟩ is a comma-separated list of files
you want included. This way, if you only want to work on one
or two chapters, you can only include those chapters, which will
speed up the document build. LATEX will still read in all the crossreferencing
information for the missing chapters, but won’t include
3 Splitting a Large Document into Several Files
Previous Next First Last Back Forward Summary Index 35
those chapters in the PDF file. There is a definite advantage to
this if you have, say, a large number of images in your results
chapter, which you don’t need when you’re working on, say, the
technical introduction. You can still reference all the figures in
the omitted chapter, as long as you have previously LATEXed the
document without the \includeonly command.
The excludeonly package provides the logically opposite command:
\excludeonly{⟨file list⟩} Definition
The previous example can now be split into various files:
Listing 2 (thesis.tex)
" Input
% arara: pdflatex: { synctex: on }
% arara: pdflatex: { synctex: on }
\documentclass[oneside]{scrbook}
\title{A Sample Thesis}
\author{A.N. Other}
3 Splitting a Large Document into Several Files
Previous Next First Last Back Forward Summary Index 36
\date{July 2013}
\titlehead{A Thesis submitted for the degree of Doctor of Philosophy}
\publishers{School of Something\\University of Somewhere}
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\listoffigures
\listoftables
\chapter{Acknowledgements}
I would like to thank my supervisor, Professor Someone. This
research was funded by the Imaginary Research Council.
\chapter{Abstract}
A brief summary of the project goes here.
\mainmatter
3 Splitting a Large Document into Several Files
Previous Next First Last Back Forward Summary Index 37
\include{intro}
\include{techintro}
\include{method}
\include{results}
\include{conc}
\backmatter
\end{document}
# Input
Listing 3 (intro.tex)
" Input
\chapter{Introduction}
\label{ch:intro}
# Input
3 Splitting a Large Document into Several Files
Previous Next First Last Back Forward Summary Index 38
Listing 4 (techintro.tex)
" Input
\chapter{Technical Introduction}
\label{ch:techintro}
# Input
Listing 5 (method.tex)
" Input
\chapter{Method}
\label{ch:method}
# Input
Listing 6 (results.tex)
" Input
\chapter{Results}
\label{ch:results}
# Input
Listing 7 (conc.tex)
" Input
\chapter{Conclusions}
\label{ch:conc}

You might also like