LaTeX-files for large documents
This is a description of a folder and file structure for documents of the types books, 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 several small help files and 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 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're not named chap1 and chap2. This is so you can easily rearrange the order of the chapters without having to change names. Additionally, there are two subfolders more: one for texing the whole book, EntireBook, and one for title pages, forewords, Table of Contents etc., with the name Frontmatter. Additional comments come after the descriptions of the files.
Capitals/ contains a tex-file, Capitals.tex.
- Capitals.tex:
\documentclass{avhandling} \newcommand\topdir{..} \newcommand\thisdir{\topdir} % Will be changed in the chapters \input{includeonly} % To be explained later \newcommand\figdir{\thisdir/figures} % See comment below \bibliographystyle{LongLabels} \begin{document} \include{\topdir/Frontmatter/Frontmatter} \include{\topdir/London/London} \include{\topdir/Madrid/Madrid} \end{document}
Capitals/London/ contains at least three tex-files:
includeonly.tex, London.tex, Capitals.tex
- includeonly.tex:
\includeonly{\topdir/London/London}
- London.tex:
\renewcommand\thisdir{\topdir/London} \chapter{London, the City that Lost an Empire} \label{chap:London} This chapter contains a thorough description of London. % Local Variables: % TeX-master: "Capitals" % End:
- Capitals.tex:
\input{../Capitals}
Capitals/Madrid/ contains at least three tex-files:
includeonly.tex, Madrid.tex, Capitals.tex
- includeonly.tex:
\includeonly{\topdir/Madrid/Madrid}
- Madrid.tex:
\renewcommand\thisdir{\topdir/Madrid} \chapter{Madrid, where the Diagonals Cross} \label{chap:Madrid} This chapter contains a thorough and exhaustive description of Madrid. % Local Variables: % TeX-master: "Capitals" % End:
- Capitals.tex:
\input{../Capitals}
Capitals/Frontmatter/ looks the same as in the other chapters, but is used for title pages, Table of Contents etc.
Capitals/EntireBook/ should be used when you want to tex the whole book. It contains two files
- includeonly.tex: This file should be empty.
- Capitals.tex: This is like the corresponding file in the chapters.
Some comments
The purpose of all of this is so you can go to any chapter and type the command latex Capitals. Only this chapter will be processed, but all numbering and cross-references will still be correct.
The parts % Local Variables above are intended for AUC-tex and are described in its manual, the chapter 'Multifile Documents'. You can tex a chapter directly from XEmacs without having to change buffer.
\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.
On Unix, you can exchange the file Capitals.tex in the different chapters with symbolic links, but the method described here also works on Windows.