14 Big Files

14.1 Include

If you're writing a large document such as a book or thesis, then it's usually more manageable to split it into several files. It's easy to combine these in LaTeX using the include command. By putting all your command definitions in one file, and each chapter in a different file, you can keep your main LaTeX file very neat indeed, e.g.

\documentclass[12pt,final]{book}
\usepackage{fancyheadings,graphicx,cite,setspace,lscape}
\usepackage{wrapfig,color,multicol}

\include{definitions}

% Only chapters go into the table of contents
\setcounter{tocdepth}{0}
\definecolor{gray}{gray}{0.8}

\begin{document}

\begin{titlepage}
\title{\Huge{\texttgoth{My Opus Magnum}}}
\author{\sc by Phil Hasnip}
\date{}
\end{titlepage}

\maketitle

\pagenumbering{roman}
\include{halftitle}
\include{frontstuff}
\tableofcontents
\include{preface}
\include{halftitle}

\pagenumbering{arabic}
\include{introduction}
\include{theory}
\include{initial_results}

\include{better_theory}
\include{nice_results}
\include{conclusions}

% Bibliography
\addcontentsline{toc}{chapter}{\sc Bibliography}
\bibliography{thesis}
\bibliographystyle{smooth}

\end{document}

The files you're including are put in your document exactly as if you'd copy-and-pasted them yourself. This means they shouldn't usually have any preamble such as \documentclass or \usepackage, they don't even need a \begin{document} - these are all done in the main LaTeX document.

14.2 Your Own Style Files

If you find yourself defining the same paper margins or commands again and again then you might want to create your own style file. Style files have the sty extension, and are essentially just a list of LaTeX commands. They don't have any preamble at all, and can be used with a \usepackage command just like any other style file.


Previous page Next page