Summary
This lesson closes the first unit of the course, devoted to the first steps with LaTeX. It rebuilds the chain of concepts and procedures that runs from typesetting to debugging a document, pointing out at each link which principle is used and in which lesson it is established; it places what has been achieved within the plan of the course and specifies which questions, barely touched upon, 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 the tools of several of them to diagnose documents that fail or to plan one from a description.
Learning objectives
- Rebuild the order of the concepts and procedures of the unit, identifying the principle on which each one rests.
- Explain how the rules for reading the source, its anatomy and the messages of the log are related.
- Distinguish what the unit established from what it only anticipated and the following units will develop.
- Diagnose documents that fail for several reasons at once, ordering the corrections according to the log.
- Plan the preamble and the body of a document from a description of what it must contain.
What the unit achieved
The unit set out to bring someone who had never used LaTeX to the point of writing, compiling and correcting a short document unaided. The purpose has been fulfilled with a single proviso, declared from the introduction onwards: the handling of files and folders on a computer has been taken for granted. With that, the path travelled can be read as a single chain in four stretches, in which each concept or procedure rests on the ones before.
What LaTeX is
The lesson What LaTeX is started from typesetting, the set of decisions that place each letter, each line and each page, and from the particular demands of academic texts. From them it deduced the advantage of a markup language, in which the author declares what each thing is and the document class decides how it looks: the separation of content and form, which reappears throughout the unit. It then distinguished the three engines and chose LuaLaTeX, which reads Unicode and loads the system's typefaces; it fixed the three rules by which the engine reads the source (repeated spaces count as one, a blank line ends the paragraph and the percent sign starts a comment), and it described the cycle of writing, compiling and reading, with the log and the auxiliary file that each compilation leaves behind.
The working environment
The lesson on the working environment turned that description into an installation: a distribution, TeX Live, MiKTeX or MacTeX, with its package manager; Texmaker, configured to compile with LuaLaTeX, to save in UTF-8 and to synchronize the source with the PDF; and Overleaf, whose default compiler must be changed in each project. It also established the rule of one folder per project, the distinction between what the author writes and what compilation regenerates, and the three reasons why a PDF may not change: a serious error that prevents it from being written, a viewer that locks it or does not reload it, and the compilation of another file.
Anatomy of a document
The lesson on the anatomy of a document explained piece by piece what the minimal document had offered as a recipe. The preamble configures and the body typesets, because on reaching \begin{document} the configuration is closed. Commands divide into control words, whose name ends at the first character that is not a letter and which consume the following space, and control symbols, which do not; they take mandatory arguments in braces and optional ones in square brackets, and some have a starred form. Declarations hold until the end of the group that contains them, and environments, which are groups, must be closed in the reverse order of their opening. The ten reserved characters do something instead of being printed, and each has its own way of being printed. Packages and the class, with their options, complete the structure.
Compiling and correcting errors
The lesson on compiling and correcting errors brought all of the above together. It explained that the engine works in passes, so that references and the table of contents are completed in the following pass, and that latexmk repeats the passes on its own; it taught how to read an error by its exclamation line, its line number and the break that separates what had been read from what was still to be read; it distinguished errors, which are always corrected, from warnings and from box messages; it associated the most frequent messages with their causes, which are almost always breaches of the anatomy of the source; and it proposed a strategy: read the first error first, divide the source in halves, reduce the problem to a minimal example, clean the auxiliary files and search for the message.
The following figure gathers the four stretches into a single chain. Each node of the column is a concept or a procedure, numbered according to the order in which they rest on one another and joined by an arc to the earlier links it uses; around them float the supports, that is, the principles to which the chain turns again and again, each joined by a solid line to the links that rest on it and by a dotted one to the link where it is established, except the one that is taken for granted without study, which is drawn as a ring. 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
- AFiles and folders. The ordinary handling of files and folders on a computer: creating them, naming them, finding them, copying them and telling them apart by their extension. It is taken for granted from the introduction. Admitted without proof in this unit.
- BContent and form. The author declares what each thing is, and the document class and the preamble decide how it looks. Established in: 2. Markup language.
- CUnicode and typefaces. LuaLaTeX reads the source as Unicode, saved in UTF-8, and loads the system's typefaces; a character that the typeface does not contain does not stop compilation, but is missing from the PDF. Established in: 3. Engines and LuaLaTeX.
- DThe log. Each compilation records in the log file what it did, with its errors and warnings; it is the first thing to read when something fails. Established in: 5. Source, compilation and PDF.
- EGroups and scope. A declaration holds until the end of the group that contains it; braces and environments open groups that must be closed in the reverse order of their opening. Established in: 12. Groups and environments.
- FReserved characters. Ten characters do something instead of being printed; written as they stand in the text, they produce an error or an unnoticed effect. Established in: 13. Reserved characters.
- GThe first error. To recover from an error the engine guesses, and its guesses may produce new errors; only the first one certainly corresponds to the source. Established in: 16. Reading an error.
Segment 1 What LaTeX is
- Explain what typesetting is and why academic texts demand it.
- Separate content from form by means of a markup language.
- Choose the engine according to the languages, the scripts and the typefaces, and justify LuaLaTeX.
- Predict what a source produces according to the rules for spaces, paragraphs and comments.
Typesetting. To typeset is to decide where each letter falls, where each line ends and where each page breaks; academic texts, with formulas, cross-references, notes and several languages, demand it to a greater degree.
Proved in: What LaTeX is.
Markup language. In LaTeX, a set of macros written on top of TeX, the author marks up the content in a plain text file, and the form follows from the class and the preamble.
Uses: 1. Typesetting. Proved in: What LaTeX is.
Engines and LuaLaTeX. pdfLaTeX, XeLaTeX and LuaLaTeX understand the same LaTeX, but only the last two read Unicode and load the system's typefaces; the course uses LuaLaTeX.
Uses: 2. Markup language. Proved in: What LaTeX is.
Spaces, paragraphs and comments. Several spaces count as one and a line break counts as a space; a blank line ends the paragraph; the percent sign turns the rest of the line, with its line break, into a comment.
Uses: 2. Markup language. Proved in: What LaTeX is.
Source, compilation and PDF. The source is written, the engine compiles it and the PDF is read; next to it remain the log and the auxiliary file.
Uses: 3. Engines and LuaLaTeX. Rests on: A (Files and folders). Proved in: What LaTeX is.
Segment 2 The working environment
- Choose a distribution and a type of installation according to the system, the space and the connection.
- Configure Texmaker and Overleaf to compile with LuaLaTeX.
- Organize each project in its folder and decide which files are kept.
- Explain why a PDF may not change after a correction.
Distribution and packages. A distribution gathers the engines, the packages, the typefaces and a manager that installs what is missing: TeX Live, MiKTeX or MacTeX, full or basic.
Uses: 3. Engines and LuaLaTeX. Rests on: A (Files and folders). Proved in: The working environment.
Texmaker and Overleaf. Texmaker is configured to compile with LuaLaTeX, to save in UTF-8 and to synchronize the source with the PDF; on Overleaf, LuaLaTeX is chosen in each project.
Uses: 5. Source, compilation and PDF, 6. Distribution and packages. Rests on: C (Unicode and typefaces). Proved in: The working environment.
Folder and auxiliary files. Each document has its folder; what the author wrote or supplied is kept, and the auxiliary files, which compilation regenerates, can be deleted.
Uses: 5. Source, compilation and PDF, 7. Texmaker and Overleaf. Rests on: A (Files and folders). Proved in: The working environment.
The PDF that does not change. If the PDF does not change, either compilation did not write it, or the viewer locks it or does not reload it, or another file was compiled; the log and the time of the PDF decide which.
Uses: 8. Folder and auxiliary files, 7. Texmaker and Overleaf. Rests on: D (The log). Proved in: The working environment.
Segment 3 Anatomy of a document
- Distinguish the preamble from the body and decide where each command goes.
- Recognize the parts of a command and predict where its name ends.
- Predict the scope of declarations and nest environments correctly.
- Print the ten reserved characters and explain what they do unprotected.
Preamble and body. The preamble loads packages and makes decisions without typesetting anything; the body is the only place where typesetting happens; what only defines or stores may go in either, and is best placed in the preamble.
Uses: 5. Source, compilation and PDF. Rests on: B (Content and form). Proved in: Anatomy of a document.
Commands. A control word ends at the first character that is not a letter and consumes the following space; a control symbol has a single character and does not consume it; arguments go in braces or in square brackets.
Uses: 4. Spaces, paragraphs and comments. Proved in: Anatomy of a document.
Groups and environments. A declaration holds until the end of its group; environments are groups, and one opened inside another is closed before it.
Uses: 11. Commands. Rests on: B (Content and form). Proved in: Anatomy of a document.
Reserved characters. The backslash, the braces, the percent sign, the dollar sign, the ampersand, the hash, the underscore, the caret and the tilde do something instead of being printed, and each is printed in its own way.
Uses: 11. Commands, 4. Spaces, paragraphs and comments. Proved in: Anatomy of a document.
Packages and class. Packages extend what LaTeX can do and are loaded only in the preamble; the class, with its options, fixes the general form of the document.
Uses: 10. Preamble and body, 6. Distribution and packages. Rests on: B (Content and form). Proved in: Anatomy of a document.
Segment 4 Compiling and correcting errors
- Explain why references and the table of contents need another pass, and compile with latexmk.
- Read an error in the log: its message, its line and the point of detection.
- Relate the most frequent errors to their probable causes.
- Locate the real cause of an error with an orderly strategy, and decide which warnings to heed.
Passes and latexmk. In each pass the engine records in the auxiliary files numbers and titles that the following pass uses; latexmk repeats the passes until nothing changes.
Uses: 8. Folder and auxiliary files. Rests on: D (The log). Proved in: Compiling and fixing errors.
Reading an error. An error is recognized by its exclamation line; the line beginning with l. gives the number of the line of the source, split into what had been read and what was still to be read.
Uses: 9. The PDF that does not change, 11. Commands. Rests on: D (The log). Proved in: Compiling and fixing errors.
Frequent errors. Undefined commands or environments, formulas not opened, braces that do not match, missing files and text in the preamble: each message betrays the breach of a rule of the anatomy of the source.
Uses: 16. Reading an error, 10. Preamble and body, 12. Groups and environments, 13. Reserved characters, 14. Packages and class. Rests on: E (Groups and scope), F (Reserved characters). Proved in: Compiling and fixing errors.
Debugging strategy. Read the first error, divide the body in halves without cutting groups or environments, reduce to a minimal example, clean the auxiliary files and search for the message.
Uses: 17. Frequent errors, 4. Spaces, paragraphs and comments, 8. Folder and auxiliary files. Rests on: D (The log), E (Groups and scope), G (The first error). Proved in: Compiling and fixing errors.
Warnings. Warnings do not stop compilation, but some demand action: undefined references, requests to compile again, lines that stick out and missing characters.
Uses: 15. Passes and latexmk, 16. Reading an error. Rests on: C (Unicode and typefaces), D (The log). Proved in: Compiling and fixing errors.
Towards the text. The chain stops where the minimal document is no longer enough: the text itself, with its languages, scripts, notes and quotations, is the subject of the next unit.
Loading the content…
Completed
Sign in to save your progress