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 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}
share|improve this question
    
Wouldn't it look better if the colon is at the end? –  Christian Hupfer Apr 23 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 at 18:55

2 Answers 2

up vote 11 down vote accepted

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

share|improve this answer
    
The colon in my example is after the counter; the change in position should be obvious. –  Gonzalo Medina Apr 23 at 17:36

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

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

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.