# Memoir’s subfigures vs cleveref: how to set the ref label format

I have a giant document based on memoir class and tightly integrated with its subfigure infrastructure - i.e. adding packages like subfloat/subfig/subcaption is extremely undesirable (AFAIK it’s possible to solve my problem with subcaption).

The publisher SUDDENLY demanded me to make all subfigures and their reference labels to look like this: i.e. subcaptions consist of an italicized letter only, and the reference inside text has said letter separated from the figure’s number with a comma and a space.

The best I could come up with is to redefine thesubfigure, but it messes up the subcaptions.

I read the cleveref documentation, being sure that there is some hook to define how the in-text reference label is rendered, but couldn't find anything.

MWE:

\documentclass[a4paper,14pt]{memoir}
\usepackage{graphicx}
\usepackage{cleveref}

\newcommand{\SCFigFont}{\small}
\newcommand{\SCFigLabelFont}{\SCFigFont\itshape}

% Figure settings - just in case some of the solutions you might want to offer conflict with these
\renewcommand{\figurename}{Fig.} % changed for simplicity
\setlength{\abovecaptionskip}{0pt}
\setlength{\belowcaptionskip}{0pt}
\captionnamefont{\SCFigLabelFont}
\captiontitlefont{\SCFigFont}
\captiondelim{. }
\captionstyle[\centering]{\centerlastline}
\SCFigFont % turn on the needed font for everything that happens to be in the figure
\renewcommand{\baselinestretch}{1} % ditto for line spacing
}

% Subfigure settings
\newsubfloat{figure}
\subcaptionstyle{\centering}
\subcaptionsize{\SCFigFont}
\subcaptionlabelfont{\SCFigLabelFont}
\subcaptionfont{\SCFigFont}
\tightsubcaptions

% The closest thing to a solution that I could find
\renewcommand{\thesubfigure}{,~\itshape\alph{subfigure}}
%\renewcommand{\thesubfigure}{\alph{subfigure}}

\begin{document}

\chapter{Chapter name}

\begin{figure}[ht]
{\centering
\hfill
\subbottom[\label{img:image-a}]{%
\includegraphics[width=0.4\linewidth]{example-image-a}}
\hfill
\subbottom[\label{img:image-b}]{%
\includegraphics[width=0.4\linewidth]{example-image-b}}
\hfill
}
\caption{Example images: \subcaptionref{img:image-a} --- image A; \subcaptionref{img:image-b} --- image B}
\label{img:images}
\end{figure}

We can see the A image in~\cref{img:image-a};
the B image in~\cref{img:image-b};
and both images in~\cref{img:images}.

%We can see the A image in~\cref{img:images},~\textit{a};
%the B image in~\cref{img:images},~\textit{b};
%and both images in~\cref{img:images}.

\end{document}


Following your last commented-out text, something along these lines?

We can seen the A image in~\cref{img:images},~\subcaptionref{img:image-a};
the B image in~\cref{img:images},~\subcaptionref{img:image-b};
and both images in~\cref{img:images}.

• Thanks, but I would expect LaTeX to be able to automate this. The whole point of using it to me is being able to solve problems like these by editing a couple lines in the preamble, instead of walking through hundreds of pages and replacing brief \cref commands with cumbersome, error-prone, and rigid manual ones. – ScumCoder Nov 24 '19 at 19:36

Forget it, I'm just dumb. While reading the very answer I myself have linked, for some reason I thought that the \p@subfigure macro is part of the subcaption package (which I don't want to use) - as opposed to an utterly normal LaTeX macro. So, here's all that I needed to do in order to achieve desired result:

\renewcommand{\thesubfigure}{\itshape\alph{subfigure}}
\makeatletter
\renewcommand\p@subfigure{\thefigure,~}
\makeatother


Thanks again to Mico for explaining me how the \p@-counters work.