Here is an attempt using cleveref
package.
- A new macro
\crefretainprefix
is defined, emulating the \crefstripprefix
.
- The setting
\crefrangelabelformat{subfigure}{...}
is based on my previous answer.
- Also I suppose
\subfloat
is defined by subcaption
package.
In the following example, input
\Cref{fig:rub} contain \cref{fig:fse,fig:fsp,fig:fsg} and \cref{fig:cle,fig:clp,fig:clg}.
gives
Figure 1 contains figs. 1(a-c) and figs. 1(d-f).
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{cleveref}
\makeatletter
\newcommand\crefretainprefix[2]{%
\begingroup%
\edef\@toksa{#1}%
\edef\@toksb{#2}%
\let\cref@acc\@empty%
\@crefretainprefix%
\cref@result%
\endgroup}%
\def\@crefretainprefix{%
\let\@iterate\relax%
\def\accum@flag{0}%
\let\@tempc\@tempb%
\cref@poptok{\@toksa}{\@tempa}%
\cref@poptok{\@toksb}{\@tempb}%
\ifx\@tempa\@tempb\relax%
\def\@iterate{\@crefretainprefix}%
\ifx\cref@acc\@empty\relax%
\let\cref@acc\@tempb%
\else%
\ifcat\@tempb\@tempc\relax%
\ifcat\@tempb a\relax%
\def\accum@flag{1}%
\else%
\expandafter\chardef\expandafter\@tempa%
\expandafter=\expandafter`\@tempb\relax%
\ifnum\@tempa>`/\relax%
\expandafter\ifnum\@tempb<`:\relax%
\def\accum@flag{1}%
\fi%
\fi%
\fi%
\fi%
\def\@tempa{1}%
\edef\cref@acc{\cref@acc\@tempb}%
\fi%
\else%
\ifcat\@tempb\@tempc\relax\else%
\edef\cref@acc{\cref@acc}%
\fi%
\edef\cref@result{\cref@acc}%
\fi%
\@iterate}%
\makeatother
\captionsetup[sub]{subrefformat=parens}
\crefrangelabelformat{subfigure}
{\crefretainprefix{#1}{#2}(#3\crefstripprefix{#2}{#1}#4--#5\crefstripprefix{#1}{#2}#6)}
\begin{document}
\Cref{fig:rub} contain \cref{fig:fse,fig:fsp,fig:fsg} and \cref{fig:cle,fig:clp,fig:clg}.
\begin{figure}[tb]
\centering
\subfloat[FS -- a]{%
\includegraphics[width=0.3\textwidth]{example-image-a}%
\label{fig:fse}%
}
\subfloat[FS -- b]{%
\includegraphics[width=0.3\textwidth]{example-image-b}%
\label{fig:fsp}%
}
\subfloat[FS -- c]{%
\includegraphics[width=0.3\textwidth]{example-image-c}%
\label{fig:fsg}%
}\par
\subfloat[CL -- d]{%
\includegraphics[width=0.3\textwidth]{example-image-a}%
\label{fig:cle}%
}
\subfloat[CL -- e]{%
\includegraphics[width=0.3\textwidth]{example-image-b}%
\label{fig:clp}%
}
\subfloat[CL -- f]{%
\includegraphics[width=0.3\textwidth]{example-image-c}%
\label{fig:clg}%
}
\caption{text}\label{fig:rub}
\end{figure}
\end{document}