2

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?

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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