Getting Started: Subdividing a Large Document

It’s easy and convenient to use just one .tex file when writing short documents. But for anything larger than, say, 10,000 words, I tend to divide the document into smaller parts so each chapter is its own .tex file.

For example, you might be writing a thesis that includes three chapters (introduction, results, conclusion) and an appendix. These are called introduction.tex, results.tex, conclusion.tex and appendix.tex.

These four files are like any other .tex file except you omit the preamble (\documentclass, \usepackage, etc.) and the \begin{document} and \end{document} commands. The reason you don’t include these commands is that they are included in your main file, thesis.tex, ensuring that your formatting is consistent throughout the final output document. This also means that page numbers and footnotes will be numbered correctly all the way through.

Which Commands to Use

There are two commands you can use in your main file, thesis.tex, to insert your four chapter files: \include and \input.

The \input command slots each chapter in straight after the one before it without any pagebreaks, while \include works by starting each new chapter on a new page and ends it with a clearpage command. (Thanks to the latex-community forum for help on explaining this to me!)

In other words, ‘natural candidates for \include are whole chapters of a book but not necessarily small fractions of text,’ for which \input would be more appropriate. (Quotation from The LaTeX Companion.)

Your thesis.tex file would therefore look something like this:

\documentclass{article}
\usepackage{semtrans}

\begin{document}

\title{My Thesis}
\author{John E. Smith}
\maketitle
\clearpage

\include{introduction}
\include{results}
\include{conclusion}
\include{appendix}

\end{document}

Note: your four files (introduction.tex, results.tex, conclusion.tex and appendix.tex) must be saved in the same folder as thesis.tex, otherwise it won’t work.

Omitting Files

If you wanted to produce a PDF from the file thesis.tex without the appendix, all you have to do is comment out that particular \include command (you just add a % at the beginning of the line): %\include{appendix}

Useful Links