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}
  • Does the following answer your question? Subcaption: Vertical alignment of two images of different vertical size – leandriis Jul 24 '18 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 Jul 25 '18 at 7:47
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

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

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.