'I\errorcontextlines=100 \oops' 中的 '\oops' 是什么,它们应该放在 TeX 文件中的什么位置?

'I\errorcontextlines=100 \oops' 中的 '\oops' 是什么,它们应该放在 TeX 文件中的什么位置?

第 34 页底部TeXbook, 有

如果您使用其他人设计的 TEX 格式包,您的错误消息可能会涉及许多难以捉摸的两行宏上下文。通过在文件开头设置 \errorcontextlines=0,您可以减少报告的信息量;TEX 将只显示上下文行的顶部和底部对以及最多 \errorcontextlines 个额外的两行项目。(如果因此省略了任何内容,您还会看到“...”。)即使大部分大上下文都被抑制,您也很有可能发现错误来源;如果没有,您可以说“I\errorcontextlines=100 \oops”并重试。(这通常会给您一个未定义的控制序列错误和大量上下文。)普通 TEX 设置 \errorcontextlines=5。

原始 tex 文件是

\hrule
\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
\hrule
\vfill\eject

由于 的第一个字符I\errorcontextlines=100 \oopsI,所以我猜想应该\input filename在错误显示时输入它。但是\oops这里是什么,为什么要在这里添加它?而且输入后I\errorcontextlines=100 \oops日志文件并不比不输入 包含更多信息I\errorcontextlines=100 \oops

答案1

您在 之后输入的内容I将由 TeX 执行。您在提示符下输入它?。因此,如果您写 I\errorcontextlines=100TeX 执行此任务并继续处理您的文档;可能会在您的文本中显示后续错误。

但是如果您输入I\errorcontextlines=100 \oops并且 if\oops未定义,TeX 会第二次停止,然后才会继续从文档中读取更多内容,因为未定义的控制字会导致错误。因此,您可以看到第一个错误的更多上下文,即您输入的错误,并且 如果显示的上下文为您提供了更多见解,I\errorcontextlines=100 \oops您可以添加更多命令。I

如果您没有看到上下文有任何变化,则 TeX 已将其拥有的所有上下文都提供给了您。但是,例如,如果您有多个嵌套宏,并且最内层包含错误,则您会看到更多上下文。

\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.}

\seven
and another \ERROR.
\bye

相关内容