# Enumeration problem redefining enumerate enivironment

I would like to redefine the enumerate environment with an optional argument. Basically I want to redefine \theenumi so that each time I label an item and call it with \ref I get the real label printed, and not just the (arabic) value of counter enumi.

I tried with the code below, and it works except for the fact it always adds an extra point (.) to each label. When I call it with \ref it prints the correct label though.

Here is a MWE of what I tried:

\documentclass{book}
\usepackage{enumerate}
%%
%%
\let\oldenumerate\enumerate
\let\endoldenumerate\endenumerate
\renewenvironment{enumerate}[1][\arabic{enumi}.]% Defaults to 1. 2. 3. ...
{%
\bgroup\renewcommand\theenumi{#1}%
\oldenumerate%
}%
{%
\endoldenumerate\egroup%
}%
\begin{document}
First list with default enumeration
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
Second list with custom enumeration
\begin{enumerate}[(\emph{\roman{enumi}})]
\item First item
\item Second item
\end{enumerate}
Labels have an extra dot in the lists, but references \ref{a} and \ref{b} are printed correctly.
\end{document}


and this is the output of the above code:

How should I redefine enumerate in order to avoid the extra dot in the lists?

-
You have loaded \usepackage{enumerate} which already gives enumerate an optional argument with a different meaning, which complicates things, You would probably be better not to load that, or if you are loading that just use \begin{enumerate}[(i)] which probably does the right thing. –  David Carlisle Apr 2 '13 at 13:33
Alternatively, use the enumitem package instead, which allows you to specify the label explicitly: \begin{enumerate}[label=(\emph{\roman*})] along with any formatting. –  Alan Munn Apr 2 '13 at 13:59
@AlanMunn Thank you very much, your solution works perfectly! Why don't you post your comment as an answer so that I can close the question? –  AndreasT Apr 2 '13 at 15:29
@AndreasT In case you're willing to implement Alan's suggestion, you may also specify how your enumerated list entries will be referred to! For instance, \begin{enumerate}[label=(\emph{\roman*}), ref=(\roman*)] would do the job. –  kan Apr 2 '13 at 15:30
@KannappanSampath Great hint, thanks! I am going to read enumitem's documentation right away –  AndreasT Apr 2 '13 at 15:33

Rather than reinventing the wheel, it's much easier to use the enumitem package for this sort of thing. For this particular example I've added a negative kern so that the parentheses are spaced nicely with the italic numeral. As Kannappan Sampath points out, you can specify the format of the references separately as well.

\documentclass{article}
\usepackage{enumitem}
\begin{document}
Second list with custom enumeration
\begin{enumerate}[label=(\kern-.5pt\emph{\roman*}),ref=(\roman*)]
\item First item \label{a}
\item Second item \label{b}
\end{enumerate}
Labels have an extra dot in the lists, but references \ref{a} and \ref{b} are printed correctly.
\end{document}


-

Here's a solution with enumitem:

\documentclass{book}
\usepackage{enumitem}
%%% Set the default: number followed by a period
\setlist[enumerate,1]{label=\arabic*.}

\begin{document}
First list with default enumeration
\begin{enumerate}
\item First item
\item\label{a} Second item
\end{enumerate}
Second list with custom enumeration
\begin{enumerate}[label=(\emph{\roman*})]
\item First item
\item\label{b} Second item
\end{enumerate}
Labels have an extra dot in the lists, and references
\ref{a} and \ref{b} are printed correctly.
\end{document}


-
Thank you @egreg, your solution works very well. Alan Munn commented first so I accepted his answer. –  AndreasT Apr 2 '13 at 15:53