2

On p.34 of TeXbook it is said:

By setting \errorcontextlines=0 at the beginning of your file, you can reduce the amount of information that is reported; TEX will show only the top and bottom pairs of context lines together with up to \errorcontextlines additional two-line items. (If anything has thereby been omitted, you’ll also see ‘...’.) Chances are good that you can spot the source of an error even when most of a large context has been suppressed; if not, you can say ‘I\errorcontextlines=100\oops’ and try again. (That will usually give you an undefined control sequence error and plenty of context.)

Let's try it by modifying line 3 of story.tex like this:

\errorcontextlines=0 \centerline{\bf A SHORT \ERROR STORY}

TeX stops with this error (one pair of context lines is omitted due to setting of \errorcontextlines):

! Undefined control sequence.
<argument> \bf A SHORT \ERROR 
                              STORY
...
l.3 ...nes=0 \centerline{\bf A SHORT \ERROR STORY}

Now suppose I want to see the omitted pair of context lines. According to above extract from TeXbook I type in response to ?:

I\errorcontextlines=100\oops

But instead of something like this

! Undefined control sequence.
<argument> \bf A SHORT \ERROR 
                              STORY
\centerline #1->\line {\hss #1
                              \hss }
l.3 ...nes=5 \centerline{\bf A SHORT \ERROR STORY}

I get this:

! Undefined control sequence.
<insert>   \errorcontextlines=100\oops

...
l.3 ...nes=0 \centerline{\bf A SHORT \ERROR STORY}

Why I do not get the omitted context by changing \errorcontextlines interactively?

Igor Liferenko
  • 7,063
  • 2
  • 14
  • 47

1 Answers1

4

You seem to have found a bug in The TeXbook: there's a space missing. It works if you enter I\errorcontextlines=100 \oops. That is, after TeX has shown:

(./story.tex
! Undefined control sequence.
<argument> \bf A SHORT \ERROR 
                              STORY
...
l.3 ...nes=0 \centerline{\bf A SHORT \ERROR STORY}
?

you can enter I\errorcontextlines=100 \oops to get:

? I\errorcontextlines=100 \oops
! Undefined control sequence.
<insert>   \errorcontextlines=100 \oops

<argument> \bf A SHORT \ERROR 
                              STORY
\centerline #1->\line {\hss #1
                              \hss }
l.3 ...nes=0 \centerline{\bf A SHORT \ERROR STORY}

? 

The idea is that in the inserted token list (what you typed), TeX has to first read \errorcontextlines=100 (and process it, i.e. perform the assignment), before encountering the \oops and showing an undefined control sequence error again. But with \errorcontextlines=100\oops, it does not stop scanning a number at 100 and tries to expand \oops in case it expands to something starting with a sequence of digits, so the error is different, and more importantly, the error is encountered before the \errorcontextlines= command is processed/acted upon. (So it has no effect.)

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149