I use Cleveref to refer to subexamples such as "2a–c". Now I want to use crefrange to refer to 1ai–ii as well.
\documentclass[a4paper,12pt]{report}
\usepackage{philex}
\usepackage{cleveref}
% Tells Cleveref to refer to a range of subexamples without repeating the number of the example.
\crefname{ExNo}{}{}
\crefname{SubExNo}{}{}
\renewcommand{\theExNo}{\arabic{ExNo}}
\renewcommand{\theSubExNo}{\theExNo\alph{SubExNo}}
\creflabelformat{SubExNo}{(#2#1#3)}
\creflabelformat{ExNo}{(#2#1#3)}
\crefrangelabelformat{SubExNo}{(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}
% Now I define the subsublevel :
\crefname{SubSubExNo}{}{}
\renewcommand{\theSubSubExNo}{\theSubExNo\roman{SubSubExNo}}
\creflabelformat{SubSubExNo}{(#2#1#3)}
\crefrangelabelformat{SubSubExNo}{(#3#1#4--#5#2#6)}
\begin{document}
\ex. \label{lakintpur}
\a. \label{lakintpura}\a. Greg's intention was to overthrow the government. \label{intention}
\b. Greg's purpose was to overthrow the government. \label{purpose}
\z.\b.\label{lakintpurb}\a. Greg intended to overthrow the government. \label{intendv}
\b.*Greg purposed to overthrow the government. \label{purposev}
With \crefrange{lakintpura}{lakintpurb}, I can refer to a range of subexamples, 1a–b.
\par \textbf{Now I want to use crefrange to refer to 1ai–ii.}
\vspace{0.5cm}
It would also be nice to have a delimiter, since it would improve readability,
especially in such examples as "2i:i-iii" (where the first i is an actual
letter). Now using Philex syntax :
\lb{cool}{We would like no delimiter
\phildashes{}{:}
\subformat{a}{}{.}
\lba{coola}{before reference to this.}
\lba{coolb}{but a colon before reference to this}
\lbb{coolc}{and this}}
\rf{coolb} and \rf{coolc} are cool but, now referring to
\crefrange{coolb}{coolc}, I would like the result (2a:i–ii).
% Please note : as pointed out by gusbrs, crefstripprefix won't work since in i-ii, i-iii, i-iv, ii-iii and ii-iv it will skip the first "i" of the second number as being part of the prefix.
\end{document}
Thank you very much.



??you get), you need to create it forSubSubExNo, just like you did forExNoandSubExNo. However,\crefstripprefixwon't work to compress the range at this level because of the roman numbering. It strips everything that is common. So what you'll get there is "(2a:i-i)", because the first "i" of the end of the range is equal to that of the beginning of the range. – gusbrs Feb 16 '22 at 22:45\crefstripprefixcan't handle it. Besides, getting the format forSubSubExNoalready grants you correct references, even if not compressed how you want. – gusbrs Feb 17 '22 at 01:23\crefstrippreffixreplacement at the moment (but perhaps someone else is). – gusbrs Feb 17 '22 at 12:25