避免出现警告“段落中的短语“Underfull \hbox (badness 10000)”是什么意思”,同时保持行距,就像使用 \\

避免出现警告“段落中的短语“Underfull \hbox (badness 10000)”是什么意思”,同时保持行距,就像使用 \\

有很多建议可以避免换行\\,并使用空行转到下一行。我的问题是,我使用的模板充满了警告

段落中的 \hbox 未满(不良率 10000)

别无他法,只能坚持使用模板。警告确实困扰着我,我不想欺骗他们关闭警告。所以我尝试了以下代码中的解决方案,以便 1. 避免警告,2. 获得与模板完全相同的输出。我没有资格发表评论;因此,感谢jlab他的建议,问题已修改。如图所示,没有一种解决方案会导致行之间的垂直间距相同,如下所示。

两个相似代码的垂直间距之间的差异

我该如何解决它?

\documentclass[12pt]{article}
\usepackage[
paperwidth=3.6in,
paperheight=.7in,
margin=.1in,
centering]{geometry}
\usepackage{calc}
\begin{document}
  \noindent
  \begin{minipage}{.48\linewidth}
    This is the first line.\\[-.45cm]
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}
  \begin{minipage}{.48\linewidth}
    This is the first line.

    \vspace*{-\parskip+\baselineskip-.45cm}
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}

  \noindent
  \begin{minipage}{.48\linewidth}
    This is the first line.\\[-.45cm]
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}
  \begin{minipage}{.48\linewidth}
    This is the first line.

    \par\vspace*{\baselineskip}\vspace*{-.45cm}
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}
\end{document}

编辑: 感谢解释了当faces 所做wipet的背景,这激发了我深入研究 的热情。恐怕提供的解决方案不会产生与 相同的输出。可以看出,相邻s 中的 s 不在同一水平。实际上, 强制的垂直间距似乎与 并不完全相同;但我不知道如何计算/考虑这种差异。这里是:LaTeX\\LaTeX\\hruleminipage\\line-spacingMWE

\documentclass[12pt]{article}
\usepackage[
paperwidth=3.6in,
paperheight=.7in,
margin=.1in,
centering]{geometry}
\usepackage{calc}
\begin{document}
  \noindent
  \begin{minipage}{.48\linewidth}
    This is the first line.\\[-.45cm]
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}
  \begin{minipage}{.48\linewidth}
    This is the first line.
    
    \vspace{\dimexpr-\parskip+\baselineskip-.45cm}
    \hrule height 1pt
    \vspace{.5mm}
    \hrule height 2.5pt
    \vspace{1.5mm}
    This is the second line.
  \end{minipage}
\end{document}

答案1

在纯 TeX 中尝试一下:

text of the first paragraph\nobreak\hfil\break\par

next paragraph
\bye

您可以看到 Underfull \hbox 消息,并且在第一个段落后插入了空行。为什么?该\par命令插入了\parfillskip粘连,然后是最后的换行符。但是粘连是可丢弃项,因此在第一个之后将其删除,这样\break就得到了\break\break。TeX 尝试创建具有给定宽度 的空行\hsize,但此处没有可拉伸的粘连。因此,您得到了 Underfull \hbox

现在,从您的 LaTeX 角度来看会发生什么: 扩展\\[-.45cm](粗略地说)为\vadjust{\vskip-.45cm}\nobreak\hfil\break以下\hruleTeX 基元插入\par到输入队列,并且可以再次读取。 因此,您有\vadjust{\vskip-.45cm}\nobreak\hfil\break\par\hrule。 请注意,与上一个示例相同的序列:\nobreak\hfil\break\par。 这会导致 Underfull 消息。

我不知道你的意图是什么。你创建空行,然后使用负垂直空间删除此行所在的空格\vadjust。这似乎过于复杂。

编辑如果您的第一行具有非零深度,即在四个位置the first linethe first gline(例如) 替换文本,则可以看到 (您询问的) 差异。并纠正您对\vspace{-\parskip+\baselineskip-.45cm}by 的错误使用\vspace{\dimexpr-\parskip+\baselineskip-.45cm}。在左列,当您开始垂直空间跳舞时,您位于空白框的底部。在右列,您可以通过添加来补偿空行,\baselineskip但您位于具有非零深度的非空行的底部。因此,您位于比左列更低的位置(差异是非零深度)。

相关内容