2

I would like to arrange four subfigures into a 2-by-2 grid, where the grid element heights vary; something like this:

|------|  |----------|
|------|  |----------|
|------|  |----------|
|------|       c)
|------|
|------|  |----------|
|------|  |----------|
   a)     |----------|
          |----------|
|------|  |----------|
|------|  |----------|
|------|  |----------|
   b)          d)

enter image description here

Is this possible? I tried to adapt this solution for a similar question, but could not get it to work for my complex requirements.


Update

Following some very useful answers, I realise I did not precisely specify my requirements. In particular, the sum of the heights for each column are not equal. I thus want to align the bases of each column, like this:

|------|  
|------|  |----------|
|------|  |----------|
|------|  |----------|
|------|       c)
|------|  
|------|  |----------|
   a)     |----------|
          |----------|
|------|  |----------|
|------|  |----------|
|------|  |----------|
   b)          d)
2

Applying the linked solution is actually quite straight-forward – just add the desired heights:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}[ht]
  \centering
  \parbox{\textwidth}{
    \parbox{.3\textwidth}{%
      \subcaptionbox{}{\includegraphics[width=\hsize, height=4cm]{imageA}}
      \vskip1em
      \subcaptionbox{}{\includegraphics[width=\hsize, height=2cm]{imageB}}
    }
    \hskip1em
    \parbox{.3\textwidth}{%
      \subcaptionbox{}{\includegraphics[width=\hsize, height=2cm]{imageC}}
      \vskip1em
      \subcaptionbox{}{\includegraphics[width=\hsize, height=4cm]{imageD}} 
    }
  }
\end{figure}
\end{document}

enter image description here

Edit: If the bases of the columns shall be aligned, this can be achieved by specifying the vertical alignment of the parboxes:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}[ht]
  \centering
  \parbox{\textwidth}{
    \parbox[b]{.3\textwidth}{%
      \subcaptionbox{}{\includegraphics[width=\hsize, height=4cm]{imageA}}
      \vskip1em
      \subcaptionbox{}{\includegraphics[width=\hsize, height=2cm]{imageB}}
    }
    \hskip1em
    \parbox[b]{.3\textwidth}{%
      \subcaptionbox{}{\includegraphics[width=\hsize, height=2cm]{imageC}}
      \vskip1em
      \subcaptionbox{}{\includegraphics[width=\hsize, height=4cm]{imageD}} 
    }
  }
\end{figure}
\end{document}

enter image description here

  • Thanks. Would it be possible for the column bases to align if the sum of the subfigure heights in each column are not equal (please see my edit)? – Adam Aug 27 '18 at 20:08
  • @Adam: yes, it is possible. See my edit. – Jasper Habicht Aug 27 '18 at 20:35
3

This layout is quite easy to obtain with \valign.

The command \subcaptionpartial has the syntax

\subcaptionpartial[<list entry>]{<subcaption>}{<image>}

and, as in \subcaptionbox, the \label should go in the first mandatory argument. If missing, the optional argument is taken to be the same as the first mandatory argument, as usual for \caption.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{xparse}

\NewDocumentEnvironment{subcaptioncolumns}{}
 {\def\\{\unskip\unskip\cr\noalign{\hspace{1em}}}\valign\bgroup\vfil##\cr}
 {\unskip\unskip\crcr\egroup}
\NewDocumentCommand{\subcaptionpartial}{O{#2}mm}{%
  \hbox{\subcaptionbox[#1]{#2}{#3}}\medskip
}

\begin{document}

\begin{figure}
\centering

\begin{subcaptioncolumns}
\subcaptionpartial{\label{one}}{%
  \includegraphics[width=4cm,height=6cm]{example-image}%
}
\subcaptionpartial{\label{two}}{%
  \includegraphics[width=4cm,height=3cm]{example-image}%
}
\\
\subcaptionpartial{\label{three}}{%
  \includegraphics[width=4cm,height=4cm]{example-image}%
}
\subcaptionpartial{\label{four}}{%
  \includegraphics[width=4cm,height=4cm]{example-image}%
}
\end{subcaptioncolumns}

\caption{Whatever}\label{full}

\end{figure}

\end{document}

enter image description here

2

Here is a solution using minipage environments on the right most column images.

\documentclass[]{article}
\usepackage[]{subfig}
\usepackage[demo]{graphicx}

\begin{document}

    \begin{figure}
        \centering
        \subfloat[][]{\includegraphics[width=3cm,height=8cm]{imageA}}\quad
        \begin{minipage}[t]{4cm}
            \vspace{-8cm}
            \subfloat[][]{\includegraphics[width=4cm,height=4cm]{imageA}}
        \end{minipage}\\[12pt] 
        \subfloat[][]{\includegraphics[width=3cm,height=2cm]{imageA}}
        \quad
        \begin{minipage}[t]{4cm}
            \vspace{-6cm}
            \subfloat[][]{\includegraphics[width=4cm,height=6cm]{imageA}}
            \end{minipage}
        \end{figure}

\end{document}

enter image description here

  • Thanks. Would you be able to modify your answer so the bases of the columns align, given the sum of heights in each column are unequal (as per my edit)? – Adam Aug 27 '18 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.