25

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?

24

One possibility is to use the xparse package:

\usepackage{xparse}
\NewDocumentEnvironment{mylist}{m}{%
  \begin{#1}%
  % other code
}{%
  \end{#1}%
}
  • 7
    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 T. Oct 29 '11 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.