3

Is it possible to have cleveref capitalise the letter when cross referencing a subfigure?

Currently my subfigures are configured to capitalise the letter in a subfig (i.e A B C D E) but when i use the \cref command it will generated Fig. 1a.

Here is MWE:

\documentclass[a4paper]{article}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup{justification=centerlast,font=small,labelfont=sc,margin=50pt}
\usepackage[capitalise]{cleveref}

\begin{document}

\begin{figure}
\centering
\subcaptionbox{\label{subfig:Test1}}[0.49\textwdith]{\includegraphics[width=0.49\textwidth]{Fig.png}}
\subcaptionbox{}[0.49\textwdith]{\includegraphics[width=0.49\textwidth]{Fig2.png}}

I would like this cross reference to show a capital 'A' rather than a lower case: \cref{subfig:Test1}.

\end{document
2
  • Can you please add a minimal example of what you're doing up to now?
    – egreg
    Dec 18, 2019 at 16:56
  • @egreg I have added the MWE
    – phald
    Dec 19, 2019 at 10:16

1 Answer 1

3

The problem is that you are not labelling the subfigures with a capital letter, but labelling with a small letter and then printing it in the caption with the small caps font. If you wish to use the small caps font for this label then rather than (or in addition to) setting the labelfont you should redefine the printing of the subfigure label via

\renewcommand{\thesubfigure}{\scshape\alpha{subfigure}}

so this formatting is used elsewhere when you reference the label.

Sample output

\documentclass[a4paper]{article}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{caption}
\captionsetup{justification=centerlast,font=small,margin=50pt}
\renewcommand{\thesubfigure}{\scshape\alph{subfigure}}
\usepackage[capitalise]{cleveref}

\begin{document}

\begin{figure}
  \centering
  \subcaptionbox{\label{subfig:Test1}}[0.49\textwidth]{\includegraphics[width=0.49\textwidth]{example-image-a}}
  \subcaptionbox{}[0.49\textwidth]{\includegraphics[width=0.49\textwidth]{example-image-b}}
\end{figure}

I would like this cross reference to show a capital 'A' rather than a
lower case: \cref{subfig:Test1}.

\end{document}

On the other hand if you really want to label by capital letters, then the appropriate redefinition is

\renewcommand{\thesubfigure}{\Alph{subfigure}}

regardless of the caption font.

Second sample

1
  • Yes of course. I see now. thanks for the help!
    – phald
    Dec 19, 2019 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.