小型页面中的文本产生未充满的水平盒子

小型页面中的文本产生未充满的水平盒子

在解决了撰写学士论文期间出现的所有与 LaTeX 相关的问题后,我现在必须解决这个我迄今为止无法解决的问题,我希望大家能帮助我。

每当我在小页面中放入较长的文本时,就会出现大量水平盒子未满的情况。尽管我没有使用有问题的换行符,例如\\\newlines或 之类的换行符。这只是纯文本。经过 3-4 小时,我能够推断出,长单词(我用德语书写)是问题所在。请在下面的文章中亲自查看。第一个小页面编译完美,没有水平盒子未满的情况。第二个小页面给出了 3 个 badbox 警告(水平盒子未满),严重程度各不相同。第三个小页面给出了 9 个(!)水平盒子未满警告,因此试图缓解连字问题反而使情况变得更糟。

有人有想法吗?我正在使用 Texmaker 5.0.3 和 MiKTeX Console 2.9.7076。

这是我的最小工作示例:

\documentclass[11pt,a4paper]{report}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lmodern}

\begin{document}

\begin{minipage}{180pt}
This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. 
\end{minipage}%

\vspace{1cm}

\begin{minipage}{180pt}
This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. 
\end{minipage}%

\vspace{1cm}

\begin{minipage}{180pt}
This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. 
\end{minipage}%

\end{document}

顺便说一下,使用 \blindtext 是可行的(没有未满的水平盒子)。

答案1

首先,加载microtype。它将在你的文档中发挥神奇的作用。

其次,在窄页中排版长单词很棘手。TeX 会尽力为您的段落找到最佳换行方式,但当选项不多时,它会很吃力。窄列中的长单词会减少 TeX 可以拉伸或收缩的单词间空格数,因此更多的拉伸/收缩会应用到更少的空格上,然后坏处就会迅速增加。在这种情况下,您几乎无法避免在您的 Überlangedeutschewörter 中进行一些手动调整 ;-)

一个选项是重写句子的某些部分,以尝试使用更好的换行选项。另一个选项是使用\hfuzz\emergencystretch\tolerance等来让 TeX 停止抱怨。另一个选项是直接忽略。如果文本在视觉上不是很糟糕(糟糕程度通常小于 1000 或 2000),那么警告只是 TeX 挑剔。另一个选项(如果您可以控制的话)是稍微更改您正在排版的框的宽度。在这里,我将最后两个框的宽度更改了2pt(几乎看不出来),所有剩余的警告都消失了。

\documentclass[11pt,a4paper]{report}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lmodern}
\usepackage{microtype}

\begin{document}

\begin{minipage}{180pt}
This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. This is a random example text that I wrote myself, it is only a manual replacement for blindtext. 
\end{minipage}%

\vspace{1cm}

\begin{minipage}{182pt}
This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. This text produces underfull hboxes with long german Dokumentenzulassungsstellenbeamter words. 
\end{minipage}%

\vspace{1cm}

\begin{minipage}{178pt}
This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. This text produces underfull hboxes with long german Dokumenten\-zulassungs\-stellen\-beamter. 
\end{minipage}%

\end{document}

答案2

在窄列中排版会使事情变得棘手,微排版在这里有点困难,但你可以允许 badness 高达(比如说)3000 而不进行注释(1000 是默认值)

运行没有任何警告


\documentclass[11pt,a4paper]{report}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lmodern}
\usepackage{microtype}
\hbadness=3000

\begin{document}

\begin{minipage}{180pt}
  This is a random example text that I wrote myself, it is only a
  manual replacement for blindtext. This is a random example text that
  I wrote myself, it is only a manual replacement for blindtext. This
  is a random example text that I wrote myself, it is only a manual
  replacement for blindtext. This is a random example text that I
  wrote myself, it is only a manual replacement for blindtext.
\end{minipage}%

\vspace{1cm}


\begin{minipage}{180pt}
  This text produces underfull hboxes with long german
  Dokumentenzulassungsstellenbeamter words. This text produces
  underfull hboxes with long german Dokumentenzulassungsstellenbeamter
  words. This text produces underfull hboxes with long german
  Dokumentenzulassungsstellenbeamter words. This text produces
  underfull hboxes with long german Dokumentenzulassungsstellenbeamter
  words.
\end{minipage}%

\vspace{1cm}

\begin{minipage}{180pt}
  This text produces underfull hboxes with long german
  Dokumenten\-zulassungs\-stellen\-beamter. This text produces
  underfull hboxes with long german
  Dokumenten\-zulassungs\-stellen\-beamter. This text produces
  underfull hboxes with long german
  Dokumenten\-zulassungs\-stellen\-beamter. This text produces
  underfull hboxes with long german
  Dokumenten\-zulassungs\-stellen\-beamter.
\end{minipage}%

\end{document}

但请注意,hbadness 只会影响警告级别,它并不会真正改变排版。但是 3000 允许这些情况通过,同时仍然捕捉到只有两个小单词和中间一个巨大的拉伸空间的非常粗糙的行。

这里的设置特别困难,因为你使用的是德语连字规则,但一半的单词是英语,而且第一行必然不够满。通过选择在长段落中换行的位置,TeX 具有很大的灵活性,可以避免过度拉伸空间,但第一行基本上没有灵活性。它以假单词 hboxes 结尾,这违反了任何连字规则,整个单词不适合这一行,因此唯一可能的换行是在第一行的 hbo-/xes 处,即使使用微类型,该行也会过度拉伸空间,从而产生

Underfull \hbox (badness 1394) in paragraph at lines 25--32

拉伸量是唯一的可能性(除非您重写文本),因此唯一的可能性是进一步增加允许的拉伸量,以便将该量计算为较低的不良度,或者正如我在这里建议的那样接受更高水平的不良度,既不会改变实际输出。

相关内容