相同的错误会导致 TeX 中同一个句子中的空格不同吗?

相同的错误会导致 TeX 中同一个句子中的空格不同吗?

第 29 页TeXbookKnuth 先生展示了同样的句子,但这些句子的单词间距不同。这是什么原因,又该如何理解这里的糟糕之处?

在此处输入图片描述

答案1

它有助于查看源代码

\begindisplay \hbadness10000
\hbox spread-.666667em{The badness of this line is 100.}&
  \quad(very tight)\cr
\hbox spread-.333333em{The badness of this line is 12.}&
  \quad(somewhat tight)\cr
\hbox{The badness of this line is 0.}&
  \quad(perfect)\cr
\hbox spread.5em{The badness of this line is 12.}&
  \quad(somewhat loose)\cr
%\hbox spread 1em{The badness of this line is 100.}&
% \quad(loose)\cr % then "looser"
\hbox spread 1.259921em{The badness of this line is 200.}&
  \quad(loose)\cr
%\hbox spread 1.713em{The badness of this line is 500.}&
% \quad(bad)\cr % then "worse"
\hbox spread 2.155em{The badness of this line is 1000.}&
  \quad(bad)\cr
\hbox spread 3.684em{The badness of this line is 5000.}& % actually 4995!
  \quad(awful)\cr
\enddisplay

Knuth 分别根据公式进行了计算,并手动计算了 badness。可以使用\badness,它始终保留最后构建的框的 badness。

\hbadness10000

\leavevmode\hbox spread-.666667em{The badness of this line is 100.}\quad\the\badness

\leavevmode\hbox spread-.333333em{The badness of this line is 12.}\quad\the\badness

\leavevmode\hbox{The badness of this line is 0.}\quad\the\badness

\leavevmode\hbox spread.5em{The badness of this line is 12.}\quad\the\badness

\leavevmode\hbox spread 1.259921em{The badness of this line is 200.}\quad\the\badness

\leavevmode\hbox spread 2.155em{The badness of this line is 1000.}\quad\the\badness

\leavevmode\hbox spread 3.684em{The badness of this line is 5000.}\quad\the\badness % actually 4995!

\bye

实际上,第一行打印的是 1000000 而不是预测值 100,但原因不同:100000 是一个无法通过公式获得的特殊值,用于表示过满的盒子(您可以在第 12 章的最后读到它)。

在此处输入图片描述

坏度是衡量单词间空间需要拉伸或收缩多少的指标。它始终为非负值。

请注意如何通过指令实现拉伸或收缩spread

相关内容