Frank Mittelbach with Ulrike Fischer, The LaTeX Companion, 3rd edition. Addison-Wesley, 2023, two volumes, 944 pp. and 970 pp., hardcover, US$96, ISBN 978-0-13-465894-0 and 978-0-201-36300-5. Electronic edition forthcoming. https://tug.org/l/tlc3
Why would you need another edition of The LaTeX Companion when you can find online guides to just about any available feature, e.g. [4, 5], so easily?
The LaTeX Companion, 3rd edition (TLC3), is not simply a reference manual or recipe book listing solutions to common problems you might encounter using LaTeX. That is not to say that you cannot use it as a reference manual, and many of the examples can be adapted as recipes to solve practical problems. But the real value of TLC3 is that it gives you deep insight into how LaTeX and its various packages work.
TLC3 is published in two parts, each of which is nearly as long as the second edition [3]. Part I, with contributions by Joseph Wright, introduces LaTeX and explains how to structure documents. It focuses almost exclusively on text—Part II discusses mathematics—covering such things as page layout, breaking documents into sections and paragraphs, lists, tabular material, tables of contents, footnotes and endnotes, how to include images and graphics, and floats for tables and figures. It finishes with a detailed chapter on font selection and encodings.
Part II, with contributions by Javier Bezos, Johannes Braams and Joseph Wright, starts with an illustrated guide to the fonts readily available in LaTeX. Then it discusses various packages for typesetting mathematics, followed by a chapter on how to use the various math fonts that are now possible as alternatives to the standard TeX math fonts. It also covers how to use LaTeX for languages other than English, citation and referencing, indexing, before finishing, as did the second edition [3], with a chapter on package documentation and appendices on writing preambles, packages and classes, resolving problems, and finding further resources.
There are many new developments and packages, and substantial improvements on older packages, since the second edition. The most important new developments to know about are default UTF-8 input support, LuaTeX and biber. UTF-8 is particularly important for those of us who use languages other than English. While pdfTeX is still the dominant LaTeX engine, it is worthwhile learning about LuaTeX, if only because it allows you to use OpenType font features like historical ligatures and alternative characters, shown in Figure 1. And biber is a more powerful alternative/successor to BibTeX that, especially notably, can sort correctly in languages that use characters available only in UTF-8.
There are too many new packages to enumerate here. So, I will point out a few that struck me as interesting. The refcheck package is a nice alternative to showkeys for showing the keys generated by \label commands and whether or not they are referenced. The todonotes package is also helpful for drafts: it produces todo notes in the margin. Figure 2 illustrates both.
The microtype package (not new) is for those who find TeX’s text formatting just not perfect enough—for example, it is what allows the hyphens on this review to jut slightly into the margin. It also can avoid rewriting to fix overfull hboxes. It only needs to be loaded to work, like subdepth, a package for better alignment of subscripts in mathematics. There is also an embrac package, for roman parentheses around italic text. The marginnote package is a flexible alternative to \marginpar for those who, like the authors of TLC3, realize that marginal notes are much easier to read than footnotes.1 And the acro package lets you ensure that an acronym is defined at first point of use.
There are numerous improvements in the sciences. I will note two. The diffcoeff package simplifies typesetting of derivatives. For example, the first integral in Figure 2 can now be set with
\int_\Omega f(\mathbf{x})\diffp{\phi}{x_j}
(\mathbf{x})\dl{\mathbf{x}}
instead of
\int_\Omega f(\mathbf{x})
\frac{\partial\phi}{\partial x_j}
(\mathbf{x})\,\mathrm{d}{\mathbf{x}}
to satisfy ISO 80000-2 recommendations. The siunitx
package makes it easier to type scientific units. So,
we can now write \qty{3.6}{\kilogram} to get
(the weight of the two parts in hardcover)
and LaTeX produces both the correct units and
the correct spacing between number and units.
It can also be used in a table like the following,
with numbers aligned at a decimal point for easy
comparison.
median | maximum | ||||
mean | |||||
skewness | |||||
kurtosis |
Chapter 8 of Part I, Graphics Generation and Manipulation, shows substantial changes from TLC2. The discussion on PostScript is much reduced, presumably because it is much less used. Instead, TLC3 now discusses some of the packages that can be used to produce graphics within LaTeX, such as those in Figure 3. This includes a reasonable introduction to tikz. The packages are outlined rather than described in the detail of [1].
One of the biggest areas of development since TLC2 has been in fonts. Chapter 10 of Part II illustrates the huge variety of fonts now available, including handwriting and symbol fonts and fonts that support languages not based on Latin. The focus is on what is either available with a standard LaTeX distribution or is freely available and good quality. But two fonts that require a license are discussed. The first is Lucida, which can be purchased from https://tug.org/lucida. The second is the Cambria font, which many LaTeX users will already have a license for. Both are suitable for both text and mathematics and support languages other than English. Lucida is a family and includes sans serif, handwriting, math (see Figure 4) and even a blackletter font. Chapter 12 discusses the many alternatives to Computer Modern Roman now available for typesetting mathematics and explains how to set them up.
The writing style, if not always elegant, is at least competent, comprehensive and candid. On the few occasions when I found myself going back through a sentence or two trying to work out what was meant, it was hard to tell if I had missed some concept because the explanation could have been better or because the concept was too subtle. The explanations are usually detailed and up-to-date—I had to update my LaTeX installation to the latest available to try out, for example, the \DocumentMetadata command. This command is not yet necessary for most people, but will become important as LaTeX gets better at addressing accessibility for people who cannot read printed text easily. The most important packages are explained in detail. Packages of more niche interest are outlined, with explanations on where to get further advice.
The advice in TLC3 is refreshingly honest about the limitations of LaTeX and the problems you might encounter in using various packages. It notes when there are conflicts between different packages. For example, Chapter 6 (Part I), on tabular material, discusses a range of problems in presenting tables— variations of the tabular environment. These include vertical and horizontal alignment of cells, issues with narrow columns, cells that span more than one row or column, automatic calculation of column widths, tables that are longer than a page, and the difficulty of rearranging the columns of a table and using tables within other environments. It then describes various ways within LaTeX to deal with these problems. It tells you which packages can be used together and which can’t and presents different solutions so that you can make an educated choice. It also points out potential conflicts, for example, in using multi-page tables and floats that (currently) can only be solved manually.
TLC3 indicates potential difficulties clearly by the extensive use of marginal notes in blue. Some are marked with warning signs to indicate potential conflicts or easy misunderstandings, for example, pointing out that [h] does not mean ‘here,’ and [bt] and [tb] have the same effect when placing floats. More often, though, the marginal notes helped me find more quickly the detail I sought. TLC3 also uses a gray background when explaining features specific to X ETeX/LuaTeX or to biber so that you don’t try to use what won’t work with these programs and don’t try to use with them what will only work in pdfTeX or BibTeX.
TeX makes it difficult to produce what is reasonably considered bad typography: random spacing, typewriter apostrophes, small changes in font size, hyphens for dashes. TLC3 explains these issues without being didactic, assuming the reader is intelligent enough to make their own judgment. For example, it includes booktabs among a range of packages for producing table rules, then suggests briefly when booktabs might be preferable.2 It notes underlining, letterspacing and the like are not always desirable before introducing packages that produce these features and explaining what can go wrong. It explains why manual adjustment of line spacing might not work and how setspace can help. It explains why quotation can be a tricky issue, how the csquotes package can help, and later how babel allows you to follow different conventions for different languages. So, TLC3 is worthwhile reading not just to find out how to do something but for its discussion on whether or not what you were thinking of doing is a good idea and what the alternatives are.
One of the most convenient features of the first two editions of The LaTeX Companion were the tables, particularly the tables of symbols whose names you might never guess. TLC3 does not disappoint. The tables are updated. There are more of them, because there are more symbols, fonts and the like now available. There are lists of tables and, at least in the hardcover edition, each part comes with a ribbon marker you can conveniently use to mark your favorite table. There are also many figures that let you, for example, compare fonts when choosing them for your next document. And, of course, the comprehensive index nearly always leads you quickly to what you were looking for.
There were one or two issues I would have liked more discussion of—for example, the koma-script packages and how LaTeX might be used to produce more accessible documents. But every book must set some bounds; the first of these is well documented elsewhere, and the second remains too much work-in-progress.
In summary, then, The LaTeX Companion, 3rd Edition is much more than a how-to guide, recipe book or even reference for LaTeX. It is the kind of book you want to have at hand for your next LaTeX document. When you want to do something but don’t know how, it will show you—and, not just show you. It will treat you as an intelligent reader. It will show you different methods and the issues around them and help you to both develop a better understanding of LaTeX and write better, more beautiful documents.
[1] Michael Goossens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel and Herbert Voß, The LaTeX Graphics Companion, 2nd Edition, Addison-Wesley, 2008.
[2] Anthony Grafton, The Footnote: A Curious History, Faber, 1997.
[3] Frank Mittelbach and Michael Goossens, The LaTeX Companion, 2nd edition, Addison-Wesley, 2004.
[4] Overleaf, Learn LaTeX in 30 minutes. https://overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes
[5] Wikibooks, LaTeX.
https://en.wikibooks.org/wiki/LaTeX
1But, see [2] for why historians won’t be switching to marginal notes any time soon.
2TLC3’s own tables are mostly in booktabs style.