# Figure number is missing in cleveref

Figure number is missing in subcaption references, when using cleveref. How can I get a subcaption reference as Fig.1(a), instead of Fig. (a)?

\documentclass[12pt]{extarticle}
\RequirePackage{figureSeries}
\usepackage{algorithm}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}
\Crefname{figure}{Fig.}{Figs.}
\newcommand{\csubfloat}[2][]{\makebox[0pt]{\subfloat[#1]{#2}}}

% % packages for this example
\usepackage{mwe}
\usepackage{xcolor}

\begin{document}

\begin{figure}[H]
\centering
% Subfigure A
\hspace*{\fill}%
\csubfloat[First subcaption.]
{\label{fig:Figure1a}%
\includegraphics[width=5cm]{example-image-a}}
\hspace*{\fill}
% Subfigure B
\hspace*{\fill}
\csubfloat[Second subcaption.]
{\label{fig:Figure1b}%
\includegraphics[width=5cm]{example-image-b}}
\hspace*{\fill}
% Overall caption and label
\caption{Overall caption of the Figure.}
\label{fig:Figure1}
\end{figure}

Current reference to Figure 1a typesets as \textbf{\cref{fig:Figure1a}}.
\\
Current reference to Figure 1b typesets as \textbf{\cref{fig:Figure1b}}.
\\ \\
\textbf{Why don't I get something like this?} {\color{red}\textbf{Fig.1(a)}} \textbf{and} {\color{red} \textbf{Fig.1(b)}}

\end{document}


• Do you know the subcaption package? I think you should give it a try, because it allows you to set/get references of subfigures (and subtables). Oct 29, 2020 at 16:23
• Thanks a lot! Yes, as @P.M. just wrote, the \usepackage{subcaption} was part of the solution :) Oct 29, 2020 at 16:41
• \usepackage{subcaption} is part of the figureSeries package. The solution is to revert the settings change of the figureSeries package with \DeclareCaptionSubType{figure}.
– user205700
Oct 29, 2020 at 16:42

Your example document could be boiled down to:

\documentclass[12pt]{article}

% from figureSeries.sty
% (taken from https://github.com/thomasWeise/figureSeries)
\usepackage{subcaption}
\DeclareCaptionSubType*[arabic]{figure}

\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}
\begin{figure}[!ht]
\subfloat[Test\label{fig:1a}]{This is not an image}
\caption{Some text\ldots}
\end{figure}
\ref{fig:1a} % typesets "(a)"
\end{document}


What happens here: The figureSeries package uses \DeclareCaptionSubType* to make the figure counter part of the sub-figure counter. And with \renewcommand\thesubfigure{(\alph{subfigure})} you remove the figure-part of the sub-figure labeling, but \label resp. \ref is not aware of your re-definition (and therefore does not prepend the figure counter since it assumes that it is already part of the sub-figure counter), and as result you have eliminated the figure-part completely.

What could be done instead: If you don't like the sub-figure setup of the figureSeries package, reverse this setting with \DeclareCaptionSubType (without star), for example:

\documentclass[12pt]{article}

% from figureSeries.sty
\usepackage{subcaption}
\DeclareCaptionSubType*[arabic]{figure}

\DeclareCaptionSubType{figure} % revert setting of figureSeries.sty
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}
\begin{figure}[!ht]
\subfloat[Test\label{fig:1a}]{This is not an image}
\caption{Some text\ldots}
\end{figure}
\ref{fig:1a} % typesets "1(a)"
\end{document}

• Thanks a lot for the explanation and for the solution!!! I think I got confused with the figureSeries package...! I Just commented % \RequirePackage{figureSeries} and I added \usepackage{subcaption} \DeclareCaptionSubType{figure} Oct 29, 2020 at 16:38
• If you don't use the figureSeries package anymore the line \DeclareCaptionSubType{figure} could be dropped since this is the default setting. (But it does not make any harm, so you could keep it, too.)
– user205700
Oct 29, 2020 at 16:44
• Thanks a lot, I should study the packages more carefully! Oct 29, 2020 at 16:45