1

I would like to be able to globally showing and hiding proofs on a document, and be able to use macros to open and close the proof environments. Here is my current MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\newif\ifshowproof
\newcommand{\bp}{\ifshowproof\begin{proof}}
\newcommand{\ep}{\end{proof}}
\showprooffalse

\begin{document}
Goodbye.
\bp
Hello.
\ep\fi
Test.
\end{document}

As explored here: newcommand does not work with \fi, I cannot simply add \fi to the definition of \ep, however, I would like to have a "catch-all" macro so to say, that is, ideally something that would execute as \end{proof}\fi. Is there an easy way to do this?

1 Answers1

0

I would just use a \NewEnviron to define a Proof environment that does what you want:

enter image description here

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{environ}

\newif\ifshowproof \showprooffalse

\NewEnviron{Proof}{% \ifshowproof% \begin{proof}% \BODY \end{proof}% \fi% }%

\begin{document}

Goodbye. \begin{Proof} Hello. \end{Proof} Test.

\showprooftrue Goodbye. \begin{Proof} Hello. \end{Proof} Test.

\end{document}

Peter Grill
  • 223,288