3

I'm currently using this code

\documentclass{article}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}

\renewcommand{\thefigure}{\Roman{figure}}
\captionsetup[figure]{labelsep=period}

\begin{document}

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

Which generates this output (when running this MWE on your computer, choose any two images, name them Plot1.pdf and Plot2.pdf and save them in the same folder as the main .tex file; it should compite without problems):

enter image description here

I have been trying to modify the numbering of the subcaptions by looking at this link, but with no success. Instead of (a) X and (b) Y, I would like to get I.a. X and I.b. Y. Can anybody please help me achieve so?

Thank you all very much in advanced for your time and effort.

EoDmnFOr3q
  • 2,299

1 Answers1

4

(Remark: I posted the following answer based on the information given in the OP's MWE and, in particular, the fact that the article document class was supposed to be in use. The OP has since informed me -- see one of the comments below -- that he/she actually uses the scrartcl instead of the article document class. In consequence, my answer doesn't solve his/her actual typesetting issue.)


Something like this?

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx} % remove 'demo' option in real document

\usepackage{subcaption} % 'caption' package is loaded automatically    
\captionsetup[figure]{labelsep=period}
\renewcommand{\thefigure}{\Roman{figure}}
\captionsetup[subfigure]{labelformat=simple} % default is 'parens'
\renewcommand\thesubfigure{\thefigure.\alph{subfigure}.}

\begin{document}

\begin{figure}[!htb]
\caption{Optimal Claims}\label{optimalclaims}
\begin{subfigure}[b]{0.49\textwidth}
    \includegraphics[width=\textwidth]{Plot1.pdf}
    \medbreak
    \caption{X}\label{our}
\end{subfigure}%
\hfill % to maximize separation between the subfigures
\begin{subfigure}[b]{0.49\textwidth}
    \includegraphics[width=\textwidth]{Plot2.pdf}
    \medbreak
    \caption{Y}\label{mascu}
\end{subfigure}
\end{figure}

\end{document}

Addendum: If you plan to create cross-references to subfigures, it would be best if you replaced the two lines of code

\captionsetup[subfigure]{labelformat=simple} % default is 'parens'
\renewcommand\thesubfigure{\thefigure.\alph{subfigure}.}

with

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

See section 5 of the user guide of the subcaption package for the commands \DeclareCaptionSubType and \DeclareCaptionSubType*. With this change, the period at the end of the composite subcaption number isn't a part to the cross-reference output.

Mico
  • 506,678
  • 1
    This is not only an answer that solves the issue, but also an anser that teaches how to proper typset MWE. Thank you. I will accept it as soon as I can. EDIT: unfortunately, when applying your solution to my real document, I get II.A and II.B instead of I.A and I.B. I'll look into it tomorrow. – EoDmnFOr3q Apr 10 '18 at 00:02
  • 1
    @Héctor - You're most welcome! By the way, I just posted an addendum, with some code that should be used if you intend to make cross-refences (using the \label-\ref mechanism) to objects of type subcaption. – Mico Apr 10 '18 at 00:15
  • Thank you very much for the addendum. I will look into the issue that I have now and I will be back to this question if it persists. Can I notify you via comment if necessary? – EoDmnFOr3q Apr 10 '18 at 00:19
  • 1
    @Héctor - Absolutely. – Mico Apr 10 '18 at 00:20
  • Thank you for your generosity. I have found what causes the problem. I'm currently using \documentclass[a4paper]{scrartcl} instead of \documentclass[a4paper]{article}. When using \documentclass[a4paper]{article}, your answer works as expected. Whenever using \documentclass[a4paper]{scrartcl}, I get II.a. and II.b instead of the desired I.a. and I.b.. Do you know why is this so? And, more importantly: can this miss-behaviour be avoided? – EoDmnFOr3q Apr 10 '18 at 00:27
  • 1
    @Héctor - Why did you post an MWE that uses the article document class when, in fact, you not only not use that class but actually use one -- scrartcl -- which for which the subcaption package doesn't work correctly. I would never have written the answer I did if I'd known that you employ the scrartcl document class. I would like to suggest that you either edit your posting to provide a more relevant MWE or post an entirely new query, this time with all relevant. I wish I could simply delete my answer, but that's not possible for answers that have received the "accept" check-mark. – Mico Apr 10 '18 at 04:46
  • Thank you very much for pointing that out. I did not know it. I want to personally apologise with you for writing a MWE that was very bad for the purpose of the question. It's my bad and I'm sorry. As you can see, I still have problems when writing MWEs (I never know which things I should simplify and which ones I should leave as they are; all I try to avoid are the typical comments of "please, make your MWE really minimal"). For respect to you and your time, as well as for the future readers of the question, I would leave this question and your answer as they are now. I'll ask a new question. – EoDmnFOr3q Apr 10 '18 at 07:58
  • In case you are still interested, you can see my new question here: https://tex.stackexchange.com/questions/425739/how-to-customise-subcaptions-with-documentclassscrartcl-that-work-inside-no – EoDmnFOr3q Apr 10 '18 at 09:29