At the bottom of page 34 of The TeXbook, there is

If you use TEX format packages designed by others, your error messages may involve many inscrutable two-line levels of macro context. 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.) Plain TEX sets \errorcontextlines=5.

The original tex file is

\vskip 1in
\centerline{\bf A SHORT \ERROR STORY}
\vskip 6pt
\centerline{\sl by A. U. Thor}
\vskip .5cm
Once upon a time, in a distant
   galaxy called \"O\"o\c c,
there lived a computer
named R.~J. Drofnats.

Mr.~Drofnats--- or ``R. J.,'' as
he preferred to be called---% error has been fixed!
was happiest when he was at work
typesetting beautiful documents.
\vskip 1in

As the first character of I\errorcontextlines=100 \oops is I, so I guess it should be entered after \input filename when the error shows. But what is \oops here and why should it be added here? And after input I\errorcontextlines=100 \oops the log file doesn't contain more information than not inputing I\errorcontextlines=100 \oops.

  • \oops is simply a placeholder for the erroneous command. Nov 13, 2023 at 13:01
  • @UlrikeFischer If this control sequence is not defined, why doesn't it cause error?
    – Y. zeng
    Nov 13, 2023 at 13:03
  • You are not using it. Nov 13, 2023 at 13:04

1 Answer 1


What you enter after the I is executed by TeX. You enter it at the ? prompt. So if you write I\errorcontextlines=100 TeX executes this assignment and continues to work on your document; probably showing a follow-on error in your text.

But if you enter I\errorcontextlines=100 \oops and if \oops is undefined TeX stops a second time before it continues to read more from your document as an undefined control word causes an error. So you see more context of the first error, i.e., the error at which you entered I\errorcontextlines=100 \oops and you can add more I commands if the then shown context gives you more insight.

If you do not see any change in the context then TeX has given you all the context it has. But, for example, if you have several nested macros and the innermost contains an error you see more context.

\errorcontextlines=5 \errorstopmode
\def\one{this one has an \ERROR!!!}\def\two{Here we call \one;}
\def\three{and here \two;}\def\four{now call \three;}\def\five{and \four.}
\def\six{Let's try to call \five.}\def\seven{The main macro calls \six.}

and another \ERROR.
  • So, should \errorcontextlines=100 be input not \errorcontextlines=100 \oops? And why did Mr. Knuth add \oops here? With your code, having and not having the I\errorcontextlines=100 will output the same log file.
    – Y. zeng
    Nov 13, 2023 at 13:49
  • 1
    @Y.zeng No, please look carefully. The log files are different as with \oops one more error is reported. It's a trick or technique if you want to fix a text interactively. Of course you must be in \errorstopmode. Nov 13, 2023 at 14:14
  • For what to use \oops to cause another error? It seems there is no need to do that.
    – Y. zeng
    Nov 14, 2023 at 1:50
  • 1
    Have you executed the code with \errorstopmode? It's a significant difference if you enter I\errorcontextlines=100 with or without \oops after TeX stops and shows you the ?-prompt. In the first case you see the next error caused by the last word of the file, the undefined control word \ERROR. In the second case you see the complete context of the error caused by \seven. Nov 14, 2023 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .