4

I'm attempting to align a 3-column x 2-row grid of figures, where the top row is aligned to the top and the bottom row to the bottom. I define the subfigures as columns so that caption numbering follows the convention I want (i.e. a on top of b, c on top of d....). I've tried using alignment parameters to subfigures, as well as messing with \vfill and \vspace*{\fill} between subfigures to try to extend vertical spacing between figures for alignment, to no avail.

I'm currently getting this result:

\documentclass[sigplan,anonymous,review,10pt]{acmart}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure*}[htbp]
\centering
    \begin{subfigure}{0.33\textwidth} % a, b
    \centering
        \begin{subfigure}[t]{\linewidth} % a
            \begin{lstlisting}
  Code snippet 1
            \end{lstlisting}
            \caption{}
            \label{code1}
        \end{subfigure}
        \begin{subfigure}[b]{\linewidth} % b
            \includegraphics[height=3cm]{example-image-a}
            \caption{}
            \label{fig1}
        \end{subfigure}
    \end{subfigure}
%===============================
% New Column for C & D
%===============================
    \begin{subfigure}{0.33\textwidth} % c, d
        \begin{subfigure}[t]{\linewidth} % c
        \centering
            \begin{lstlisting}
  Code snippet
  2
            \end{lstlisting}
            \caption{}
            \label{code2}
        \end{subfigure}
        \begin{subfigure}[b]{\linewidth}  % d
        \centering
            \includegraphics[height=4cm]{example-image-b}
            \caption{}
            \label{fig2}
        \end{subfigure}
    \end{subfigure}
%===============================
% New column for E & F
%===============================
    \begin{subfigure}{0.33\textwidth} % e, f
    \centering
        \begin{subfigure}[b]{\linewidth}  % e
        \centering
            \begin{lstlisting}
  Code
  snippet
  3
            \end{lstlisting}
            \caption{}
            \label{code3}
        \end{subfigure}
        \begin{subfigure}[b]{\linewidth}  % f
        \centering
            \includegraphics[height=5cm]{example-image-c}
            \caption{}
            \label{fig3}
         \end{subfigure}
    \end{subfigure}
    \caption[]{Caption}
    \label{label}
\end{figure*}

\end{document}

current

What I want is:

desire

2
  • BTW, a subfigure is basically a minipage with captions. Now if you really want subsubfigures, see the second version from tex.stackexchange.com/questions/423580/… Sep 5, 2019 at 15:24
  • Hey @JohnKormylo, this doesn't quite do what I wanted -- my issue was in the ordering of the caption numbers(letters) when laying out the subfigures with the correct alignment. I found a simple way to do it, using \addtocounter in conjunction with laying out by row instead of by column. Thanks for the suggestion! Sep 6, 2019 at 16:22

1 Answer 1

2

The solution lies in keeping subfigures as rows (for easy alignment), and using the addtocounter command to adjust numbering of subfigures manually.

\documentclass[sigplan,anonymous,review,10pt]{acmart}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure*}[htbp]
\centering
    \begin{subfigure}[b]{\textwidth}
    \centering
        \begin{subfigure}[b]{0.33\linewidth}
        \centering
            \begin{lstlisting}
  Code snippet 1
            \end{lstlisting}
            \caption{}
            \label{code1}
        \end{subfigure}
        \begin{subfigure}[b]{0.33\linewidth}
        \addtocounter{subfigure}{1}
        \centering
            \begin{lstlisting}
  Code snippet
  2
            \end{lstlisting}
            \caption{}
            \label{code2}
        \end{subfigure}
        \begin{subfigure}[b]{0.33\linewidth}
        \addtocounter{subfigure}{1}
         \centering
             \begin{lstlisting}
  Code
  snippet
  3
            \end{lstlisting}
            \caption{}
            \label{code3}
       \end{subfigure}
    \end{subfigure}
    \begin{subfigure}[b]{\textwidth}
    \centering
       \begin{subfigure}[b]{0.33\linewidth}
       \addtocounter{subfigure}{-4}
       \centering
        \includegraphics[height=3cm]{example-image-a}
        \caption{}
        \label{fig1}
    \end{subfigure}
    \begin{subfigure}[b]{0.33\linewidth}
    \addtocounter{subfigure}{1}
    \centering
    \includegraphics[height=4cm]{example-image-b}
    \caption{}
    \label{fig2}
    \end{subfigure}
    \begin{subfigure}[b]{0.33\linewidth}
    \addtocounter{subfigure}{1}
    \centering
        \includegraphics[height=5cm]{example-image-c}
        \caption{}
        \label{fig3}
     \end{subfigure}
    \end{subfigure}
    \caption[]{Caption}
    \label{label}
\end{figure*}

\end{document}

solution

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .