This question is a follow-up from
Solution environment via true/false switch
where Ian helped me to define a solution environment which can be hidden. I
tried it as well for a proof environment, but proof is already defined. I
tried to work with \RenewEnviron and followed
How to ignore everything in the document environment?
to get past the first error, but now I get LaTeX Error: \env@proof@save@env undefined. I am looking for a fix (rather than a suggestion to stick with the
already defined environment or to use a different name).
\documentclass{scrartcl}
\usepackage[american]{babel}
\usepackage{environ}
\usepackage{amsthm}
\usepackage{amsmath}
\newif\ifshowproof
\showprooftrue
% proof environment
\makeatletter
\providecommand{\env@document@save@env}{}%
\providecommand{\env@document@process}{}%
\RenewEnviron{proof}[1][showproof]{%
\csname if#1\endcsname
\trivlist
\item\relax{\sffamily\bfseries Proof}\par\noindent
\BODY
\endtrivlist
\fi
}
\makeatother
\begin{document}
Proof with hide feature:
\begin{proof}[false]
This should not appear
\end{proof}
Proof without hide feature:
\begin{proof}
This should appear
\end{proof}
\end{document}

\let\proof\relax\let\endproof\relaxand to remove the useless\providecommandinstructions. – egreg Apr 26 '14 at 19:13\let\proof...statement at? instead of the\providecommandor inside? I tried various versions but they give me errors. – Marius Hofert Apr 26 '14 at 19:20\RenewEnvironshould become\NewEnviron. – egreg Apr 26 '14 at 19:22