12

I am using enumitem to create a list. My goal is to label each item as Case: 1, Case: 2, etc.

With the enumerate package, I was able to do

\begin{enumerate}[{Case} :1]
\item
something
...
\end{enumerate}

I tried this with enumitem but it didn't work. I also tried label = {Case} : 1 and label = {Case :} as optional arguments. In the first try, the case didn't increase from 1, and the in the second, incrementation never started start.

How can I achieve this result with enumitem?

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[not sure what to put here for desired result]
\item
\item
\end{enumerate}
\end{document}
2
  • Wouldn't it look better if the colon is at the end?
    – user31729
    Commented Apr 23, 2014 at 17:47
  • 1
    If you want to put exactly the same, just add the option \usepackage[shortlabels]{enumitem}. Then the exact same syntax will be available (plus all the extra options from enumitem).
    – Manuel
    Commented Apr 23, 2014 at 18:55

2 Answers 2

12

The package offers a set of starred versions of \alph, \Alph, \arabic, \roman and \Roman, without argument, for the current counter in enumerate, so you can use \arabic* to get the Arabic representation. A little example:

\documentclass{article}
\usepackage{enumitem}


\begin{document}

\begin{enumerate}[label={\bfseries Case \arabic*:}]
\item First.
\end{enumerate}


\end{document}

Or define a new dedicated list:

\documentclass{article}
\usepackage{enumitem}

\newlist{ecases}{enumerate}{1}
\setlist[ecases,1]{label={\bfseries Case \arabic*:}}


\begin{document}

\begin{ecases}
\item First.
\end{ecases}


\end{document}

enter image description here

As an additional useful feature, enumitem has a provision to handle user defined counters as well, using \AddEnumerateCounter or \AddEnumerateCounter* The following example illustrates a possible use of the non-starred variant (the example is a variation of one given in the package documentation):

\documentclass{article}
\usepackage{enumitem}

\makeatletter
\def\ctext#1{\expandafter\@ctext\csname c@#1\endcsname}
\def\@ctext#1{\ifcase#1\or First\or Second\or Third\or
Fourth\or Fifth\or Sixth\fi}

\AddEnumerateCounter{\ctext}{\@ctext}{Second}
\makeatother

\newlist{steps}{enumerate}{1}
\setlist[steps,1]{label={\ctext*:},align=left}

\begin{document}

\begin{steps}
\item do this.
\item do that.
\item don't do this.
\end{steps}

\end{document}

enter image description here

1
  • The colon in my example is after the counter; the change in position should be obvious. Commented Apr 23, 2014 at 17:36
7

The label is changed by using the label={\arabic*} syntax, where it can be preceded by basically any text/construction. If letters should be used, then write \alph* or \Alph* instead.

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label={\bfseries Case \arabic*:}]
\item First
\item Second
\end{enumerate}

\begin{enumerate}[label={\bfseries Case \Alph*:}]
\item \( E = mc^2 \)
\item \( c^2 = a^2 + b^2 \)
\end{enumerate}

\end{document}

enter image description here

3
  • 2
    Too many braces! ;-) Actually [label=\bfseries Case: \arabic*] suffices.
    – egreg
    Commented Apr 23, 2014 at 17:36
  • @egreg: I know, but I am fond of braces, as long as they do no harm ;-)
    – user31729
    Commented Apr 23, 2014 at 17:38
  • 1
    The % at the end of \begin{document} does not harm as well. I like it. :-) Commented Apr 24, 2014 at 8:11

You must log in to answer this question.

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