解决段落换行问题

解决段落换行问题

我正在处理一个更大的项目,其中的文本我根本无法更改,因此我显然遇到了各种问题,例如水平盒子过满和不足等。因此,我创建了以下宏(当然,使用它假设连字符等已经全部设置好),它应该可以在纯 TeX 和 LaTeX 中工作(因为它非常原始):

\def\emergency #1 #2\par{%
\begingroup
    \ifcase #1
        \message{Emergency level 0 does nothing at all.}%
    \or
        \tolerance = 250
        \message{Emergency level 1: increasing \string\tolerance\space to \the\tolerance.}%
    \or
        \tolerance = 300
        \message{Emergency level 2: increasing \string\tolerance\space to \the\tolerance.}%
    \or
        \tolerance = 300
        \righthyphenmin = 2
        \message{Emergency level 3: increasing \string\tolerance\space to \the\tolerance,
                 decreasing \string\righthyphenmin\space to \the\righthyphenmin.}%
        \message{You might need to set hyphenation properly for this emergency level to work.}%
    \or
        \righthyphenmin = 2
        \emergencystretch = 5pt
        \message{Emergency level 4: increasing \string\emergencystretch\space to \the\emergencystretch,
                 decreasing \string\righthyphenmin\space to \the\righthyphenmin.}%
        \message{You might need to set hyphenation properly for this emergency level to work.}%
    \or
        \righthyphenmin = 2
        \emergencystretch = 8pt
        \message{Emergency level 5: increasing \string\emergencystretch\space to \the\emergencystretch,
                 decreasing \string\righthyphenmin\space to \the\righthyphenmin.}%
        \message{You might need to set hyphenation properly for this emergency level to work.}%
    \else
        \errmessage{Emergency level #1 not supported!}%
    \fi
    #2
    \par
\endgroup
}

这个想法是把它放在一些麻烦的段落的开头,然后尝试从 1 到 5 的级别,如下所示:

...some text of previous paragraph.

\emergency 1 % or 2 or ... or 5
Some naughty paragraph that wouldn't break nicely...

我对这种设置没有太多经验,但我当然会尝试并调整它。但是我有一些时间压力,所以如果有更有经验的人可以看看并提示我这些级别是否间隔足够均匀或者有些是否太粗糙,或者是否应该尝试一些更好的方法或插入更精细的步骤等,我将不胜感激。

谢谢!

相关内容