# A new environment based on enumerate

I have defined the following simple environment:

\newenvironment{renumerate}{\begin{enumerate}\raggedright}{\end{enumerate}}


I wonder how the above can be modified to use with, say, the following:

\begin{renumerate}[label=\color{blue}10.\theenumi]
\item blah
\item blah
\end{renumerate}


The options given in [] are not known in advance.

-

Since you're already loading the enumitem package, it makes sense to use the in-built command newlist that it provides for exactly this purpose

\newlist{renumerate}{enumerate}{3}
\setlist[renumerate]{label=\arabic*,before=\raggedright}


This sets up the renumerate environment to be based on the standard enumerate environment. The {3} at the end specifies the maximum depth- you can change this as you see fit.

The setlist command is important as it provides the default behaviour of the list. The environment, by default(!), can take optional arguments, thanks to the wizardry of the enumitem package.

\documentclass{article}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{lipsum}

\newlist{renumerate}{enumerate}{3}
\setlist[renumerate]{label=\arabic*,before=\raggedright}

\begin{document}

\begin{renumerate}[label=10.\arabic*,font=\color{blue}]
\item \lipsum[1]
\item \lipsum[1]
\item \lipsum[1]
\end{renumerate}

\lipsum[1]

\begin{renumerate}
\item \lipsum[1]
\item \lipsum[1]
\item \lipsum[1]
\end{renumerate}

\end{document}

-
Works as said on the tin. –  Reza Jan 21 '13 at 23:01

Add an "empty" optional argument to the environment:

\documentclass{article}
\usepackage{enumitem,xcolor}% http://ctan.org/pkg/{enumitem,xcolor}
\newenvironment{renumerate}[1][,]{\begin{enumerate}[#1]\raggedright}{\end{enumerate}}
\begin{document}
\begin{renumerate}[label=\color{blue}10.\theenumi]
\item blah
\item blah
\end{renumerate}
\begin{renumerate}
\item blah
\item blah
\end{renumerate}
\end{document}


The "empty" optional argument is given as ,. As reference for the use of mandatory/optional arguments with environments, either see source2e (texdoc source2e) or LaTeX help with \newenvironment.

Perhaps more in line with enumitem style, you could use

\begin{renumerate}[label=10.\arabic*,font=\color{blue}]
\item blah
\item blah
\end{renumerate}

-
+1 it seems a little more inline with enumitem to use [label=10.\arabic*,font=\color{blue}]. Same result of course –  cmhughes Jan 21 '13 at 18:24
[resume] is not working as shown here: \documentclass{article} \usepackage{enumitem,xcolor}% ctan.org/pkg{enumitem,xcolor} \newenvironment{renumerate}[1][,]{\begin{enumerate}[#1]\raggedright}{\end{enumer‌​ate}} \begin{document} \begin{renumerate}[label=\color{blue}10.\theenumi] \item blah \item blah \end{renumerate} \begin{renumerate} \item blah \item blah \end{renumerate} \begin{renumerate}[resume] <-- \item blah \item blah \end{renumerate} \end{document} –  Reza Jan 21 '13 at 20:23
@Reza: I'll look into this later. It may be that definitions that resume rely on are localized due to the nature of \newenvironment. Setting up a list using \newlist (as in cmhughes' answer) circumvents this, and might be the more appropriate alternative. –  Werner Jan 21 '13 at 20:46
Thanks Werner for your reply. I had a look at cmhughes'answer. It is fine with [resume] however I cannot get it working with other options say \raggedright, i.e. I want \begin{renumerate}....\end{\enumerate} to always ragged right the items without me having to add \raggedright manually. –  Reza Jan 21 '13 at 20:56
@Reza see my updated answer which includes raggedright –  cmhughes Jan 21 '13 at 22:07