4

I have a use case description, something along the lines of:

\begin{enumerate}
    \item User does X.
    \item User does Y. \label{y}
    \item User does Z. \label{z}
\end{enumerate}

Then there is an alternative path that deviates from action Y. It is shown in a different list. I would like to start that list with the value of the Y item above (in this case, the second list would start at 2). I tried:

\begin{enumerate}
    \setcounter{enumi}{\ref{y}}\addtocounter{enumi}{-1}
    \item User does Y2.
    \item Continue with Z (\ref{z}).
\end{enumerate}

However, this only works when the index has been made already. Otherwise, I get:

! Missing number, treated as zero.

What is the correct way to do this?

1
  • 1
    You can see the package refcount or, more generally, zref.
    – egreg
    Dec 10, 2015 at 23:04

1 Answer 1

4

You could use refcount (as egreg already proposed) in conjunction with the enumitem package and its start=... feature (no need to use \setcounter{enumi}{...} explicitly then.

\documentclass{article}

\usepackage{refcount}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
    \item User does X.
    \item User does Y. \label{y}
    \item User does Z. \label{z}
\end{enumerate}

\begin{enumerate}[start={\getrefnumber{y}}]
%    \setcounter{enumi}{\ref{y}}\addtocounter{enumi}{-1}
    \item User does Y2.
    \item Continue with Z (\ref{z}).
\end{enumerate}



\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .