[Tex/LaTex] horizontal and vertical image alignment with subfigure package

horizontal alignmentsubfloatsvertical alignment

I have 5 images : A,B,C,D and E, all are different size. They need to be set up like this:

------- ----------- ------- -------
|     | |         | |     | |  D  |
|     | |         | |     | -------
|  A  | |     B   | |  C  | 
|     | |         | |     | -------
|     | |         | |     | |  E  |
------- ----------- ------- -------

How do I set this up with the subcaption\subfigure package in latex? I have managed to get A,B,C working like this:

\centering
    \begin{subfigure}[t]{0.246\textwidth}
            \centering
            \includegraphics[height=0.18\textheight]{tease5_a.jpg}
    \end{subfigure}%
    \centering
    \begin{subfigure}[t]{0.18\textwidth}
            \centering
            \includegraphics[height=0.18\textheight]{tease5_b.jpg}
    \end{subfigure}%        
    \centering
    \begin{subfigure}[t]{0.18\textwidth}
            \centering
            \includegraphics[height=0.18\textheight]{tease5_c.jpg}
    \end{subfigure}%

.. which is pretty much a constant height for all images, but different width allocations for each, as otherwise I have too much extra space or overlaps. But how do I set it up so that the last 2 images are aligned vertically like the image shows?

Best Answer

You don't need subfig or subcaption. Use a minipage bottom aligned, but also specify its vertical size.

\documentclass{article}

\usepackage[demo]{graphicx} % demo is just for the example

\begin{document}
\begin{figure}
\centering
\includegraphics[height=0.18\textheight,width=.246\textwidth]{tease5_a.jpg}
\includegraphics[height=0.18\textheight,width=0.18\textwidth]{tease5_b.jpg}
\includegraphics[height=0.18\textheight,width=0.18\textwidth]{tease5_c.jpg}
\begin{minipage}[b][0.18\textheight][s]{0.18\textwidth}
  \centering
  \includegraphics[height=0.08\textheight,width=\textwidth]{tease5_d.jpg}

  \vfill

  \includegraphics[height=0.08\textheight,width=\textwidth]{tease5_e.jpg}
\end{minipage}
\caption{A caption}
\end{figure}
\end{document}

enter image description here