1

Following the answer here (or here), I have an inline figure with four subfigures. I would like to add subcaptions for those, preferably with automatic labels, but since the figure isn't a float, things like \subcaptionbox do not work. I also couldn't find a way of faking it using \captionof. Does anyone know of a solution, or at least a hack to manually specify the labels and subcaptions?

\noindent%
\begin{minipage}{\linewidth}%
    \makebox[\linewidth]{%
        \includegraphics[width=0.49\linewidth]{image.png}%
        \includegraphics[width=0.49\linewidth]{image.png}
    }
    \makebox[\linewidth]{%
        \includegraphics[width=0.49\linewidth]{image.png}
        \includegraphics[width=0.49\linewidth]{image.png}
    }
    \captionof{figure}{Main caption}\label{fig:some-figure}
\end{minipage}
2

Use either \captionsetup{type=figure} or \setcaptiontype{figure}:

\begin{minipage}{\linewidth}%
    \setcaptiontype{figure}%
    \subcaptionbox{..}{..}
    \subcaptionbox{..}{..}
    \caption{Main caption}\label{fig:some-figure}
\end{minipage}

This is the preferred way anyway since \captionof could cause wrong hyperref jump targets.

For more information take a look at the caption package documentation.

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.