\newcommand 在段落中建立 underfull\hbox (壞度 10000)

\newcommand 在段落中建立 underfull\hbox (壞度 10000)

我有一個包含重複框的 2 列文件。

所以我創建了這些巨集(不要介意顏色和盒子高度):

% -------------------------------------------------------
% 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”)給了我“Undefull \hbox(段落中的壞處10000))”,而純無宏版本渲染時沒有任何抱怨。

使用該巨集會引入此警告。為什麼?我怎樣才能擺脫它?我究竟做錯了什麼?

答案1

我不會批評你所有的程式碼,我只是建議你在這裡閱讀一段時間,向智者學習;-)

關於Undefull \hbox消息,有兩個問題:

  1. 在您的巨集中,您將在第二個小型頁面之後引入一個空格字元。為什麼這是一個問題,我不完全確定,但是註解掉空格會使警告消失(在非巨集範例中的小型頁面後鍵入空格不會產生警告;不要問我......)
  2. \\使用巨集時,您將在in 巨集產生的中斷之後立即開始一個新段落(由空白行引起)\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}

關於我介紹的百分號,請參見行尾百分號有什麼用?

關於使用\\空行與空白行,我找不到一個規範的答案,但是看看這裡

相關內容