# How do I make one minipage the same size as another?

I'm writing a LaTeX document into which I want to put two boxes, in a row next to each other, which will contain varying length content.

I want each box to be the same height, and that height needs to be the height necessary to contain the content in the box with the most content, i.e. both boxes should be the height of the taller of the two. Lastly, I want to put a border partway around one of the boxes. The "each box is the same height" comes into play, because I want the border around the box with the border to appear to contain the text in the other, unbordered box.

In a word processor like Word / Pages / etc; I would do this by making a 1 row, 2 column table; where I apply the box border by arbitrarily styling the borders of one of the cells. If you put a lot of content in one cell, the other cell in the row grows to match it.

I've tried to do it in LaTeX and got halfway there. I can get the two boxes, with two minipages. And I can get the box outlined with \newmdenv. What I can't seem to do is, get the two boxes to be the same size with varying length content. If I put "big" content in the box with the border. But if I put "small" content in that box, then it isn't big enough for the top & bottom to appear to "contain" the other box.

\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{mdframed}
\geometry{letterpaper}
\usepackage{lipsum} %used to generate dummy text

\newmdenv[leftline=false]{leftcap}

\title{latextest2.tex}
\author{test}

\begin{document}
\begin{figure}[!h]
\begin{minipage}[t]{0.5\linewidth}
\vspace{12pt}
\lipsum[1]
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[t]{0.5\linewidth}
\vspace{0pt}
\begin{leftcap}
\lipsum[2]
\end{leftcap}
\end{minipage}
\end{figure}
\end{document}


In the code above, the lipsum[1] paragraph is longer than the lipsum[2] paragraph, so that box gets bigger. How can I make both of those minipage boxes the same size? Or alternately, what other approach can I use to get the behaviour of Word's 2 column 1 row table?

UPDATE

Thanks for your answers, Werner and Martin. I was able to get Werner's to work with a little homework. I couldn't quite get Martin'sto work all the way.
Below, I added in Martin's cfbox command that he linked to, and using that I can get he box to go around the minipage in the way that I want, for this particular content. The only problem is, by setting the minipage height explicitly it is not flexible anymore. By this I mean, the box on the right is always the same height as the box on the left. But what I want is for both boxes to be as high as the tallest of the two boxes. So, for example, if I add content to the right box, I want that box to grow. I think what is necessary here is the equivalent of an if/then/else statement for the box heights. Below is an example showing it working as far as putting the boxes around, but breaking as far as not expanding to fit the new sized content.

\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{lipsum} %used to generate dummy text
\usepackage{xcolor}

\makeatletter % Copied this from: http://tex.stackexchange.com/a/55534

\newcommand\cfbox[3][lbrt]{% Copied this from: http://tex.stackexchange.com/a/55534
\begingroup
\leavevmode
\setbox\@tempboxa\hbox{%
\color@begingroup
\kern\fboxsep{#3}\kern\fboxsep
\color@endgroup
}%
\@tempdima\fboxrule
\hbox{%
\hskip-.5\fboxrule
\lower\@tempdima\hbox{%
\vbox{%
\in@{t}{#1}%
\ifin@
{\color{#2}%
\hrule\@height\fboxrule
}%
\fi
\hbox{%
\in@{l}{#1}%
\ifin@
{\color{#2}%
\vrule\@width\fboxrule
}%
\fi
\vbox{%
\vskip\fboxsep
\box\@tempboxa
\vskip\fboxsep}%
\in@{r}{#1}%
\ifin@
{\color{#2}%
\vrule\@width\fboxrule
}%
\fi
}%
\in@{b}{#1}%
\ifin@
{\color{#2}%
\hrule\@height\fboxrule
}%
\fi
}%
}%
\hskip-.5\fboxrule
}%
\endgroup
}

\title{latextest2.tex}
\author{test}

\usepackage{calc}
\newsavebox\mybox
\begin{document}
\begin{lrbox}{\mybox}
\begin{minipage}[t]{0.5\linewidth}
\lipsum[1]
\end{minipage}%
\end{lrbox}%
\usebox\mybox
\hspace{0.5cm}
\cfbox[tbr]{black}{% As suggested by Martin Scharrer at http://tex.stackexchange.com/a/56883
\begin{minipage}[t][\ht\mybox+\dp\mybox]{0.5\linewidth}
\lipsum[2]\par\lipsum[3]
\end{minipage}
}
\end{document}

-
If you don't want to work with the solution of Werner you must work with two save boxes to compare the dimension. – Marco Daniel May 22 '12 at 18:01

You can stick to your "MS Word's 2 column 1 row table" approach:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\begin{figure}[t]
\begin{tabular}{|p{\dimexpr.5\linewidth-2\tabcolsep}|p{\dimexpr.5\linewidth-2\tabcolsep}}
\cline{1-1}
\lipsum[1] & \lipsum[2] \\ \cline{1-1}
\end{tabular}
\end{figure}

\begin{figure}[t]
\begin{tabular}{p{\dimexpr.5\linewidth-2\tabcolsep}|p{\dimexpr.5\linewidth-2\tabcolsep}|}
\cline{2-2}
\lipsum[1] & \lipsum[2] \\ \cline{2-2}
\end{tabular}
\end{figure}
\end{document}


The two figures in the above MWE contains a boxed left and right block, respectively. Since both cells (regardless of content) is set inside a 1 x 2 table, the sizes will expand according to the same rules as in your requirement.

The tabular is constructed with only 2 paragraph columns of width .5\linewidth-2\tabcolsep, which makes it fit inside the text block exactly. \cline draws a horizontal rule across the specified columns.

-
Hi Werner- Thanks for getting back so quickly with an answer! – quietlyconfident May 22 '12 at 11:40
This totally solves the problem of getting the boxes to expand with each other, and I figured out that I can remove the | from before the first p in tabular to remove the one line that I wanted gone. – quietlyconfident May 22 '12 at 11:53

You can set the height of the minipage using its second optional argument. You need to store the first minipage into a savebox in order to get its height.

The framed bar around the content without the left line is a little difficult. However you can use the macro I defined for CSS border-top, border-bottom, border-right LaTeX equivalent for this. E.g. replace the \fbox with \cfbox[brt] or the fbox key with precode=\cfbox[brt]. The mdframed environment doesn't fit to the already minipage-d content.

\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{lipsum} %used to generate dummy text

%\usepackage{mdframed}
%\newmdenv[leftline=false]{leftcap}

\title{latextest2.tex}
\author{test}

\usepackage{calc}
\newsavebox\mybox
\begin{document}
\begin{figure}[!h]% ? figure is only required if you need a \caption or actually want it to float
\begin{lrbox}{\mybox}
\begin{minipage}[t]{0.5\linewidth}
\lipsum[1]
\end{minipage}%
\end{lrbox}%
\usebox\mybox
\hspace{0.5cm}
\begin{minipage}[t][\ht\mybox+\dp\mybox]{0.5\linewidth}
\begin{leftcap}
\lipsum[2]
\end{leftcap}
\end{minipage}
\end{figure}
\end{document}


Note that this can be simplified with the recent version of adjustbox:

\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{mdframed}
\geometry{letterpaper}
\usepackage{lipsum} %used to generate dummy text

\newmdenv[leftline=false]{leftcap}

\title{latextest2.tex}
\author{test}

\newlength\myheight
\begin{document}
\begin{figure}[!h]% ? figure is only required if you need a \caption or actually want it to float
\begin{adjustbox}{minipage=[t]{0.5\linewidth},gstore totalheight=\myheight,margin=\fboxsep+\fboxrule}% margin has same size as a \fbox
\lipsum[1]