\newcommand 在段落中创建 underfull\hbox (badness 10000)

\newcommand 在段落中创建 underfull\hbox (badness 10000)

我有一个带有重复框的两列文档。

所以我创建了这些宏(不要介意颜色和框高度):

% -------------------------------------------------------
% aitparagraph
%
% gives header and content with proper size and color
% for an arbitrary box
%
\newcommand{\aitparagraph}[2]{
    \vspace{0.5cm}
    {\Large \bf \textcolor{AITred}{#1}} \\[10pt] {#2}
}


% -------------------------------------------------------
% aitbox
%
% a single box 
%
\newcommand{\aitbox}[2]{
    \begin{minipage}[t]{\hsize}
        \fcolorbox{AITgray}{white}{
            \begin{minipage}[t]{0.92 \hsize}
                \vbox to \the\boxheight{
                    \aitparagraph{#1}{#2}
                    \vfill
                }
             \end{minipage}
        }
    \end{minipage}
}

当在我的文档中使用这些宏时,如下所示:

\begin{multicols}{2}

\aitbox{FIRSTBOX}{

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue euneque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. 

}

\columnbreak

\begin{minipage}[t]{\hsize}
    \fcolorbox{AITgray}{white}{
        \begin{minipage}[t]{0.92 \hsize}
            \vbox to \the\boxheight{
                \aitparagraph{SECOND}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue euneque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.}
                \vfill
            }
         \end{minipage}
    }
\end{minipage}

\end{multicols}

第一个框(“FIRSTBOX”)给我“段落中未充满 \hbox(不良程度 10000)”而纯无宏版本呈现时没有任何抱怨。

使用宏会引发此警告。为什么?我该如何摆脱它?我做错了什么?

答案1

我不会去批评你们所有的代码,我只是建议你们在这里阅读一段时间,向聪明的人学习;-)

关于这些Undefull \hbox信息,有两个问题:

  1. 在您的宏中,您在第二个小页面后引入了一个空格字符。我不太清楚为什么这是一个问题,但注释掉空格会使警告消失(在非宏示例中的小页面后输入空格不会产生警告;不要问我……)
  2. 使用宏时,您会在\\宏产生的断行之后立即开始一个新段落(由空行引起) \aitparagraph,从而导致第二次警告。

因此,消除这两个警告所需的最小改变是:

% -------------------------------------------------------
% aitparagraph
%
% gives header and content with proper size and color
% for an arbitrary box
%
\newcommand{\aitparagraph}[2]{
    \vspace{0.5cm}
    {\Large \bf \textcolor{red}{#1}} \\[10pt] {#2}
}


% -------------------------------------------------------
% aitbox
%
% a single box 
%
\newcommand{\aitbox}[2]{
    \begin{minipage}[t]{\hsize}
        \fcolorbox{green}{white}{
            \begin{minipage}[t]{0.92 \hsize}
                \vbox{
                    \aitparagraph{#1}{#2}
                    \vfill
                }
             \end{minipage}
        }
    \end{minipage}%
}

\begin{document}

\begin{multicols}{2}

\aitbox{FIRSTBOX}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue euneque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.

}

\columnbreak

\begin{minipage}[t]{\hsize}
    \fcolorbox{green}{white}{
        \begin{minipage}[t]{0.92 \hsize}
            \vbox{
                \aitparagraph{SECOND}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue euneque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.}
                \vfill
            }
         \end{minipage}
    }
\end{minipage} 

\end{multicols}

关于我引入的百分号,请参阅行末的百分号有什么用?

关于使用\\与空行,我找不到一个规范的答案,但是看看这里

相关内容