Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
    
@lockstep — Thanks for the edit. –  jmc Mar 24 at 17:44
1  
related (but not with the specific requirement for enumitem: tex.stackexchange.com/questions/52715/… –  egreg Mar 24 at 22:26
    
@egreg — Awesome. Somehow it did not pop up out of my search. Your answer there is fabulous. –  jmc Mar 25 at 7:53

2 Answers 2

up vote 8 down vote accepted

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

share|improve this answer
    
Wonderful answer, because (i) this easily generalises to nested lists, and (ii) changing the format of labels now only needs to happen in one place. –  jmc Mar 25 at 7:54

I am not sure whether this is, what you want to achieve, but you can explicitly set the label of an item.

\documentclass[a4paper,10pt]{article}

\usepackage[]{enumitem}


\begin{document}
Foobar

\begin{enumerate}[label={(\arabic*)}]
        \item baz
        \item[\refstepcounter{enumi}(*\number\value{enumi})] xyzzy
        \item quux
\end{enumerate}

Lorem ipsum
\end{document}

I suppose, the refstepcounter statement inside the [] is necessary because the counter is not advanced if one sets the label by hand.

enter image description here

share|improve this answer
    
Awesome, thanks. In the end it was easier than I thought. I don't know why I didn't try this combo. (I was trying to difficult stuff, somewhere in the internals of enumitem.) Note that you have one * too much. In the end I did \def\staritem{\refstepcounter{enumi}\item[(*\number\value{enumi})]}. Would you mind to edit this into your answer? –  jmc Mar 24 at 17:58
    
@jmc: Regarding that extra *****: I thought you intended to so do, see your middle example in your MWE. –  Christian Hupfer Mar 24 at 18:01
    
The example only has a * in front of the digit. In the code it reads *\arabic*, but the latter * is part of the enumitem syntax. –  jmc Mar 24 at 18:03
    
@jmc: Ok, I admit: I have never used enumitem before ;-) I changed as you wished –  Christian Hupfer Mar 24 at 18:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.