Doubts about the example on page 167 of The TeXbook (Computers & Typesetting A by Donald E. Knuth)

47 Views Asked by At

Page 167 of "The TeXBook", line 5

... $F_n=F_{n-1}+F_{n-2}$, \ $n\ge2$.}$$

I tried to write the omitted part completely, as I understand it should be written:

$${\rm The\ Fibonacci\ numbers\ satisfy\ $F_n=F_{n-1}+F_{n-2}$, \ $n\ge2$.}$$

But the above code can't be compiled under plain TeX (error hint: "Missing } inserted.") Is it not possible to insert $...$ in a $$...$$?

Environment: macOS, TexShop 5.03 (with plain TeX selected), MacTeX 2022

What is the correct way to complete it?

Thanks for your comment.


I found that the following code compiles successfully, but I'm not sure whether this is the author's intention, and I don't quite understand the meaning of using $$...$$ here, is it just for more vertical whitespace?

$$\centerline{The Fibonacci numbers satisfy $F_n=F_{n-1}+F(n-2)$, \ $n\ge2$.}$$
1

There are 1 best solutions below

0
Jasper Habicht On

If you look into the source code of the TeXbook, you will find that this line was typset like this:

\begindisplay
The ^{Fibonacci} numbers satisfy $F_n=F_{n-1}+F_{n-2}$, \ $n\ge2$.
\enddisplay

Indeed, the use of $$ is not a good idea in this case, since this will introduce display math mode, which not only adds some whitespace, but also switches to math mode (just like $ does) and additionally typesets the part between $$ and the next $$ centered on a separate line. Since $$ already introduces math mode, TeX will complain if it encounters a single $.

Now, the above example consists only of a short math part while the rest is non-math. Therefore, not the whole sentence should not be typeset in math mode, but only the math part of it. Hence, the use of $$ would not make much sense here.

I don't know why it is stated on page 167 that the sentence was printed using $$ which is obviously wrong. Maybe it is just a mistake.

As for your last example: If you use \centerline, you essentially step out of math mode. Since the stuff inside the argument of \centerline is not typeset in math mode, another single $ is not a problem here. This is why your example compiles just fine. But it is probably not the best idea to place \centerline inside $$...$$.