I have defined an environment called answer that displays the answer of a question of a test I'm supposed to prepare.
The idea is to compile a version where the answers are displays and one were they are not (in order to test the students).
Is there an elegant way to disable environments?
One can of course define a command \ifanswer and then write \ifanswer{\begin{answer}foo\end{answer}}. For each environment. The problem with this approach however is that one needs to remember and insert this command each time, and of course forgetting this one time would be embarrassing.
MWE:
\documentclass{article}
\newenvironment{answer}{\textit{Answer} }{\textit{the end.}}
\begin{document}
Question: Bla
\begin{answer}
Foo
\end{answer}
\end{document}
commentpackage which has facilities to turn environments into comments – David Carlisle Mar 14 '14 at 13:58examclass, example shown here. – Mike Renfro Mar 14 '14 at 20:14