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}
dustin
  • 18,617
  • 23
  • 99
  • 204
  • Wouldn't it look better if the colon is at the end? –  Apr 23 '14 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 Apr 23 '14 at 18:55

2 Answers2

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

Gonzalo Medina
  • 505,128
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