错误线何时分为三部分?

错误线何时分为三部分?

通常 TeX 会将错误行分为两部分。但有时会分为三部分。什么时候以及为什么会发生这种情况?请考虑以下示例。如果\hfil删除 final,则顶部仅显示两行,但有\hfil三行。

\headline={\ifnum\pageno=1 \hfil Title\hfil\elsePage\dotfill\the\pageno\hfil\fi}
hello world
\bye

答案1

这是 TeX 的两个配置选项(以及许多其他配置选项)之间相互作用的结果:

  • error_line,“终端错误信息上下文行的宽度”,即错误信息一行中的最大字符数。

  • max_print_line,“输出的最长文本行的宽度”,即换行(通过插入硬换行符)的长度。

通常情况下,TeX 会用两“行”打印错误消息:

  • 第一行最多包含half_error_line字符,假设k打印了字符。

  • 第二“行”包含k空格,后跟最多 个error_line - k字符,因此其总长度以 为界error_line

现在,当error_line≥时会发生一件奇怪的事情max_print_line:当(最多)error_line个字符被打印时(在第二行),我们可以点击max_print_line,然后 TeX 会通过插入换行符来换行!

这可能有点令人困惑(参见下面的示例错误输出),因此在我看来最好设置error_line < max_print_line

原始的tex.web,正如所写,设置error_line = 72max_print_line = 79,并让本地安装来更改这些值。任何使用这些精确值的 TeX 实现都不会出现此问题。

在 TeX Live 中,可以在运行时配置这些内容(texmf.cnf或通过环境变量),这些值在默认的 中都设置为 79 texmf.cnf,导致在第二个错误“行”中恰好打印了 79 个字符时出现空白行。如果max_print_line设置小于error_line,情况会更糟,因为我们会得到像 这样的丑陋输出(您的文件带有max_print_line=73 error_line=79 tex):

! Undefined control sequence.
<inserted text> ... =1 \hfil Title\hfil \elsePage 
                                                  \dotfill \the \pageno \
hfi...
\makeheadline ...{\vbox to8.5\p@ {}\the \headline 
                                                  }\vss }\nointerlineskip

\plainoutput ->\shipout \vbox {\makeheadline 
                                             \pagebody \makefootline }\ad
van...

—— 这里第一对错误行(分布在三条物理行上)\hfil被拆分了,第二对错误行中有一个令人困惑的空白行,而第三对错误行中\ad的一行和van...下一行看起来很神秘。


我认为理想世界中:

  • TeX 会检查这一点error_line < max_print_line,或至少将其记录为期望。我不知道为什么不强制执行。

  • TeX Live 会将其默认值更改为 78 和 79,而不是两者均为 79。

就我个人而言,安装 TeX 后我做的第一件事就是设置

half_error_line=238
error_line=254
max_print_line=1000000

在我的 texmf.cnf 中,这样就不会出现换行,并且错误行尽可能长。


编辑:通过设置max_print_line远小于error_line,我们甚至可以得到(应该是)占据的误差线对物理线路:

% Quotes from DEK
\def\email{Email is a wonderful thing for people whose role in life is to be on top of things. But not for me; my role is to be on the bottom of things. What I do takes long hours of studying and uninterruptible concentration. I try to learn\theory certain areas of computer science exhaustively; then I try to digest that knowledge into a form that is accessible to people who don't have time for such study.}
\def\theory{If you find that you're spending almost all your time on theory, start turning some attention to practical things; it will improve your theories. If you find that you're spending almost all your time on practice, start turning\lp some attention to theoretical things; it will improve your practice.}
\def\lp{Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a comput\err to do. The practitioner....}

\email

\bye

运行

max_print_line=60 half_error_line=238 error_line=254 tex err.tex

要得到:

This is TeX, Version 3.14159265 (TeX Live 2019/Debian) (preloaded format=tex)
(./err.tex
! Undefined control sequence.
\lp ->Let us change our traditional attitude to the construc
tion of programs: Instead of imagining that our main task is
 to instruct a computer what to do, let us concentrate rathe
r on explaining to human beings what we want a comput\err 



                                                          to
 do. The pr...
\theory ...you find that you're spending almost all your tim
e on theory, start turning some attention to practical thing
s; it will improve your theories. If you find that you're sp
ending almost all your time on practice, start turning\lp 



                                                          so
me attentio...
\email ... wonderful thing for people whose role in life is 
to be on top of things. But not for me; my role is to be on 
the bottom of things. What I do takes long hours of studying
 and uninterruptible concentration. I try to learn\theory 



                                                          ce
rtain areas...
l.5 \email

? x
No pages of output.

相关内容