I'm using the cleveref package to format references in my documents. However I am having difficulties implementing different formats for labels referring to enumerate-lists, in particular nested list.
Here is a minimal example:
\documentclass{article}
\usepackage{enumerate}
\usepackage{cleveref}
\creflabelformat{enumi}{#1(#2)#3}
\creflabelformat{enumii}{#1(#2)#3}
\begin{document}
\begin{enumerate}[(i)]
\item\label{fi} The first item
\item the second item
\begin{enumerate}[(a)]
\item the first sub-item
\item\label{ssi} the second sub-item
\end{enumerate}
\end{enumerate}
This is a fancy reference to the first item: \labelcref{fi}.
The second sub-item can be referred to as \labelcref{ssi}.
\end{document}
Ideally, I would like the first reference to be formatted as (i), and the second as (ii-b).
The actual output is the following:
As we can see, both labels look different, i() instead of (i); and iib instead of (b) [I don't how to use `creflabelformat to get (ii-b), so I went for (b) but even this doesn't work.]
I know there are a few questions, some recent, asking about formatting references to list items, but they didn't really help me.
Many thanks.
Best Answer
You can use the
label
,ref
keys from theenumitem
package to control the format for the labels and the references (I added some settings for the third and fourth nesting levels just as an illustration):