3

I use amsthm to define a "Solution" environment. I want to be able to hide it. Following this comment I tried using the comment package:

\documentclass{article}

\usepackage{amsthm}
\newtheorem*{solution*}{Solution}
\usepackage{comment}
\excludecomment{solution*}

\begin{document}
Foo
  \begin{solution*}
    Bar
  \end{solution*}
Baz
\end{document}

However this doesn't work because my solution environment is indented and the comment package requires

The opening and closing commands should appear on a line of their own. No starting spaces, nothing after it.

So my question is: how can I hide an indented solution environment defined with amsthm?

petobens
  • 3,306

1 Answers1

5

Capture the solution* environment contents using the powers provided by environ and never display it:

\documentclass{article}

\usepackage{amsthm}
\newtheorem*{solution*}{Solution}
%\usepackage{comment}
%\excludecomment{solution*}

\usepackage{environ}
\RenewEnviron{solution*}{}% or \RenewEnviron{solution*}{\par}

\begin{document}
Foo
  \begin{solution*}
    Bar
  \end{solution*}
Baz
\end{document}

Depending on the application, you may want to issue \par, or something to the effect that may separate the contents above solution* from that below.

Werner
  • 603,163