2

It would like to modify the proof environment of amsart in such a way that if a boolean variable, say solution is set to true in the preamble of the document, then the environment works as usual, but otherwise \begin{proof} content \end{proof} has no effect (i.e. is not printed). Is there a way to do this using etoolbox?

1 Answer 1

3

Not with etoolbox, but with comment:

\documentclass{amsart}

\usepackage{comment}
\makeatletter
\newcommand\pr@@fon{%
  \includecomment{proof}%
  \let\proof\savedproofenv
  \let\proofon\@empty}
\newcommand\proofoff{%
  \ifx\proofon\@empty
    \let\savedproofenv\proof
    \excludecomment{proof}%
    \let\proofon\pr@@fon
  \fi}
\newcommand*\proofon{}%

\proofon

\begin{document}

\begin{proof}
  A proof that is typeset
\end{proof}

\proofoff
\begin{proof}
  A proof that is removed
\end{proof}

\proofon
\begin{proof}
  Another proof that is typeset
\end{proof}

\end{document}

enter image description here

6
  • Many thanks! Also, apologies, I have not made myself clear. The boolean variable is set in the preamble of the document.
    – 220284
    Jul 15, 2021 at 13:01
  • @220284 You're welcome! You can move \proofon and \proofoff to the preamble of the document. I put them in the middle just to show that they work Jul 15, 2021 at 13:02
  • Great, will give it a shot!
    – 220284
    Jul 15, 2021 at 13:03
  • Hm, if I put \proofoff in the preamble it works fine, but if I put \proofon it get the error that the proof environment is undefined.
    – 220284
    Jul 15, 2021 at 13:21
  • @220284 Indeed, \proofon assumed \proofoff was used somewhere. I edited my answer with a more robust version Jul 15, 2021 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .