I need to reference nested enumeration lists and do not want to repeat the highest level if several points of a lower level are mentioned consecutively. Thus, instead of a list like
1.1a(i), 1.1b, 1.1c
I would like to get the following result
1.1a(i), b, c
Unfortunately, I do not find a suitable solution. Here is a MWE, based on the standard cleveref
approach, which produces a strange result:
\documentclass[ngerman, 12pt]{article}
\usepackage{enumitem}
\usepackage{cleveref}
\parindent0pt
\labelcrefmultiformat{enumi}%
{\edef\crefstripprefixinfo{#1}#2#1#3}%
{ and~#2\crefstripprefix{\crefstripprefixinfo}{#1}#3}%
{, #2\crefstripprefix{\crefstripprefixinfo}{#1}#3}%
{, and~#2\crefstripprefix{\crefstripprefixinfo}{#1}#3}
\setlist[1]{leftmargin=*}
\setlist[2]{label=\alph*}
\setlist[3]{label=(\roman*)}
\begin{document}
\section{References}
\begin{enumerate}[ref=\thesection.\arabic*]
\item Fruits
\begin{enumerate}[ref=\theenumi\alph*]
\item \label{en:apples} Apples
\begin{enumerate}[ref=\theenumii(\roman*)]
\item \label{en:red} Red Apples
\item \label{en:green} Green Apples
\end{enumerate}
\item \label{en:bananas} Bananas
\item \label{en:pears} Pears
\end{enumerate}
\item \label{en:vegetables} Vegetables
\end{enumerate}
Now, I would like to reference to \labelcref{en:red,,en:bananas,,en:pears,,en:vegetables}.\\
\end{document}
Instead of
1.1a(i), b, c and 1.2.
I get the following strange result:
1.1a(i), 11.1b, 11.1c, and 1.2
However, if I don't use the lowest level and replace the reference with the following code, then it would work fine:
\labelcref{en:apples,,en:bananas,,en:pears,,en:vegetables}.
Does anyone have an idea, how to solve this also for the lowest level?