welcome: please sign in
location: Computer / Latex / LargeDocuments

LaTeX-files for large documents

Here is an old version of this page

This is a description of a folder and file structure for documents such as books, theses, reports and similar with several chapters. The idea is that you should be able to work on one chapter at a time and still get all numbering and cross-referencing correct all the time. The proposed structure might seem complex, with files on different levels, but it's probably not possible to simplify and still be able to tex the whole book and individual chapters without having to switch between the two and edit the text.

The important commands to acheive this are \include{} and \includeonly{}, which are described in the LaTeX wikibook or the LaTeX book.

The book in the example is supposed to describe the capitals of Europe and hence the main folder is called  Capitals, and the main file Capitals/Capitals.tex.

There are two chapters so far, and therefore two sub-folders, which are named Madrid and London. Note that they are not named chap1 and chap2. This is so you can easily rearrange the order of the chapters without having to change names. There is also another subfolder with the name Frontmatter, intended for title pages, forewords, Table of Contents etc. Additional comments come after the descriptions of the files.

 Capitals/  contains a tex-file, Capitals.tex.

 \documentclass{LTHthesis}
 \newcommand\thisdir{.}                 % Will be changed in the chapters
 \newcommand\figdir{\thisdir/figures}   % See comment below
 \addbibresource{europe.bib}            % and other preamble commands

 \includeonly{                          % For the layout, see comments below.
   Frontmatter/Frontmatter,
   London/London,
   Madrid/Madrid,
 }

 \begin{document}
 \include{Frontmatter/Frontmatter}
 \include{London/London}
 \include{Madrid/Madrid}
 \end{document}

Capitals/London/ contains at least one tex-file, London.tex, and possibly a subdirectory figures.

 Capitals/Madrid/  contains at least one tex-file, Madrid.tex and possibly a subdirectory figures.

Capitals/Frontmatter/  is used for title pages, Table of Contents etc. Typically:

  \begin{titlepages}
    \author{...}
    \title{...}
    % other entries for the title pages
  \end{titlepages}
  \chapter*{Acknowlegements}
  % ...
  \chapter*{Abstract}
  % ...
  \tableofcontents

The different parts of Frontmatter may be in separate files, but in this case, use \input, not \include.

Some comments

The statement \includeonly ... has this special layout so that it will be easy to comment out all chapters except the one you specifically want to work with. You can then type latex Capitals, and only the desired chapter will be processed, but all numbering and cross-references will still be correct.

Both Texmaker and Texstudio have the possibility to specify a 'Master File', in this case Capitals.tex, such that even if you work with London.tex, the build command will be for the main file, Capitals.tex

\figdir as defined in Capitals.tex  above presumes that each chapter has a subfolder with the name figures, where the figures for each respective chapter are located. There are other possible layouts and you can change the definiton of \figdir to fit.

Computer/Latex/LargeDocuments (last edited 2022-06-01 12:05:44 by leif)