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

Eduardo M KALINOWSKI ekalin at gmail.com
Tue Nov 20 23:54:16 CET 2007

On Nov 20, 2007 7:55 PM, Micha Hofri <hofri at wpi.edu> wrote:
> 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
> that evades me.

See the documentation for the comment package. You can achieve what
you currently have in an easier way with \includecomment and

More information about the texhax mailing list