1

I have two figures of unequal size (figure 1 is wider and shorter), and I would like to centre-align the two subfigures vertically, but keep the subcaptions aligned at the top (please see attached image). Can this be done with the subcaption package, without modifying the figures themselves? enter image description here (figure updated)

%preamble
\usepackage[singlelinecheck=false, aboveskip=-3pt]{subcaption}
%document
       %version1----
            \begin{figure}
            \captionsetup[subfigure]{labelformat=simple, position = top}
            \captionsetup{font={onehalfspacing},skip=-10pt}
            \subcaptionbox{}[0.5\textwidth]{\includegraphics[width=0.5\linewidth]{fig1.pdf}}
            \subcaptionbox{}[0.5\textwidth]{\includegraphics[width=0.5\linewidth]{fig2.pdf}}

        \end{figure}
        \clearpage
       %version2----
        \begin{figure}[hb]
            \captionsetup[subfigure]{labelformat=simple}
            \captionsetup{font={onehalfspacing},skip=-10pt}
                \begin{subfigure}[c]{0.49\textwidth}
                    \caption{}                
                    \includegraphics[width=\textwidth]{fig1.pdf}
                \end{subfigure}
                \begin{subfigure}[c]{0.49\textwidth}
                    \caption{}                
                    \includegraphics[width=\textwidth]{fig2.pdf}
                \end{subfigure}
2
  • Does the following answer your question? Subcaption: Vertical alignment of two images of different vertical size
    – leandriis
    Commented Jul 24, 2018 at 16:46
  • Hi, I think that solution still centres the subcaption along with the subfigure, whereas I would like the subcaption to be at the top and the figure centred. I can already centre the figure with the [c] option for {subfigure}. I have updated the attached image to better reflect my question. Thanks.
    – srao
    Commented Jul 25, 2018 at 7:47

1 Answer 1

1

You might like this solution:

\documentclass{article}

\usepackage{graphicx}
\usepackage[singlelinecheck=false, aboveskip=-3pt]{subcaption}
\renewcommand{\thesubfigure}{\Alph{subfigure}}

\begin{document}

\begin{figure}[htbp]
\captionsetup[subfigure]{labelformat=simple}
\begin{subfigure}{\textwidth}
\valign{\hsize=0.49\hsize \linewidth=\hsize #\cr
  \caption{}
  \vfill
  \includegraphics[height=2cm,width=\hsize]{example-image}
  \vfill
  \cr\noalign{\hfill}
  \caption{}
  \vfill
  \includegraphics[width=\hsize]{example-image}
  \vfill
  \cr
}
\end{subfigure}

\end{figure}

\end{document}

enter image description here

2
  • Great, this works! I am guessing \newsavebox{\subA} \newsavebox{\subB} in the preamble can be safely removed.
    – srao
    Commented Jul 25, 2018 at 13:44
  • @srao Yes, they are a relic from a previous attempt.
    – egreg
    Commented Jul 25, 2018 at 14:01

You must log in to answer this question.

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