# How do I redefine a custom environment that I have previously defined elsewhere?

I made a custom class for homework assignments and I've defined a solution environment as follows:

\def\qed{\ensuremath{\square}} % <-QED Symbol
\newenvironment{solution}{%  <-Solution
\itshape{Solution:}}


This is intended to be a general purpose environment, but I am making a package specifically for use with math typesetting, and I'd like to slightly modify my solution environment when I load that package in this class... but I've tried the following and I get an error:

\let\solution\relax

\newenvironment{solution}{%  <-Solution


The error I get when trying to compile a document is

-
There is \renewenvironment. Otherwise you will need to \let\endsolution\relax. –  Qrrbrbirlbel Feb 27 '13 at 19:21
Ah, good - I suppose it would have been nice to try that first. Thanks. –  agent154 Feb 27 '13 at 19:22
@Qrrbrbirlbel please post an answer :) –  cmhughes Feb 27 '13 at 21:21


Otherwise you will also need to \let\endsolution\relax.

## Code

\documentclass{article}

% \newenvironment{<name>} defines \<name> and \end<name>
% and it checks if both are undefined (= \relax)
\newenvironment{solution}{stuff}{end stuff}

% Solution 1
% \renewenvironment{<name>} checks if both are defined (!= \relax)
\renewenvironment{solution}{other stuff}{end other stuff}

% Solution 2 (just for completeness)
%\let\solution\relax
%\let\endsolution\relax
%\newenvironment{solution}{other stuff}{end other stuff}

\begin{document}
\begin{solution}
content
\end{solution}
\end{document}

-