# Passing \newenvironment parameters to the end block?

I am attempting to construct a new environment which will allow me to format arbitrary list types (itemize, enumerate, description etc.) with the new environment. As such I am passing it as a parameter to the new environment but it complains when I attempt the following:

\newenvironment{mylist}[1]
{
\begin{#1}
#Environment definition here
}
{\end{#1}}


I get the following error:

! Illegal parameter number in definition of \endmylist. 1 l.15 {\end{#1}}

How can I pass my parameters into the end block?

-
The reason why you can't use arguments in the "end" part of the definition of a new environment and some possible solutions are given in Why can't the end code of an environment contain an argument?. – Gonzalo Medina Jun 13 '11 at 2:03

One possibility is to use the xparse package:

\usepackage{xparse}
\NewDocumentEnvironment{mylist}{m}{%
\begin{#1}%
% other code
}{%
\end{#1}%
}

-
Thank you, very useful package. As a side note for everyone who, like me, doesn't know xparse the {m} parameter is specified just like table columns. The m stands for "mandatory parameter". – Riccardo Oct 29 '11 at 14:00