1

I am trying to use the subcaption package (not subfig) to generate the labels of the subfigures beside the figure.

I have found many similar questions, but all answers (like this one) use subfigand floatrow. I have tried using floatrow with subcaption (see MWI below), but I could not generate the same behaviour. What am I missing?

The subcaption manual explicitly states that

[f]or a more advanced usage of the sub-caption feature of the caption package, please take a look at the floatrow package

but the floatrow manual only gives an example of a caption beside the figure using subfig (p.75).

So any help is greatly appreciated.

MWE:

\documentclass{scrartcl}

\usepackage{graphicx}
\usepackage[font=footnotesize,figurewithin=none]{caption}
\usepackage{subcaption}
\captionsetup{subrefformat=parens} % will result in references (typeset with \ref) like  1a  but sub-references (typeset with\subref) like  (a)
\usepackage{floatrow}
\floatsetup[subfigure]{style=plain,subcapbesideposition=top}
%\usepackage{subfig} % not compatible with subcaption

\begin{document}

\begin{figure}
  \centering
  \begin{subfigure}[t]{0.7\textwidth}
    \centering
    \includegraphics[width=0.7\textwidth]{example-image-a}
    \caption{}
    \label{subfig:a}
  \end{subfigure}
  \\
  \begin{subfigure}[t]{0.49\textwidth}
    \centering
    \includegraphics[width=\textwidth]{example-image-b}
    \caption{}
    \label{subfig:b}
  \end{subfigure}
  \hfill
  \begin{subfigure}[t]{0.49\textwidth}
    \centering
     \includegraphics[width=\textwidth]{example-image-c}
    \caption{}
    \label{subfig:c}
  \end{subfigure}
  \caption{Caption for all subfigs: \subref{subfig:a},\subref{subfig:b}, \subref{subfig:c}}
  \label{fig}
\end{figure}

\end{document}

Output of MWE:

Output of MWE

0

1 Answer 1

2

Rather than figure out how to make floatrow work, it was easier just to fake it.

It should be noted that the [t] option of subfigure refers to the first baseline, not the absolute top, so what it does is align the bottoms of the images instead of the captions. To align the tops you need to use \raisebox. In fact, there is no reason to put the images into subfigures at all (just the captions).

The \raisebox for the caption was to automatically produce a gap between rows.

\documentclass{scrartcl}

\usepackage{graphicx}
\usepackage[font=footnotesize,figurewithin=none]{caption}
\usepackage{subcaption}
\captionsetup{subrefformat=parens} % will result in references (typeset with \ref) like  1a  but sub-references (typeset with\subref) like  (a)
%\usepackage{subfig} % not compatible with subcaption

\newcommand{\sidecaption}[1]% #1 = label name
{\begin{subfigure}[t]{1.6em}
  \captionsetup{singlelinecheck=off, skip=0pt}%
  \caption{}
  \ifx\empty#1\relax\else\label{#1}\fi
\end{subfigure}\ignorespaces}

\begin{document}

\begin{figure}
  \centering
  \sidecaption{subfig:a}
  \raisebox{-\height}{\includegraphics[width=0.45\textwidth]{example-image-a}}

  \sidecaption{subfig:b}
  \raisebox{-\height}{\includegraphics[width=0.45\textwidth]{example-image-b}}%
  \hfill
  \sidecaption{subfig:c}
  \raisebox{-\height}{\includegraphics[width=0.45\textwidth]{example-image-c}}
  \caption{Caption for all subfigs: \subref{subfig:a},\subref{subfig:b}, \subref{subfig:c}}
  \label{fig}
\end{figure}

\end{document}

demo


It should be noted that this is only one of many possible ways to format a side caption. The following does not use the subcaption package at all. OTOH, it does not write an entry for the \listoffigures either.

\newcounter{subfigure}[figure]% not needed with subcaption
\renewcommand{\thesubfigure}{\alph{subfigure}}

\newcommand{\sidecaption}[1]% #1 = label name
{\rule{0pt}{\abovecaptionskip}% create gap between rows
  \refstepcounter{subfigure}%
  \raisebox{-\height}{(\thesubfigure)~}% align
  \label{#1}\ignorespaces}
2
  • Thank you, this solves my basic problem (although I find it a little bit strange that subcaption has no setting for this and now I have to rewrite the code for all my figures...). But one little thing: the labels do not align with the top of the figure, how could this be achieved?
    – Taunch
    Commented Feb 1, 2017 at 21:29
  • 1
    I discovered that \abovecaptionskip it larger outside the subfigure than inside (10pt vs 6pt). In any case, you can adjust the \raisebox in \sidecaption to whatever you think looks good. Commented Feb 2, 2017 at 15:33

You must log in to answer this question.

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