# Boxes with equal height

I am looking for a simple way to make the following boxes the same height.

\documentclass{article}

\setlength{\parindent}{0pt}

\begin{document}

\fbox{\hbox to 0.3\linewidth{\vbox{test}}}%
\hfill
\fbox{\hbox to 0.3\linewidth{\vbox{test\par{}test\par{}test}}}%
\hfill
\fbox{\hbox to 0.3\linewidth{\vbox{test\par{}test}}}

\end{document}


I have experimented with calculating the maximum of the heights of the boxes and setting them with the settobox package but I am wondering whether there might be a simpler way. Please note that I do not know the height of any of the boxes beforehand and that I am looking for a method that also scales when there are more than three boxes.

• You do know \fbox{\hbox to 0.3\linewidth{\vbox{\phantom{test}\par{}test\par{}test}}}? Would this be enough? – LaRiFaRi Aug 5 '14 at 11:56

\documentclass{article}
\begin{document}
\fbox{\parbox[b][2.5\baselineskip]{0.3\linewidth}{test}}
\fbox{\parbox[b][2.5\baselineskip]{0.3\linewidth}{test\par{}test\par{}test}}
\fbox{\parbox[b][2.5\baselineskip]{0.3\linewidth}{test\par{}test}}
\end{document}


\parbox[<vpos>][<height>]{<width>}{<contents>}

or for a variable height which needs a test:

\documentclass{article}
\newsavebox\VBox
\begin{document}
\savebox\VBox{\parbox{0.3\linewidth}{test\par test\par test\par}}

\noindent
\fbox{\parbox[b][\dimexpr\ht\VBox+\dp\VBox]{0.3\linewidth}{test}}
\fbox{\parbox[b][\dimexpr\ht\VBox+\dp\VBox]{0.3\linewidth}{test\par test\par test}}
\fbox{\parbox[b][\dimexpr\ht\VBox+\dp\VBox]{0.3\linewidth}{test\par test}}

\end{document}

• I do not know the height of the content of a box. If I am not mistaken this assumes the knowledge of the height. – Jan Christiansen Aug 5 '14 at 14:24
• ok, I see. I edited my answer. It needs a box for the highest entry. – user2478 Aug 5 '14 at 14:40
• So, if I don't know the largest box I have to save all three boxes and calculate the maximum of the three dimensions, is that correct? – Jan Christiansen Aug 5 '14 at 16:38
• yes, that is true. – user2478 Aug 5 '14 at 17:45

This could be a another job for tcolorbox, if you like. Its option equal height group allows to set a group of boxes to the same height. The example code below produces a new kind of \fbox called \mybox here. It has an optional parameter to specify another equal height group, if you have several ones.

My example is specific, of course, but the option can be used for any number of boxes and does not need xparse which I used for the example. The current version 3.12 (2014/07/29) describes the option on page 42 of the documentation.

Note: The example has to be compiled twice.

\documentclass{article}

\usepackage[xparse]{tcolorbox}
\usepackage{lipsum}
\setlength{\parindent}{0pt}

\begin{document}

\NewTotalTColorBox{\mybox}{ O{once} +m }{size=fbox,sharp corners,
colframe=blue!50!black,colback=yellow!10!white,
width=0.3\linewidth,nobeforeafter,equal height group=#1}{#2}

\mybox{test}%
\hfill
\mybox{test\par{}test\par{}test}%
\hfill
\mybox{test\par{}test}\par

\bigskip

{
\footnotesize
\mybox[other]{\lipsum[1]}%
\hfill
\mybox[other]{\lipsum[2]}%
\hfill
\mybox[other]{\lipsum[3]}\par
}

\end{document}


• I probably should have mentioned that I am looking for a replacement of tcolorbox : ) I am currently using tcolorbox and I really like the equal height group option but I am having trouble with rendering speed. Therefore, I am looking for a very basic replacement to check whether it would improve rendering speed. – Jan Christiansen Aug 5 '14 at 14:22
• @JanChristiansen I see. If rendering speed is an important factor, then a basic replacement could help much :-) – Thomas F. Sturm Aug 5 '14 at 15:30
• Although I would go with this "high-level" solution if possible, I picked the other answer because it pointed me into the right direction to improve my rendering performance. – Jan Christiansen Aug 7 '14 at 12:06