# two subfigures next to each other aligned on top

I'm trying to place a sequence of images of different height in two columns. So far I've found I can use the subfigure environment, which I can use in this way:

\documentclass{article}
\usepackage{caption,subcaption}
\usepackage{graphicx} % demo is just for the example

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{.4\textwidth}
\includegraphics[width=\textwidth]{./pic1}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic2}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic3}
\end{subfigure}
\hspace{-1mm}
\begin{subfigure}[b]{.4\textwidth}
\includegraphics[width=\textwidth]{./pic4}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic5}
\end{subfigure}
\caption{The full caption}
\end{figure}

\end{document}


This gives me a figure where the top of the two columns is not aligned, which is what I would want.

So I need to have this:

Also, the above code works in a separate .tex file but not when I insert it in my document where I want to have it in the end. I get

"Environment subfigure undefined."

I'm using subfloats for all other images there with the package

\usepackage[labelformat=simple]{subfig}

could the problem be that they clash? It would take too much work to move all the old figures to the same subfigure environment, they are all set now.

Alternatively, can the 2-column figure be solved with the subfloat environment?

• subfigure is effectively a minipage, so your question boils down to the question how minipages can be aligned. – TeXnician Aug 7 '17 at 9:18

I have used the subcaption package to get subfigure and subcaption. With the same optional arguments as for minipage the height can be specified for the subfigure box. Here I define \subfigheight so it can easily be changed. Just set to slightly more than the talest stack of pictures (I used \fboxes around the subfigures to see the heights. Then \vfill fills the vertical gaps.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[htb]
\newcommand\subfigheight{80mm}
\centering
\begin{subfigure}[t][\subfigheight][b]{0.4\linewidth}
\includegraphics[width=\linewidth,height=0.3\linewidth]{example-image}
\caption{first}
\vfill
\includegraphics[width=\linewidth,height=0.3\linewidth]{example-image}
\caption{next}
\vfill
\includegraphics[width=\linewidth,height=0.3\linewidth]{example-image}
\caption{last}
\end{subfigure}
\hspace{2em}
\begin{subfigure}[t][\subfigheight][b]{0.4\linewidth}
\includegraphics[width=\linewidth,height=0.5\linewidth]{example-image}
\caption{next}
\vfill
\includegraphics[width=\linewidth,height=0.8\linewidth]{example-image}
\caption{last}
\end{subfigure}
\caption{Overall caption}
\label{fig:Test}
\end{figure}
\lipsum[2]
\end{document}


As TeXnician mentioned, minipage is the answer. You have to use it instead of the subfigure and set the alignment to the top. Additionaly with the graphbox package adjust the alignment of both top images to top:

\documentclass{article}
\usepackage{graphbox}
\usepackage[labelformat=simple]{subfig}

\begin{document}

\begin{figure}
\centering
\begin{minipage}[t]{.4\textwidth}
\includegraphics[align=t,width=\textwidth]{./pic1}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic2}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic3}
\end{minipage}
\hspace{-1mm}
\begin{minipage}[t]{.4\textwidth}
\includegraphics[align=t,width=\textwidth]{./pic4}

\vspace{1mm}

\includegraphics[width=\textwidth]{./pic5}
\end{minipage}
\caption{The full caption}
\end{figure}

\end{document}