This solution works by redefining \@@setcrefrange
.
For a hyperref
solution, this will need extra work.
Also the numbering-scheme of the subequations (which is actually the equation
counter) is not saved with the label (neither is the scheme of the equations (which is actually the parentequation
counter)).
The problem is that not a
, b
and so on is stored with the label but 1
, 2
and so on.
In \[C|c]refrangeformat
, #2
refers to 5
, in your case. With \@alph
, this is converted back to the e
from 1e
. There is no easy way to store the e
separately (or extract it from 1e
) clean.
In the hopes that you won’t change the subequation style every page, this should do, though. (You should be consistent throughout the document, anyway, shouldn't you?)
Code
\documentclass[varwidth]{standalone}
\usepackage{amsmath,amsfonts,amssymb,cleveref}
\makeatletter
\Crefrangeformat{equation@special}{\Cref@equation@name@plural~(#1--\@alph{#2})}
\crefrangeformat{equation@special}{\cref@equation@name@plural~(#1--\@alph{#2})}
\crefrangemultiformat{equation@special}
{\cref@equation@name@plural~(#1--\@alph{#2})}{\crefpairgroupconjunction (#1--\@alph{#2})}
{\crefmiddlegroupconjunction(#1--\@alph{#2})}{\creflastgroupconjunction (#1--\@alph{#2})}
\Crefrangemultiformat{equation@special}
{\Cref@equation@name@plural~(#1--\@alph{#2})}{\crefpairgroupconjunction (#1--\@alph{#2})}
{\crefmiddlegroupconjunction(#1--\@alph{#2})}{\creflastgroupconjunction (#1--\@alph{#2})}
\begingroup
\edef\x{\endgroup
\noexpand\def\noexpand\cref@insert@special##1\string @##2\string @##3\noexpand\@nil}
\x{\csname#1@#2@special@#3\endcsname}
\def\@@setcrefrange#1#2#3{%
\cref@getlabel{#2}{\@labela}%
\cref@getlabel{#3}{\@labelb}%
\cref@getprefix{#2}\@prefixa
\cref@getprefix{#3}\@prefixb
\ifx\@prefixa\@prefixb
\ifx\@prefix\@empty
#1{\@labela}{\@labelb}{}{}{}{}%
\else
\cref@getcounter{#3}\@counterb
\expandafter\expandafter\expandafter\cref@insert@special\expandafter\@gobble\string
#1\@nil{\@labela}{\@counterb}{}{}{}{}%
\fi
\else
#1{\@labela}{\@labelb}{}{}{}{}%
\fi}
\makeatother
\def\ra{\hfill(\texttt{range})}% only for this example
\textwidth=.6\textwidth % only for this example
\begin{document}
\Cref{eq1a,eq1b,eq1c,eq1d,eq1e,eq2a,eq2b,eq2c,eq2d,eq2e,eq3a,eq3b,eq3c,eq3d,eq3e}\par
\Crefrange{eq1a}{eq3e} \ra\par
\cref{eq1a,eq1b,eq1c,eq1d,eq1e,eq2a,eq2b,eq2c,eq2d,eq2e,eq3a,eq3b,eq3c,eq3d,eq3e}\par
\crefrange{eq1a}{eq3e} \ra
\begin{subequations}
\begin{align}
1+1=2 \label{eq1a} \\
1-1=0 \label{eq1b} \\
23+23=46 \label{eq1c} \\
d+e=f \label{eq1d} \\
e+f=g \label{eq1e}
\end{align}
\end{subequations}
\Cref{eq1a,eq1b,eq1c,eq1d,eq1e} \par \Crefrange{eq1a}{eq1e} \ra\par
\cref{eq1a,eq1b,eq1c,eq1d,eq1e} \par \crefrange{eq1a}{eq1e} \ra
\begin{subequations}
\begin{align}
1+1=2 \label{eq2a} \\
1-1=0 \label{eq2b} \\
23+23=46 \label{eq2c} \tag{*} \\
d+e=f \label{eq2d} \\
e+f=g \label{eq2e}
\end{align}
\end{subequations}
\Cref{eq2a,eq2b,eq2c,eq2d,eq2e} \par \Crefrange{eq2a}{eq2e} \ra\par
\cref{eq2a,eq2b,eq2c,eq2d,eq2e} \par \crefrange{eq2a}{eq2e} \ra
\begin{subequations}
\begin{align}
1+1=2 \label{eq3a} \\
1-1=0 \label{eq3b} \\
23+23=46 \label{eq3c} \\
d+e=f \label{eq3d} \\
e+f=g \label{eq3e} \tag{**}
\end{align}
\end{subequations}
\Cref{eq3a,eq3b,eq3c,eq3d,eq3e}\par \Crefrange{eq3a}{eq3e} \ra\par
\cref{eq3a,eq3b,eq3c,eq3d,eq3e}\par \crefrange{eq3a}{eq3e} \ra
\end{document}
Output
