Summary
This lesson closes the third unit of the course, devoted to the structure of the document. It reconstructs the chain of decisions and mechanisms that runs from the document class to a preamble of one’s own, pointing out in each link which principle is used and in which lesson it is established; it places what has been achieved against the plan of the course and specifies which questions, barely anticipated, are left for the following units; it repeats in its exit assessment the skills of the entry assessment; and it ends with six challenges, harder than the problems of the lessons, which require combining several of them to plan a thesis from its regulations, predict the numbering and the references of a book, and diagnose divided documents that fail or that lie.
Learning objectives
- Reconstruct the order of the decisions and mechanisms of the unit, identifying the principle on which each one rests.
- Explain how the numbering, the table of contents, the cross-references and partial compilation depend on the auxiliary files.
- Distinguish what the unit established from what it only anticipated and the following units will develop.
- Diagnose documents divided into several files that fail, or that compile with false numbers, ordering the corrections.
- Plan the class, the page, the parts, the cross-references and the files of a thesis from the regulations it must meet.
What the unit achieved
The unit set out to give the document an architecture whose numbers, table of contents and cross-references remain true through all its changes. The purpose has been fulfilled by relying on what the introduction declared known from the previous units: the runs of the compilation, the division between preamble and body, and logical markup. With that, the path travelled can be read as a single chain in five stretches.
Document classes and page layout
The lesson on document classes and page layout established that the class decides which divisions exist, what \maketitle does, whether there is an abstract and whether even pages are distinguished from odd ones; from this it deduced a criterion for choosing among article, report and book according to the structure and the printing, and it presented the KOMA-Script classes, together with the option es-noquoting that combining them with Spanish requires in the TeX Live version of these examples. It went through the class options, explained why the margins depend on the length of the line and how to set them with geometry, and ended with page styles, which some commands of the class impose on their own.
Sections, table of contents and appendices
The lesson on sections, the table of contents and appendices typeset the title data and the abstract, ordered the levels of division and established that two independent counters, secnumdepth and tocdepth, decide what is numbered and what enters the table of contents. It explained that the table of contents is typeset from what the previous run recorded, with no warning when it is out of date; that \appendix changes the numbering of what follows it; and that a book has three parts, with two page numberings, whose order is not indifferent.
Cross-references
The lesson on cross-references established the principle on which every reference depends: a label records the last number assigned before it, within its environment. From it, it deduced where the label goes in each element, why a label before the caption of a figure refers to the section, and why an unnumbered section has no number of its own to refer to. It showed that, after a change, a single compilation prints the previous numbers with every appearance of correctness, and it presented hyperref, which must be loaded at the end of the packages, and cleveref, which comes after it and which in English abbreviates “fig.” and “eq.” and writes names in lowercase unless told otherwise.
Long documents
The lesson on long documents divided a document into a main file and pieces without a preamble. It distinguished \input, a literal substitution, from \include, which starts a new page, writes an auxiliary file of its own and admits \includeonly, whose numbering depends on the auxiliary files of an earlier complete compilation. It established that paths are written from the folder of the main file, that in Texmaker the master document is declared, and it went through the errors typical of divided documents, two of them silent: the piece that \include does not find, and the piece with a preamble, whose \end{document} ends the thesis.
Macros and a preamble of one’s own
The lesson on macros and a preamble of one’s own turned logical markup into a method: \newcommand with arguments and with an optional one, the protection that prevents redefining a name already taken, the space lost after a command without arguments, \NewDocumentCommand, environments of one’s own, whose arguments exist only in the opening, and the preamble moved to a file or to a package, which must not impose the class, the language or the position of hyperref.
The following figure gathers the five stretches into a single chain. Each node of the column is a decision or a mechanism, numbered according to the order in which they rest on one another and joined by an arc to the earlier links it uses; around it float the supports, that is, the principles to which the chain returns again and again, each joined with a solid line to the links that rest on it and with a dotted one to the link where it is established, except those established in earlier units, which are drawn as rings. Clicking a support highlights all the links that use it, and each link refers to the lesson in which it is studied.
Supports of the chain
- ARuns. The engine records the numbers, titles and pages in the auxiliary files in one run, and uses them in the next. Established in the first unit. Admitted without proof in this unit.
- BPreamble and body. The preamble configures and loads packages, and the body typesets; what only defines or stores may go in either. Established in the first unit. Admitted without proof in this unit.
- CContent and form. The author declares what each thing is, and a decision taken elsewhere fixes how it looks. Established in the previous units. Admitted without proof in this unit.
- DThe class decides. The document class decides which divisions exist, what typesets the title, whether there is an abstract, how the pages are laid out and which style its commands impose. Established in: 1. Three standard classes.
- EWhat a label records. A label records the last number assigned before it, within its environment, without knowing what it is attached to. Established in: 11. Labels and references.
- FLoading order. Packages are loaded in the order in which they are read, and a later one can undo what an earlier one did: hyperref goes at the end, and cleveref after it. Established in: 13. Links.
- GThe main file. It is always the main file that is compiled; the pieces are fragments of its body, without a preamble, and their paths are written from the folder of the main file. Established in: 16. The include command.
Segment 1 Document classes and page layout
- Choose the class by the structure and the printing of the document.
- Declare the class options and predict their effect.
- Set the margins with geometry without lengthening the line too much.
- Predict and change page styles, headers and footers.
Three standard classes. article has no chapters; report has them, with title and abstract on pages of their own; book prints two-sided and has no abstract.
Rests on: B (Preamble and body). Proved in: Document classes and page layout.
KOMA-Script. scrartcl, scrreprt and scrbook correspond to the standard classes with European decisions; with babel set to Spanish they require, in this version, the option es-noquoting.
Uses: 1. Three standard classes. Rests on: C (Content and form). Proved in: Document classes and page layout.
Class options. Paper, type size, one or two sides, title page, where chapters begin and draft mode are declared in the first line.
Uses: 1. Three standard classes. Rests on: D (The class decides). Proved in: Document classes and page layout.
Margins. geometry computes the page from a few measurements; the width of the text block fixes the length of the line, which is what the reader suffers.
Uses: 3. Class options. Rests on: B (Preamble and body). Proved in: Document classes and page layout.
Page styles. The style decides headers and footers;
\maketitleand\chapterimpose the plain style on their page, and fancyhdr or scrlayer-scrpage build styles of one’s own.Uses: 1. Three standard classes, 4. Margins. Rests on: D (The class decides). Proved in: Document classes and page layout.
Segment 2 Sections, table of contents and appendices
- Typeset the title and the abstract according to the class.
- Choose the level of division and predict the numbering and the table of contents.
- Produce the table of contents and the lists, knowing which run they depend on.
- Order the appendices and the parts of a book.
Title and abstract.
\title,\authorand\datestore,\maketitletypesets; the abstract environment exists in article and report, not in book.Uses: 1. Three standard classes. Rests on: D (The class decides), B (Preamble and body). Proved in: Sections, table of contents and appendices.
Levels of division. Seven levels, from part to subparagraph; the chapter exists only in report and book, and the hierarchy is not chosen by the size of the heading.
Uses: 1. Three standard classes. Rests on: D (The class decides). Proved in: Sections, table of contents and appendices.
Numbering and contents. secnumdepth decides which levels are numbered and tocdepth which enter the table of contents; the starred form neither numbers nor uses up a number.
Uses: 7. Levels of division. Rests on: C (Content and form). Proved in: Sections, table of contents and appendices.
Contents and lists. The table of contents typesets what the previous run recorded in the .toc file, and gives no warning when it is out of date.
Uses: 7. Levels of division, 8. Numbering and contents. Rests on: A (Runs). Proved in: Sections, table of contents and appendices.
Appendices and parts of a book.
\appendixchanges the numbering of what follows; in book, the front matter, the main matter and the back matter have two numberings, and the appendices come before\backmatter.Uses: 7. Levels of division, 5. Page styles. Rests on: D (The class decides). Proved in: Sections, table of contents and appendices.
Segment 3 Cross-references
- Place and name labels.
- Foresee what a reference prints after one or two runs.
- Load hyperref and cleveref in their order.
- Refer with the name and the number, or with the title.
Labels and references.
\labelmarks a place,\refand\pagerefwrite its number and its page, with two runs.Uses: 7. Levels of division. Rests on: A (Runs). Proved in: Cross-references.
Where the label goes. After the command that assigns the number and inside the same environment: after
\section, after\caption; with a prefix that says what it designates.Uses: 11. Labels and references. Rests on: E (What a label records). Proved in: Cross-references.
Links. hyperref turns references, the table of contents and notes into links and sections into bookmarks, and is loaded at the end of the packages.
Uses: 11. Labels and references, 9. Contents and lists. Rests on: B (Preamble and body). Proved in: Cross-references.
References with names. cleveref writes the name and the number, in English “section”, “fig.” and “eq.”, adjustable with options such as
capitaliseandnoabbrevor with\crefname; nameref refers by the title.Uses: 13. Links, 12. Where the label goes. Rests on: E (What a label records), F (Loading order). Proved in: Cross-references.
Segment 4 Long documents
- Choose between
\inputand\includefor each piece. - Predict what
\includeonlypreserves. - Organize the folders and declare the master document.
- Recognize the errors, loud and silent, of divided documents.
The input command.
\inputinserts a file as if its text were written in its place, without breaking the page or creating auxiliary files.Rests on: B (Preamble and body). Proved in: Long documents.
The include command.
\includestarts a new page before and after, writes an auxiliary file of its own for each piece and cannot be nested.Uses: 15. The input command, 7. Levels of division. Rests on: A (Runs). Proved in: Long documents.
Partial compilation.
\includeonlytypesets only the chosen pieces and numbers the others with their auxiliary files, which must come from a complete compilation later than their last change.Uses: 16. The include command, 11. Labels and references. Rests on: A (Runs). Proved in: Long documents.
Folders and master document. A main file at the root, pieces in folders, paths from the main file, simple names, and in Texmaker the main file as master document.
Uses: 16. The include command. Rests on: G (The main file). Proved in: Long documents.
Errors of divided documents. An
\inputwithout a file stops the compilation; an\includewithout a file only records “No file”; a piece with a preamble ends the thesis at its\end{document}.Uses: 16. The include command, 18. Folders and master document. Rests on: G (The main file), B (Preamble and body). Proved in: Long documents.
- Choose between
Segment 5 Macros and a preamble of one’s own
- Define commands with arguments and an optional one.
- Distinguish defining, redefining and providing, and avoid the lost space.
- Define environments of one’s own.
- Gather the preamble into a file or a package.
Commands of one’s own.
\newcommanddefines a command with up to nine arguments, the first optional with its default value; it names a function that recurs.Rests on: C (Content and form). Proved in: Macros and a preamble of one’s own.
Names taken and spaces.
\newcommandrejects an existing name and\renewcommanda nonexistent one; a command without arguments consumes the space that follows it.Uses: 20. Commands of one’s own. Rests on: B (Preamble and body). Proved in: Macros and a preamble of one’s own.
Environments of one’s own.
\newenvironmentdefines an opening and a closing; its arguments exist only in the opening, and\NewDocumentEnvironmentadmits them in the closing too.Uses: 20. Commands of one’s own. Rests on: C (Content and form). Proved in: Macros and a preamble of one’s own.
A preamble of one’s own. The preamble is moved to a file read with
\inputor to a .sty package, which does not impose the class, the language or the position of hyperref.Uses: 20. Commands of one’s own, 21. Names taken and spaces, 15. The input command, 13. Links. Rests on: F (Loading order), C (Content and form). Proved in: Macros and a preamble of one’s own.
Towards mathematics. The chain stops where the architecture is complete and remains to be filled: equations and numbered theorems, which will be referred to with the labels of this unit, are the subject of the next one.
Loading the content…
Completed
Sign in to save your progress