4

DISCLAIMER: Yesterday, I posted this question about subcaptions numbering. The question received an excellent answer that works perfect for \documentclass{article}, but that fails whenever using \documentclass{scrartcl}. I posted a MWE with \documentclass{article} because I did not know that the package subcaption fails with scrartcl. Hence, I was suggested to either edit my question or ask a new one. Because the question already has an accepted answer that I think may be useful to other readers, I have left the other question as it is and I ask here a new one.

Consider the following (now correct) MWE:

\documentclass[a4paper]{scrartcl}

\usepackage{subcaption}
\usepackage[demo]{graphicx}

\captionsetup[figure]{labelsep=period}
\renewcommand{\thefigure}{\Roman{figure}}
\DeclareCaptionSubType*[alph]{figure}
\captionsetup[subfigure]{labelformat=simple,labelsep=period}

\begin{document}

\begin{center}
\captionof{figure}{Optimal Claims}\label{optimalclaims}
\medbreak
\begin{subfigure}[H]{0.49\textwidth}
    \includegraphics[width=\textwidth]{Resources/Plot1.pdf}
    \medbreak
    \captionof{figure}{Our Game}\label{our}
\end{subfigure}
\hfill
\begin{subfigure}[H]{0.49\textwidth}
    \includegraphics[width=\textwidth]{Resources/Plot2.pdf}
    \medbreak
    \captionof{figure}{mascu}\label{mascu}
\end{subfigure}
\end{center}

\end{document}

Which generates the following output:

enter image description here

As you can see, I get II.a and II.b, and what I would get is I.a. and I.b. instead. Therefore, my question is: how can I get I.a. and I.b. with \documentclass[a4paper]{scrartcl} (that is, without subcaption)?

IMPORTANT: I need a solution that works inside environments that allow no floats or, at least, a solution that is easy to adapt to such environments (as the accepted solution by Mico in my original question). I'm namely thinking about mdframed environments, in which I'm writing my proofs.

Thank you all very much in advanced for your time and effort. I'm sorry for the confusion with my first question.

EoDmnFOr3q
  • 2,299
  • 1
    If the use of mdframed is important in your question, include it in your MWE. – Troy Apr 10 '18 at 09:59
  • Thank you for your comment. To keep the MWE really simple, I did not include it in the question; I just took the figures out of the float environment (this suffices for the question to be complete; madramed is only relevant to the extent that does not allow floats in it). I hope the MWE is OK now. – EoDmnFOr3q Apr 10 '18 at 10:12

1 Answers1

2

If the caption is set above the pictures use \captionabove. For explanations see the comments by Axel Sommerfeldt at the end of this answer.

In a non-float environment you have to add \captionsetup{type=figure}.

\documentclass[a4paper]{scrartcl}

\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage{mdframed}

\captionsetup[figure]{labelsep=period}
\renewcommand{\thefigure}{\Roman{figure}}
\DeclareCaptionSubType*[alph]{figure}
\captionsetup[subfigure]{labelformat=simple,labelsep=period}

\begin{document}

\begin{figure}[!htb]
  \captionabove{Optimal Claims}\label{optimalclaims}
  \centering
  \begin{subfigure}{0.49\textwidth}
    \includegraphics[width=\textwidth]{Plot1.pdf}
    \medbreak
    \subcaption{X}\label{our}
  \end{subfigure}%
  \hfill
  \begin{subfigure}{0.49\textwidth}
    \includegraphics[width=\textwidth]{Plot2.pdf}
    \medbreak
    \subcaption{Y}\label{mascu}
  \end{subfigure}
\end{figure}

\begin{mdframed}
  \begin{center}
    \begin{minipage}{\linewidth}
      \centering
      \captionsetup{type=figure}
      \captionabove{Optimal Claims}\label{optimalclaims2}
      \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Plot1.pdf}
        \medbreak
        \subcaption{X}\label{our2}
      \end{subfigure}%
      \hfill
      \begin{subfigure}{0.49\textwidth}
        \includegraphics[width=\textwidth]{Plot2.pdf}
        \medbreak
        \subcaption{Y}\label{mascu2}
      \end{subfigure}
    \end{minipage}
  \end{center}
\end{mdframed}
\end{document}

enter image description here

esdd
  • 85,675
  • Thank you for your answer. Using \captionabove I solve the issue if the pictures are in a float environment. But inside mdframed environments in which floats are not allowed, the solution you suggest does not work. Is there anything else I could do? – EoDmnFOr3q Apr 10 '18 at 09:57
  • Thank you for your edit. That solved the question. I will edit my question to highlight the need of the answer working on a non-float environment. – EoDmnFOr3q Apr 10 '18 at 10:05
  • @Héctor If you place all your figure captions above the content, you could use the KOMA-Script document class option captions=figureheading. (Afterwards ' \captionis sufficient, no need for using\captionabove`.) –  May 15 '18 at 06:41