TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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:


\newenvironment{solution}{%  <-Solution

The error I get when trying to compile a document is

Command \solution already defined.

share|improve this question
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

The macro \renewenvironment is there to overwrite a previous defined environment (similar to \renewcommand and \newcommand).

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



% \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)
%\newenvironment{solution}{other stuff}{end other stuff}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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