# Def in renewenvironment

I redefine a custom environment of mine that uses "local variables":

\newenvironment{asdf}[3]{
\def\argi{#1}
\def\argii{#2}
\def\argiii{#3}
%....
}
{ }


But when I do:

\renewenvironment{asdf}[3]{
\def\argi{#1}
\def\argii{#2}
\def\argiii{#3}
%....
}
{ }


later on in the document, LaTeX claims

! Illegal parameter number in definition of \test


And also, I have no idea where \test comes from.

-
Will's answer shows that in such cases you should always include a minimal working example, not just the code snippet. –  Hendrik Vogt Dec 6 '10 at 13:25

Works for me:

\documentclass{article}
\begin{document}
I redefine a custom environment of mine that uses "local variables":
\newenvironment{asdf}[3]{
\def\argi{#1}
\def\argii{#2}
\def\argiii{#3}
%....
}
{ }
But when I do:
\renewenvironment{asdf}[3]{
\def\argi{#1}
\def\argii{#2}
\def\argiii{#3}
%....
}
{ }
\end{document}


I suspect here's more you're not telling us, such as that you have the \renewenvironment inside something else. Don't forget that if you have \renewenvironment inside another macro, you need to double the # signs:

\def\reset{%
\renewenvironment{asdf}[3]{
\def\argi{##1}
\def\argii{##2}
\def\argiii{##3}
}
{ }
}

-
Would \def\foo{\def\bar{\renewenvironment{asdf}[3]... require ###1? –  Seamus Mar 22 '11 at 18:08
@Seamus: No, ####1; you have to double each #. –  Hendrik Vogt Mar 22 '11 at 18:22