# [texhax] meddling with the comment environment in latex, article class

Micha Hofri hofri at WPI.EDU
Tue Nov 20 22:55:16 CET 2007

I write many homework assignments for my students that I post twice, The
second time with solutions; each problem is followed by its solution.

Naturally I want to use the same file for the two postings. My current
method: surround the solutions by \begin{comment}...\end{comment} and use
a parameter that gets a value 0 (no solutions) or 1 (with solutions),
When it is 1 an \ifthenelse kicks in that activates a \renewenvironment,
which replaces the comment delimiters by a text like "solution:"

Thus when I need to post solutions, the only editing is to change one
\newcommand argument from 0 to 1. This works well, but I "lose" the
normal use of the comment environment, which I would like to keep.

The same parameter is also used to drive changes in headers and markings,
so I would like to keep using it.  I thought of a new environment, say
solution, in which to keep the solutions, and then skip them when my
parameter is 0, but I cannot do it with the comment environment (the
\end{solution} is not caught..). there is certainly an obvious solution