[Tex/LaTex] Layout issues when using `subcaption` together with `sidecap`

captionsfloatssidecapsubcaption

I am using the sidecap package for side captions. I also want to have subfigures (for example, three or four subfigures labeled with a), b), c) and d), respectively).

When not using the SCfigure environment, this is what I get (the figures are aligned correctly, but the caption is obviously not at the side):

\documentclass[a4paper,twoside,11pt,openright]{scrbook}         
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\graphicspath{{./images/}}
\usepackage[wide]{sidecap}                                                      % custom captions on the side
\sidecaptionvpos{figure}{t}                                                     % captions should be on top
\sidecaptionvpos{table}{t}
\usepackage[font=footnotesize,
    format=plain,
    labelfont={bf,sf},
    nooneline,
    textfont={it}]{caption}

\usepackage{subcaption} 
\usepackage[twoside]{geometry}
\geometry{a4paper,
                    left=24.8mm,
                    top=27.4mm,
                    %headheight=\baselineskip,
                    %headsep=2\baselineskip,
                    textwidth=135mm,
                    marginparsep=8.2mm,
                    marginparwidth=28mm
                    }

\begin{document}
\begin{figure}
    \subcaptionbox{\label{fig:01:054a}}
          {\includegraphics[width=0.5\textwidth]{a}}
    \subcaptionbox{\label{fig:01:054b}}
          {\includegraphics[width=0.5\textwidth]{b}}
  \subcaptionbox{\label{fig:01:054c}}
          {\includegraphics[width=0.5\textwidth]{c}}
\caption{A test figure}\label{fig:01:054}
\end{figure}    

\end{document}

using <code>figure</code>

When using SCfigure but with only two subfigures, the result is satisfying, correctly displaying the side caption:

\begin{SCfigure}
    \subcaptionbox{\label{fig:01:054a}}
          {\includegraphics[width=0.5\textwidth]{a}}
    \subcaptionbox{\label{fig:01:054b}}
          {\includegraphics[width=0.5\textwidth]{b}}
%  \subcaptionbox{\label{fig:01:054c}}
%          {\includegraphics[width=0.5\textwidth]{c}}
\caption{A test figure}\label{fig:01:054}
\end{SCfigure}  

using <code>SCfigure</code> with two subfigures

When I uncomment the last \subcaptionbox, this is what I get:

Using <code>SCfigure</code> with three subfigures

What do I have to do in order to display three or more figures of width=0.5\textwidth correctly like in the figure environment? Can't be that I'm the only one who's using side captions in conjunction with subfigures….

Edit: In this German forum thread, the author of the subcaption package claims that it is compatible with sidecap.

Best Answer

I would suggest you the more powerful and flexible floatrow package (in fact, the author of caption also suggest this package as an alternative to sidecap).

I commented out a spurious blank space after the first \subcaptionbox and added a line changing command \\ after the second one; I also added a "fake" four image (a rule of zero height and 0.5\textwidth width) to have the third image flushed left instead of centered:

\documentclass[a4paper,twoside,11pt,openright]{scrbook}         
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\graphicspath{{./images/}}
\usepackage{floatrow}

\usepackage[font=footnotesize,
    format=plain,
    labelfont={bf,sf},
    nooneline,
    textfont={it}]{caption}

\usepackage{subcaption} 
\usepackage[twoside]{geometry}
\geometry{a4paper,
                    left=24.8mm,
                    top=27.4mm,
                    %headheight=\baselineskip,
                    %headsep=2\baselineskip,
                    textwidth=135mm,
                    marginparsep=8.2mm,
                    marginparwidth=28mm
                    }

\begin{document}

\thisfloatsetup{margins=hangright,capposition=beside,
capbesideposition={top,right},floatwidth=\textwidth}
\begin{figure}
    \subcaptionbox{\label{fig:01:054a}}
          {\includegraphics[width=0.5\textwidth]{example-image-a}}%
    \subcaptionbox{\label{fig:01:054b}}
          {\includegraphics[width=0.5\textwidth]{example-image-b}}\\
  \subcaptionbox{\label{fig:01:054c}}
          {\includegraphics[width=0.5\textwidth]{example-image-c}}\rule{.5\textwidth}{0pt}
\caption{A test figure}\label{fig:01:054}
\end{figure}    

\end{document}

enter image description here