TUGboat, Volume 44 (2023), No. 2.

The gods smile at me: The LaTeX Companion, third edition, and ChatGPT

1 Contemplation

The fifth edition of my Math into LaTeX book is still selling well, but it is seven years old (LIT). A lot has changed. All TeX files, BibTeX and MakeIndex files changed from ASCII to UTF-8. Lots of work has been done for references, further developing and enhancing BibTeX. And a lot more …

So I started contemplating a sixth edition, a huge undertaking. For instance, the BibLaTeX manual alone is about 350 pages and I would have to read at least ten like that.

And then the gods smiled at me ….

First smile: The LaTeX Companion, third edition.

Second smile: ChatGPT.

2 The LaTeX Companion, third edition


This is a heavy contribution by Frank Mittelbach (mostly); the two volumes weigh 3.5 Kg and they run to almost 1,800 pages. I complained how much I would have to read for my sixth edition, multiply that by ten, twenty, or more for this. Frank is a voracious reader with an immense knowledge of LaTeX. The book discusses about 500 packages.

It caters to two audiences, the general user, GU (they use LaTeX for their work but cannot read TeX code, like me) and the 1% (they read TeX code and design style files and create packages).

It is hard to tell whether the 1% is 1% of LaTeX users. CTAN has currently about 6,500 packages and 3,000 contributors. We have no hard numbers on the number of research mathematicians who use LaTeX or the number of computer scientists, physicists, chemists, and so on, who also use it. So I will use 1% as a label, not quantified.

The needs of the GU and the 1% are very different. I wrote over 270 research papers, all for mathematical journals, style files supplied by the journals and 31 books, all with custom style files written by the 1%.

Now the content, it starts with Chapter 2, “The Structure of a LaTeX Document”. The first few sections are for the GU, each veering off into topics for the 1%. At least one section, “Splitting the source document into several files”, was made obsolete by the increasing speed of computers. When I started TeXing, it took more than two minutes to typeset a page. Now the whole sixth edition typesets in less than 3 seconds. So the section on how to use the LaTeX commands \include and \includeonly is much more esoteric.

There is little in the 130 pages of Chapter 3, “Basic Formatting Tools—Paragraph Level”, for the GU. It does mention xspace and microtype, so important.

Chapter 4 is “Basic Formatting Tools — Larger Structures”. Another 100 pages that does not have much for the GU. It does discuss modifying the list environments; not many users like how they are spaced.

Chapter 5, “The Layout of the Page”, is full of useful information for the 1%.

Chapter 6, “Tabular Material”, helps the reader to publish nicer-looking tables, the LaTeX default is rather ugly. It mentions the booktabs package I use for all my tables in my LaTeX books.

Chapter 7, “Mastering Floats”, addresses every LaTeX user’s huge problem: the figures and illustrations act up, they are not inserted into the document well. It suggests the use of the \clearpage command. In the sixth edition, I recommend trying to combine two or three floats into one.

“Graphics Generation and Manipulation” is discussed in Chapter 8, including the very important graphicx package of David Carlisle.

Maybe one of the most illuminating parts is Chapter 9, “Font Selection and Encodings”. Everybody can benefit from reading the first five sections, a detailed introduction to the New Font Selection Scheme (NFSS) of Frank Mittelbach and Rainer Schöpf, which revolutionized LaTeX.

This completes Volume 1, and we start the second volume with Chapter 10, “Text and Symbol Fonts”. It is continued in Chapter 12, “Fonts in Formulas”. I am not sure for whom these chapters are meant. They must have been hard to compile, but who will benefit? The exception is the Lucida font, in which the book is typeset. Almost 200 pages of font samples seems a little excessive.

Chapter 11, “Higher Mathematics”, is compulsory reading for all mathematicians. Also for all scientists using formulas. Maybe, “Typesetting Formulas” would have been a better title. College math does not utilize formulas?

Chapter 13, “Localizing Documents”, is also compulsoryreading for all LaTeX users who want to write in a language other than English. There is support for 30 languages, French and German are the best.


Chapter 14 discusses “Index Generation” for books and long documents utilizing MakeIndex. All book authors should read it.

    Chapters 15, “Bibliography Generation” and 16, “Managing Citations” are also must-reads for book authors. The first focuses on BibTeX and the highlight of the second is the section on BibLaTeX, a 45 page summary of a 350 page user manual.

Chapter 17, “LaTeX Package Documentation Tools”, Appendixes A, “LaTeX Overview for Preamble, Package, and Class Writers” and B, “Tracing and Resolving Problems” are, of course for the 1%.

This book is a tour de force by Frank Mittelbach, seven years of intense work. I am not sure that “the Companion would serve as the only reference needed to get ‘the job’ done.” But for sure, no LaTeX user should be without it.

A minor complaint: The Contents is almost 20 pages long, hard to navigate. Maybe a Short Contents would have been helpful.

3 ChatGPT

For a few months now, I have been writing the sixth edition of my book, with a new title, Text and Math into LaTeX. Every day I consult ChatGPT dozens of times. I mostly converse about LaTeX topics but I also check English usage often (and love to write Hungarian poems in the poet Petőfy’s style.)


ChatGPT got a bad rep. Version 3.5 used its pattern recognition and completion abilities to generate references and links, with unfortunate results. I use Version 4.0 which does not have this problem, nor do I ask anything where such a problem would arise.

In the first three editions of my book, I distinguish between LaTeX commands and AMS math commands. I changed that in the fourth edition, to simplify the discussion. So the phrase: “LaTeX does not provide tools to access bold lowercase Greek letters”, changed its meaning from the third to the fourth edition. Is it still true?

So I ask ChatGPT. It responds: use the \bm command provided by the bm package.

I want to refresh my understanding of the command \fontencoding. I ask ChatGPT:

latex fontencoding command, use and examples

The reply:

As of my last training cut-off in September 2021, in LaTeX, the \fontencoding command is used to specify the font encoding scheme. Different font encodings contain different sets of characters. By using a specific encoding, you can access the set of characters that it defines.

For example, the OT1 encoding is the default in LaTeX, and it does not support accented characters. If you use an accented character, then LaTeX will build it by combining the unaccented character and a separate accent character. But this can cause problems in some situations, like hyphenation.

The T1 encoding, which is part of the Cork encoding scheme, supports accented characters directly. It’s often recommended to use T1 for European languages, because it improves the hyphenation of words with accented characters.

Here’s an example:


In this example, the \usepackage[T1]{fontenc} line loads the T1 font encoding. The words in the document are German and include accented characters. The T1 encoding allows LaTeX to handle these characters properly.

It’s worth mentioning that using
\usepackage[T1]{fontenc} changes the font encoding for the entire document. If you want to change the encoding for a specific part of the document only, you can use the \fontencoding command together with \selectfont, like this:


ln this example, the T1 encoding is used only for the German text, and then the encoding is changed back to OT1 for the rest of the document. Note that \fontencoding doesn’t change the font immediately. It only changes the encoding that LaTeX will use the next time it selects a font, which is why \selectfont is needed.

And if you want more related information, ask:

And how about XeLaTeX and LuaTeX

ChatGPT keeps track of all your conversations, so I have hundreds more to share. I trust these two are enough to convince you to try it for yourself.

George Grätzer
University of Manitoba
gratzer (at) mac dot com

$Date: 2023/08/22 01:19:00 $
TUG home page; webmaster; facebook; twitter; mastodon;   (via DuckDuckGo)