Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a 2-column document with repeating boxes.

So I created these macros (don't mind the colors and boxheight):

% -------------------------------------------------------
% 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}
}

When use these macros in my document like this:

\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}

The first box ("FIRSTBOX") gives me "Undefull \hbox (badness 10000) in paragraph)" whereas the pure macro-less version renders without any complains.

Utilizing the macro introduces this warning. Why? How can I get rid of it? What am I doing wrong?

share|improve this question
    
Your example code should contain everything neccessary to compile the example without errors. Several packages and color definitions are missing here. –  Stephan Lehmke Aug 27 '12 at 9:08
1  
Why do you use multicols if you only want to align two boxes (minipages) side by side? –  Ulrike Fischer Aug 27 '12 at 10:42
add comment

1 Answer

I won't go criticizing all of your code, I can just advise you to read here for some time to learn from the wise men and women ;-)

Concerning the Undefull \hbox messages, there are two issues:

  1. In your macro, you are introducing a space character after the second minipage. Why this is a problem I'm not completely sure, but commenting out the space makes the warning go away (typing space after the minipage in the non-macro example doesn't produce a warning; don't ask me...)
  2. When using your macro, you are starting a new paragraph (caused by the empty line) immediately after the break produced by the \\ in macro \aitparagraph, causing the second warning.

Hence, the minimal changes neccessary to make both warnings go away are:

% -------------------------------------------------------
% 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}

Concerning the percent sign I introduced, see What is the use of percent signs at the end of lines?.

Concerning the use of \\ versus empty lines, I couldn't find a single canonical answer, but look here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.