3
$ latex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=latex)
 restricted \write18 enabled.
**\s666666
entering extended mode
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
! Undefined control sequence.
<*> \s
      666666
? 2
<*> \s66
        6666
?

In the example above, what did typing a 2 do? Why it picked two characters from undefined control sequence?

潇洒张
  • 491

1 Answers1

10

TeX error context lines always comes in pairs. In the error message:

! Undefined control sequence.
<*> \s
      666666
?

the first line (the one that ends with the \s) shows you what TeX saw when it found the undefined control sequence: \s, so that is the control sequence, and not \s666666 (because numbers usually don't make control sequence names: only letters).

Now about the 2 you typed in: suppose, instead, you had typed ?, TeX would tell you what to do:

phelype@phelype ~> tex
This is TeX, Version 3.14159265 (TeX Live 2020) (preloaded format=tex)
**\s666666
! Undefined control sequence.
<*> \s
      666666
? ?
Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, 
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
?

When you type a number 1 to 9, TeX will ignore the next 1 to 9 tokens. So when you typed 2, TeX ignored two of the 6 you had input. In fact, if I type 2, as you did, in the prompt above:

? 2
<*> \s66
        6666
?

TeX will do as promised and ignore the next two tokens (remember that what TeX already processed is in the first line (\s66) and the rest in the line below), and wait for input once again. If I hit <return> here, TeX will resume processing the rest of the input (6666), and prompt you with *, at which point you can type \bye and TeX will finish its job and the resulting .dvi file will have only 6666 written:

enter image description here

Note: I used tex in the example to avoid LaTeX's Missing \begin{document} error, but the same principle applies.