[Tex/LaTex] How to get the height of a minipage to set the height of another one

minipage

In the example below, how can I set the height of the 2nd minipage so that it matches the one of the 1st one, such that the images "C" are uniformly distributed vertically to match the composite height of the images "A" and "B"?

Please note:

1) the dissimilar widths of the minipages is an important constraint, and

2) I'm looking for a solution that literally does what the question says; I know the same behavior can be achieved using tabular or other means, but I'm really interested in learning how to determine float sizes and reuse them to size others.

Thanks, Jorge.

Example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure*}[!t]
    \fbox{\noindent
    \begin{minipage}[b]{0.6\linewidth}
        \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-a}}
        \vfill
        \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-b}}
    \end{minipage}}
    \hfill
    \fbox{\noindent
    \begin{minipage}[b]{0.3\linewidth}
        \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}
        \vfill
        \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}
        \vfill
        \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}
    \end{minipage}}
\end{figure*}
\end{document}

Output:
enter image description here

Best Answer

Measure the left box and force the right minipage to have the same height.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\newsavebox{\dontpanicbox}
\newlength{\dontpanicht}

\begin{document}

\begin{figure}[!htp]
\centering

\sbox{\dontpanicbox}{%
  \begin{minipage}[b]{0.6\linewidth}
  \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-a}}

  \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-b}}
  \end{minipage}%
}

\setlength{\dontpanicht}{\ht\dontpanicbox}

\usebox{\dontpanicbox}\hfill
\begin{minipage}[b][\dontpanicht][s]{0.3\linewidth}
  \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}

  \vfill

  \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}

  \vfill

  \subfloat[]{\includegraphics[width=1.0\linewidth]{example-image-c}}
\end{minipage}

\end{figure}

\end{document}

enter image description here

“Much simpler” with \valign. 😉

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}

\begin{figure}[!htp]
\centering

\valign{#\cr
  \hsize=0.6\textwidth
  \subfloat[]{\includegraphics[width=\hsize]{example-image-a}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-b}}\cr
  \noalign{\hfill}
  \hsize=0.3\textwidth
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\cr
}

\end{figure}

\end{document}

Where's the advantage? In that you don't need to know which column is higher. For instance, if the proportions are set to 0.55 and 0.35 instead of 0.6 and 0.3, the right column would become higher, but the same code as above, with just the change in the two parameters

\valign{#\cr
  \hsize=0.55\textwidth
  \subfloat[]{\includegraphics[width=\hsize]{example-image-a}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-b}}\cr
  \noalign{\hfill}
  \hsize=0.35\textwidth
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\vfill
  \subfloat[]{\includegraphics[width=\hsize]{example-image-c}}\cr
}

would produce

enter image description here