1

I have two subfigures side by side in one figure, and one subfigure is less than half the height of the other. I would like to align the subfigures at their titles and have the caption fill the empty space under the smaller subfigure, then overflow beneath both figures. Is this possible? Below is the code and picture of how it is now.

Thank you in advance!

\begin{figure}[H]
  \centering
  \subfloat[]{{\includegraphics[width=5cm]{Fig10a.png} }}%
  \qquad
  \subfloat[]{{\includegraphics[width=5cm]{Fig10b.png} }}%
  \caption{Caption text goes here.}
  \label{fig:fig10} 
\end{figure}

enter image description here

0

1 Answer 1

1

This solution modifies \@makecaption locally to format the caption using \hangindent and \hangafter. The saveboxes are used to compute the distance for the text to be wrapped.

The \subfloats are aligned at the top using \raisebox. Technically, the caption overlaps the left picture, hence the [0pt].

The extra \topskip is due to a feature (bug) in subfig which behaves differently in vmode and hmode.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{blindtext}
\usepackage{caption}% not used, test for compatibility
\usepackage{hyperref}

\makeatletter
\newcommand{\hangcaption}[2]{% #1 = \hangindent, #2 = \hangafter\baselineskip (negative distance)
  \long\def\@makecaption##1##2{% 
    \vskip\abovecaptionskip
    \hangindent=#1\relax
    \hangafter=\numexpr #2\relax/\baselineskip\relax
    ##1: ##2\par
    \vskip\belowcaptionskip}%
  \ignorespaces}
\makeatother

\begin{document}
\listoffigures

\begin{figure}[hp]
  \sbox0{\subfloat[]{\includegraphics[width=5cm,height=6cm]{example-image}}}%
  \sbox1{\subfloat[]{\includegraphics[width=5cm,height=2cm]{example-image}}}%
  \centering
  \raisebox{-\height}[0pt][0pt]{\usebox0}\hfil\hfil
  \raisebox{\dimexpr \topskip-\height}{\usebox1}% \topskip ?????
  \hangcaption{0.5\textwidth}{\dimexpr \ht1-\ht0}%
  \caption[short caption]{\blindtext}
\end{figure}

\end{document}

demo

You must log in to answer this question.

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