[Tex/LaTex] A question about customizing ref in enumitem package

#enumeratecross-referencingenumitemlists

I'm experimenting with enumitem version 3.4 (released Aug 2011) a little but facing a problem in customizing the ref.

What I'm trying to reach is simple: Have list label in the form 1.1.3. for example. This is easy using the label* key. However, I don't want the references to take the same form as the label. This is because the dot (.) at the end is inconvenient to appear in the middle of a sentence.

So I defined the list as follows:

\newlist{procedureflow}{enumerate}{2}
\setlist[procedureflow,1]{label*=\color{blue!80!black}\arabic*.,ref=\arabic*}
\setlist[procedureflow,2]{label*=\color{green!80!black}\arabic*.,ref=\arabic{enumi}.\arabic*}

The problem with the above code is that the part ref=\arabic{enumi}.\arabic* evaluates using the current value of enumi which of course has nothing to do with the list that is yet to come later in the source file 🙁

Here is the code in which the list is created:

\begin{procedureflow}
    \item First
    \item Second
    \begin{procedureflow}
         \item First First
         \item Second Second\label{mylabel}
    \end{procedureflow}
\end{procedureflow}
Here is a cross reference: \ref{mylabel}

There are similar examples in the user guide of enumitem (chapter 5, page 9), so I wonder how could I use the ref key to have the reference displayed as 1.1.3 (i.e. without a dot at the end)? (I feel something is not right in enumitem in that regard! At least the example seems not useful to me)

Best Answer

I build a minimal example with your code fragment.

\listfiles
\listfiles
\documentclass[12pt,]{article}
\usepackage{xcolor}
\usepackage{enumitem}
\newlist{procedureflow}{enumerate}{2}
\setlist[procedureflow,1]{label*=\color{blue!80!black}\arabic*.,ref=\arabic*}
\setlist[procedureflow,2]{label*=\color{green!80!black}\arabic*.,ref=\arabic{procedureflowi}.\arabic*}
\begin{document}
\begin{procedureflow}
    \item First
    \item Second
    \begin{procedureflow}
         \item First First
         \item Second Second\label{mylabel}
    \end{procedureflow}
\end{procedureflow}
Here is a cross reference: \ref{mylabel}
\end{document}
Here is a cross reference: \ref{mylabel}
\end{document}

With this version

enumitem.sty 2011/08/06 v3.4 Customized lists

You have to use the correct counter: procedureflowi