[Tex/LaTex] margin caption and subfloat

marginssubcaptionsubfloats

I'm desperately trying to get a workable setup of margin caption and subfloats. I use mcaption for margin caption which provides an environment which one wraps the inner content of the float in. However, it seems to mess up labels so that I can't refer to figures. The following example illustrates the problem:

\documentclass{scrartcl}
\usepackage{subcaption}
\usepackage{mcaption}
\begin{document}

\begin{figure}
\begin{margincap}
  \begin{subfigure}[b]{.5\linewidth}
    \centering\large A
    \caption{A subfigure}\label{fig:1a}
  \end{subfigure}%
  \begin{subfigure}[b]{.5\linewidth}
    \centering\large B
    \caption{Another subfigure}\label{fig:1b}
  \end{subfigure}
  \caption{A figure}\label{fig:1}
\end{margincap}
\end{figure}

\ref{fig:1b}
\end{document}

Here's a figure of of the output [?? is the unsuccessful \ref ].
illustration

I would appreciate any hints on how to get margin captions and some kind of sub-figures (e.g. subfig/subcaption)

Thanks,

Edit, here's an example where I can't get it to to the outer margin:

\documentclass[twoside]{scrartcl}
\usepackage{scrpage2}

\usepackage{subcaption}
\usepackage{floatrow}
\ohead{outer}
\ihead{inner}
\captionsetup[capbesidefigure]{format=plain}
\floatsetup[figure]{margins=hangoutside,capposition=beside,
capbesideposition={top,right},floatwidth=\textwidth,capbesidewidth=1\marginparwidth}
\pagestyle{scrheadings}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering\large B
\caption{Another subfigure}\label{fig:1b}
\end{subfigure}
\caption{A test figure}\label{fig:1}
\end{figure}
\newpage~\newpage
{
\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering\large B
\caption{Another subfigure}\label{fig:1b}
\end{subfigure}
\caption{A test figure}\label{fig:1}
\end{figure}
}

\ref{fig:1b}

\end{document}

Best Answer

You can use the floatrow package instead of mcaption:

\documentclass{scrartcl}
\usepackage{subcaption}
\usepackage{floatrow}

\captionsetup[capbesidefigure]{format=plain,justification=RaggedRight,
font=small,labelsep=newline}

\begin{document}

{
\floatsetup[figure]{margins=hangleft,capposition=beside,
capbesideposition={top,right},floatwidth=\textwidth,capbesidewidth=1.5\marginparwidth}
\begin{figure}
  \begin{subfigure}[b]{.5\linewidth}
    \centering\large A
    \caption{A subfigure}\label{fig:1a}
  \end{subfigure}%
  \begin{subfigure}[b]{.5\linewidth}
    \centering\large B
    \caption{Another subfigure}\label{fig:1b}
  \end{subfigure}
  \caption{A test figure}\label{fig:1}
\end{figure}
}

\ref{fig:1b}

\end{document}

enter image description here

To obtain captions in the outer margin, you can use the options facing=yes, and capbesideposition={top,outside}:

\floatsetup[figure]{facing=yes,margins=hangoutside,capposition=beside,
capbesideposition={top,outside},floatwidth=\textwidth,capbesidewidth=1.5\marginparwidth}
\captionsetup[capbesidefigure]{format=plain,justification=RaggedRight,
font=small,labelsep=newline}