请看下面这段在两端对齐文本中相当糟糕的行:
你可以看到它被截断了,或者至少右侧有多余的空间。这是因为在这个示例中我关闭了字间距。对于本次讨论的目的而言,没有更好的换行位置,因此无处插入额外空间,结果导致行框未填满。但谁会这样做呢?肯定有人会开启字间距。所以让我们开启一点点:0.5%:
真糟糕。这远远超过了 0.5% 的最大拉伸。发生了什么?XeTeX 需要决定如何处理像这样非常糟糕的换行。实际上,它有一个特殊的处理过程,相当于告诉换行器:每行你有额外的 1in 空间(默认通过 \emergencystretch=1in 设置),如果你能基于此实现两端对齐,那就尽管去做。而 0.5% 恰好增加了足够的字符间距,使得所需额外空间低于 1in。现在该行被拉伸,所有紧急拉伸都分配到了这些拉伸中,无论我们可能设置的拉伸最大值是多少,字符间距看起来都非常宽且分散。
这是我们能做到的最好结果吗?那些处理较短“单词”且无需处理缺乏词间断点的人有福了。幸运的是,这段文本标记了断词点,这些断词点会被转换为 ZWSP。ZWSP 被定义为占用字符间距,因此我们可以耍个小聪明:在保持 ZWSP 的字符间距的同时关闭字间距。我们通过添加以下行来实现这一点:
```
\def\intercharspace{\leavevmode\nobreak\hskip\intercharskip}
```
添加到我们的 ptxprint-mods.tex 中(因为关闭字间距会将其从作业 .tex 文件中注释掉)。如果我们再次关闭字间距,会得到什么结果?
嗯,好不了多少,但至少文本是按单词而不是按字素簇断行的。这可能更好,也可能更差。但没有完美的解决方案。这只是在糟糕的情况下尽力而为。
欢迎评论,只要不要说:“那就不要在那里断行!”(这当然是正确的解决方案,但考虑到我们的时间,并不总是可行的)
Consider this rather ghastly line in some fully justified text:
You can see how it has been truncated, or at least there is extra space to the right. This is because I have turned off letter spacing for this example. There is no better line break (for the purposes of this discussion) and so there is nowhere to insert extra space and so we get an under full box. But who would do this. Surely they would turn on letter spacing. So let's turn on a tiny amount: 0.5%:
Yuk. That's way more than 0.5% maximum stretch. What's going on? Well XeTeX needs to decide what to do about spacing a really bad break like this. In fact it has a special pass that in effect says to the line breaker: you have an extra 1in per line (set via \emergencystretch=1in by default) so if you can justify based on that, go for it. And 0.5% adds just enough intercharacter space to get us under needing 1in extra space. Now the line is spread out and all that emergency stretch is distributed among all those stretches, regardless of any maximum we might have set on the stretch, and the intercharacter space looks super wide and spread out.
Is this the best we can do? Consider yourselves blessed all those who work with shorter 'words' and don't have to deal with lack of interword breaks. Thankfully this text is marked with wordbreaks which are turned into ZWSP. ZWSP is defined as taking the intercharacter spacing, so we can be sneaky and turn of letter spacing while still keeping the intercharacter space for ZWSP. We do this by adding the line:
```
\def\intercharspace{\leavevmode\nobreak\hskip\intercharskip}
```
to our ptxprint-mods.tex (since turning off letter spaces comments it out from the job .tex file). Now what do we get if we turn off letter spacing again?
Hmm not much better but at least the text is broken on words rather than grapheme clusters. This may or may not be preferable. But there is no nice solution. This is about making the best of a bad job.
Comments welcome so long as you don't say: don't break there then! (Which of course is the right solution, but may not always be available given the time we have)
机器翻译自 English 显示原文