小型页面内的连字符以警告结尾

小型页面内的连字符以警告结尾

我正在排版一个包含两列不同宽度的文档。我决定使用两个宽度相同的小页面,但每次单词连字符时,LaTeX 都会发出 badbox 警告。有人知道如何消除该警告吗?它不会影响文档的视觉输出,因为它是正确的,但很烦人。

这是一个获取错误的最小示例。

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

答案1

首先,这些是警告,而不是错误。所以,你真的不必去掉它们。有一些这样的警告是可以的。LaTeX 给出这些警告的原因是第一个小页面的宽度非常小,无法包含漂亮的连字符,并且迫使程序在单词之间留出很大的间隙(如果与它们的长度相比)。

在您的文本中,您提到在第二列中您遇到了同样的问题(而我的回答无法解释这样的问题,因为第二列更大)。但是,如果您确实将文本复制到那里并粘贴几次以扩展段落,您会发现那里没有这样的警告:

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want.   In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

解决此类问题的方法,是减小小列的字体大小,这样单词的长度就会变小,出现难看间隙的可能性也会降低。下一个示例(\small在第一列添加命令)不会出现此类警告,而且看起来更美观:

\documentclass{article}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth} \small
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want.   In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

PS:如果您希望各列之间保持一致,可以将第二列缩小。

答案2

问题不在于单词是否带连字符,而在于连字符不够多,无法避免由于线宽太小而导致的框未满。

框未满意味着一行中的内容不够,导致单词之间的间距太大。

如果你使用 LaTeX(与 XeLaTeX 或 LuaLaTeX 相反),你可以使用microtype包裹以改善间距。据我所知,它可以操纵每个单词的单个字符之间的间距。

\documentclass{article}

\usepackage{microtype}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}
\noindent
\begin{minipage}{0.25\linewidth}
  This is a minimal script to get the error, you will see that every time needs to hyphen, it returns a badbox error. It can be seen more easily with long words like, genoma virtually generator firefighters
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
  In this `column' is the same, you can prove it if you want
\end{minipage}
\end{document}

在此处输入图片描述


虽然它\usepackage[T1]{fontenc}具有允许对包含变音符号的单词进行连字符连接以及从生成的 PDF 中复制变音符号的积极作用,但它也有负面影响:

  • 字体质量(有点像素化,可读性较差)
  • 连字符可以不是从结果 pdf 中复制
  • 不是使用微缩印刷技术

所有这些负面影响都可以通过加载lmodern包来消除。

相关内容