[Tex/LaTex] How to change the label of one item in an enumitem list

enumitemlists

I want to change the label of one item in a list. I am using the enumitem package, I am very fond of it, and I have to keep using it (lots of other code would break).

MWE:

\documentclass[a4paper,10pt]{article}

\usepackage[]{enumitem}

\begin{document}
Foobar

\begin{enumerate}[label={(\arabic*)}]
        \item baz
\end{enumerate}
\begin{enumerate}[resume,label={(*\arabic*)}]
        \item xyzzy
\end{enumerate}
\begin{enumerate}[resume,label={(\arabic*)}]
        \item quux
\end{enumerate}

Lorem ipsum
\end{document}

The result is a list

 (1) baz
(*2) xyzzy
 (3) quux

However, I would like to do something like

\documentclass[a4paper,10pt]{article}

\usepackage[]{enumitem}

\begin{document}
Foobar

\begin{enumerate}[label={(\arabic*)}]
        \item baz
        \staritem xyzzy
        \item quux
\end{enumerate}

Lorem ipsum
\end{document}

It would be very cool if the enumitem package would make code like \item[label=(*\arabic*)] possible. But as far as I know, an easy solution is not available.

What would you do? Please define a command \staritem in your answer, as this would be a more orthogonal solution than hacking it straight into the document text. Alternatively, hacking \item to accept options (as in \item[label=(*\arabic*)]) would be awesome!

Best Answer

Put the asterisk in the specification of the label:

\documentclass[a4paper,10pt]{article}

\usepackage{enumitem}

\newcommand{\staritem}{\global\asterisktrue\item}
\newcommand{\perhapsasterisk}{%
  \ifasterisk*\global\asteriskfalse\fi
}
\newif\ifasterisk

\begin{document}
Foobar

\begin{enumerate}[label={(\protect\perhapsasterisk\arabic*)}]
\item baz
\staritem xyzzy
\item quux
\staritem xxx
\end{enumerate}

Lorem ipsum
\end{document}

enter image description here

Related Question