Summary
This lesson opens the third unit of the course, devoted to the structure of the document. It explains what the unit is for: to move from the well-typeset text of the previous unit to a long document with an architecture of its own, whose parts are numbered, listed in a table of contents, referred to one another and distributed over several files; it presents its five lessons and the thread that joins them, from the document class and the page to a preamble of one’s own; it specifies what is taken for granted from the previous units; it recalls where the forms of academic documents come from; it states the problem the unit solves, that a document whose cross-references and numbers are written by hand begins to lie as soon as it changes; and it shows that this architecture serves a thesis in physics just as well as one in history.
Learning objectives
- Describe the sequence of contents of the unit and explain what each lesson contributes to the next.
- Recognise what the unit takes for granted from the previous ones and review it if necessary.
- Explain, with an example, why internal cross-references are not written by hand.
- Recognise in the academic genres of different disciplines the structure that the unit teaches how to typeset.
Entry assessment
Before working through the unit, it is worth measuring the starting point. This assessment is a self-assessment: it is not graded, and its only purpose is to guide your study. Its first two questions review what the unit takes for granted from the previous ones; the next ten cover, two by two and in order, the five lessons of the unit. Anyone who has never written a long document should not expect to get them right: every answer, right or wrong, explains the point and names the lesson that deals with it. The same skills are measured again at the end, in the synthesis lesson.
Before starting the unit, measure your starting point. It is a short self-assessment: it is not graded and its result is stored only in your browser.
Question 1From earlier unitsAfter the first compilation of a document, a cross-reference made with
\refappears as two question marks, and the log asks for another run. What is happening?That can happen, but then the undefined reference warning would persist after compiling again; here the log is asking precisely for another run.\refand\labelbelong to the LaTeX kernel and need no package.Deleting it achieves nothing: the next run would write it again and the reference would still be waiting for another.The engine reads the source only once; what it writes to the.auxfile in one run it reads at the beginning of the next. That is why cross-references and the table of contents need at least two.Review: Compiling and fixing errors
Question 2From earlier unitsAn essay marks the titles of works with
\work{…}, defined in the preamble as\newcommand{\work}[1]{\emph{#1}}, instead of writing\textit{…}in each place. What does it gain?Today the result is similar; the gain appears when a style guide changes and the titles have to be told apart from the other italics.Speed does not change appreciably; the advantage is one of maintenance, not of performance.Nothing in the definition takes them to the table of contents; it only fixes their appearance.The command names the function, the title of a work, and its definition fixes the appearance. This is logical markup, and this unit will turn it into a method with a preamble of one’s own.Review: Formatting with meaning
Question 3A student writes a thesis with
\documentclass{article}and divides the text with\chapter{…}. What happens on compiling?The class does not translate a division it does not know: the command does not exist in it.Divisions depend on the class; that is why choosing the class is the first decision about structure.An unknown command produces an error; the engine does not ignore it silently.Each class defines its own divisions:reportandbookhave\chapter;articlebegins at\section. A thesis with chapters is written with a class that has them.Review: Document classes and page layout
Question 4A university requires margins of 2.5 centimetres on A4 paper. What is the appropriate way to set them?
a4paperchooses the paper size; the margins are decided by the class according to its own proportions, not according to the university’s rules.That does not change the margins but shifts the text, and\hspaceat the beginning of a broken line disappears; besides, it would be visual markup in the body.The font size does not change the margins of the page.From a few measurements, geometry computes all the dimensions of the page, so that they are declared once and are consistent with one another.Review: Document classes and page layout
Question 5In a document of class
article,\setcounter{tocdepth}{1}is written before\tableofcontents. What does the table of contents show?The number is a maximum depth, not a single level: the levels up to 1 enter, that is, the sections.The table of contents is empty only in the first compilation, because of the runs;tocdepthdoes not empty it.Numbering is governed by another counter,secnumdepth;tocdepthonly decides what enters the table of contents.tocdepthsets the deepest level that enters the table of contents: inarticle, the section is level 1 and the subsection level 2. The subsections are still numbered in the text; they only disappear from the table of contents.Question 6In a document of class
article, after the command\appendix, two\sectioncommands are written. How are they numbered?\appendixexists precisely to change the numbering; without it, the appendices would be just more sections.Appendices carry a number, in letters, and enter the table of contents.The numbering of appendices in the standard classes uses capital letters.\appendixrestarts the numbering of the sections and changes it to capital letters; inreportandbookit does the same with the chapters.Question 7An author writes
\label{sec:methods}on the line before\section{Methods}, which is Section 2. What number does\ref{sec:methods}print?Proximity in the source is not enough: what counts is the order. Written before, the label does not see the number of Section 2.The label exists and is recorded; after the second run it prints a number, though not the one intended.There is no error; the label goes after the title, not inside it or before it.\labeldoes not know what comes after it: it stores the last number assigned before it, here that of Section 1. That is why it is written immediately after\section{…}.Review: Cross-references
Question 8What changes in a document when the hyperref package is loaded?
The numbering does not change; hyperref turns it into links.The runs are still needed: the links rest on the same data from the auxiliary file.Those names are decided by babel, according to the language; hyperref does not touch them.hyperref changes neither the numbers nor the text: it adds navigation. That is why it is loaded near the end of the preamble, after almost all the packages whose behaviour it modifies.Review: Cross-references
Question 9In the main document of a thesis, what distinguishes
\include{chapter1}from\input{chapter1}?They differ in the page break, in the auxiliary files and in the possibility of compiling only some parts.\inputaccepts any file, in the preamble or in the body.Neither of them modifies the files: both read them when compiling.\includeis designed for chapters: it starts a page, keeps an auxiliary file of its own for each part and allows selection;\inputserves for any piece, even inside a paragraph or in the preamble.Review: Long documents
Question 10The preamble of a thesis contains
\includeonly{chapter3}, and the body includes the five chapters with\include. What does the compilation produce, if the thesis had already been compiled in full before?\includeonlydecides which chapters are typeset; the others do not appear in the PDF.That would happen if the other\includecommands were removed; with\includeonly, the numbering is preserved.The other files are still in place; they are simply not typeset.For each excluded chapter, LaTeX reads the auxiliary file left by its last compilation, so that the numbering remains that of the complete document.Review: Long documents
Question 11A preamble contains
\newcommand{\emph}[1]{\textbf{#1}}. What happens?That is what\renewcommandwould do;\newcommandrefuses to redefine.A name designates a single command; two with the same name cannot coexist.Definitions are executed in the preamble, and a rejected definition is an error.The protection prevents a command of LaTeX or of a package from being replaced by accident. If one really wants to redefine it, one uses\renewcommand, knowing what is lost.Question 12With
\newcommand{\measure}[2]{#1~#2}in the preamble, what does\measure{5}{km}print?#1is the first argument written, the 5, and it comes first in the definition.The tilde is a reserved character: in the definition it acts as an unbreakable space and is not printed.\newcommandaccepts up to nine arguments, numbered from#1to#9.[2]declares two arguments, and#1and#2receive them in order: the number and the unit, joined by a tilde. The command names the function and guarantees that the tilde is never forgotten.
Loading the content…
Completed
Sign in to save your progress