這可能會很長。
首先,TeX 如何斷行是 TeXbook 中整整一章的內容。基本上有一個 \tolerance(設定為 9000,這非常寬鬆。PlainTeX 將其設定為 200),它決定某種特定的段落斷行方式是否會被考慮。因此,如果將段落減少一行導致 badness > 9000,無論您多麼要求,它都不會減少該段落。增加段落的情況也是如此。TeX 的自然段落長度是選擇來最小化 badness 的。因此,減少或增加段落會使其變差,但這與更好的頁面版面配置相平衡。在 TeX 最小化段落 badness 的情況下,較大的 tolerance 並不壞。它只是說我們真的不希望出現過滿或過空行,謝謝。
根據我們的經驗,TeX 很少允許段落縮排。擁有更多可縮排的間距有助於(間距的預設最小縮排為 66%,因此 95% 實際上使其更不可縮排)。同樣,預設最大伸排為 150%,因此 140% 使其更不可伸排。增加字元間距不太可能對斷行產生太大影響。它可能會,但實際上它所做的只是吸收一些額外的間距伸排,使間距看起來不太醜陋。順帶一提,如果 TeX 斷行了一個非常非常糟糕的行,無論您將最大伸排限制得多低,TeX 都會按比例拉伸所有內容以填滿該行,超出任何最大值。
這部分是數學:9000 的 tolerance 需要除以行數以獲得平均值。假設段落中有 10 行,因此我們得到每行平均 900 的 badness。TeX 計算 badness 為 100x(實際縮排或伸排 / 最大縮排或伸排)^3。這意味著它平均允許一行縮排或伸排最多為該行總量的 2 倍。因此,它可能將間距縮排到其最小值的一半,或伸排到其最大值的兩倍。顯然,這是最壞的情況,而 TeX 總是選擇看起來最好的段落。所以不要擔心一切看起來會比您指定的更糟。在實踐中,效果看起來非常好,並且透過明智地選擇要伸排的段落,可以以未經訓練的眼睛無法察覺的方式解決問題。
為什麼 TeX 不能很好地縮排段落?因為通常一行中間距的最大縮排不足以將整個單詞拉上來,更不用說 2 或 3 個了。這取決於您是否願意讓最小間距降至間距的 40%,這真的不算多。
對於沒有單詞間距的文字系統,關鍵是透過大量插入 ZWSP 字元,為 TeX 提供足夠的斷行位置。
現在關於逐段變更。是的,我們可以逐段更改 glue 段落的值,但我不知道我們如何為其提供 UI。您想做所有這些工作嗎?也許更有意義的方式是創建一個工具,測量所有可能的段落縮排和伸排,並讓您知道實際發生的值範圍。我們本來就有一些關於改進調整清單周圍整個 UI 的想法。
順帶一提,這裡有一個提示。您始終可以增加標題樣式的行數,因為它們不對齊,所以 TeX 會很樂意使這些行越來越短,以便在段落中有更多行。但它们在頁面上也非常顯眼。
您問了!!
This could get long.
First, how TeX breaks paragraphs is a whole chapter in the TeXbook. Basically there is a \tolerance (set to 9000 which is very generous. PlainTeX sets it to 200) that governs whether a particular way of breaking the paragraph is going to be considered. So if reducing the paragraph by a line makes the badness > 9000 it won’t reduce the paragraph however much you ask it. Likewise for increasing the paragraph. TeX’s natural paragraph length is chosen to minimise the badness. So reducing or increasing the paragraph will make it worse, but that’s balanced against a better page layout. A large tolerance isn’t bad given TeX minimises the badness for a paragraph. It just says we really don’t want over or underfull lines thank you.
In our experience, TeX rarely allows a paragraph to reduce. Have more shrinky spaces helps (the default min shrink for a space is 66% so 95% actually makes it less shrinky). Likewise the default max stretch is 150% so 140% makes it less stretchy. Adding intercharacter spacing is unlikely to make much difference to line breaking. It might but really all it does is soak up some extra stretch from the spaces making them less ugly. BTW if TeX breaks a really really bad line, it doesn’t matter how low you limit the max stretch, TeX will just stretch everything in proportion to fill the line overflowing any maxima.
This bit is mathematical: The 9000 tolerance needs to be divided by the number of lines to get an average. Let’s say there are 10 lines in a paragraph, so we get an average of 900 badness per line. TeX calculates badness as 100x(actual shrink or stretch / maximum shrink or stretch)^3. So that means it can allow a line to shrink or stretch on average up to 2 x the total for the line. Thus it might reduce spaces down to half their minimum or stretch them to twice their maximum. Obviously this is a worst case and TeX always chooses the best looking paragraph it can. So don’t worry that everything will look far worse than you specify. In practise, things look really good and by choosing which paragraphs to stretch wisely, one can fix problems in a way that is not obvious to the untrained eye.
Why does TeX not shrink paragraphs well? Because usually the max shrink of the spaces on a line are insufficient to pull a whole word up let alone 2 or 3. It depends if you are willing to let your min space be down at 40% of a space, which really isn’t much.
For scripts that don’t have word spaces then the key is to give plenty of places for TeX to break lines by inserting ZWSP characters liberally.
Now as to per paragraph changes. Yes we could change the values of the glue paragraph by paragraph, but I don’t know how we would provide a UI for that. Would you want to do all that work? Perhaps a more helpful way is to create a tool that measures all the possible paragraph shrinks and stretches and lets you know the range of values that will actually happen. We have some thoughts on improving the whole UI around adjustment lists anyway.
BTW here’s a tip. You can always increase the line count for a heading style since they aren’t justified, so TeX will happily make those lines shorter and shorter to have more of them in a paragraph. But they are also very noticeable on the page.
You did ask!!
機器翻譯自 English