I once asked for a solution to suppress vertical space right after the beginning of a proof environment; see the link (1) below. I use this quite heavily, it works very well.
I recently asked how to hide/display solutions in an exercise; see the link (2) below. It also works very well.
I now would like to construct a proof environment which allows for the hide/show
feature. So exactly combining the two solutions of the above problems. I tried
my best but I'm not a TeX expert... see below (I obtain: ./mini.tex:55: LaTeX Error: \env@proof@save@env undefined.)
\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{environ}
\usepackage{ifthen}
\newboolean{showProof}% for showing proofs
\setboolean{showProof}{true}% setting the switch
\newboolean{sol}% for solution environment
\setboolean{sol}{true}% setting the switch
% proof environment which suppresses vertical space
% see (1) http://tex.stackexchange.com/questions/66739/how-to-suppress-vertical-space-between-proof-environment-heads-and-itemize-envir
\makeatletter
\renewenvironment{proof}[1][Proof]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\mbox{}\hfill\\*\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
% solution environment which allows to show/hide of content
% see (2) http://tex.stackexchange.com/questions/172404/solution-environment-via-true-false-switch?noredirect=1#172408
\makeatletter
\NewEnviron{solution}[1][sol]{
\gdef\@tmp{#1}
\ifthenelse{\boolean{#1}}{\par\noindent{\sffamily\bfseries Solution}\par\noindent\BODY}{\ignorespaces}
}[\ifthenelse{\boolean{\@tmp}}{}{\ignorespacesafterend}]
\makeatother
% trial to define proof environment with the feature that content can be
% shown/hidden (mix of the above two solutions)
\makeatletter
\RenewEnviron{proof}[1][showProof]{
\gdef\@tmp{#1}
\ifthenelse{\boolean{#1}}{%
\par\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist\item[\hskip\labelsep
\sffamily\bfseries #1]\gdef\mycurrenvir{proof}\global\starttheoremtrue\mbox{}\hfill\\*\ignorespaces
\BODY}{\ignorespaces}
}[\ifthenelse{\boolean{\@tmp}}{%
\gdef\mycurrenvir{\relax}
\popQED\endtrivlist\@endpefalse
}{\ignorespacesafterend}]
\makeatother
\begin{document}
This is some statement we would like to prove: $\exp(i\pi)=-1$
\begin{proof}
This should be displayed if and only if showProof is set to true.
\end{proof}
\end{document}
documentenvironment? where I got around the problem by defining the required commands so as to makeenvironhappy. More specifically, just add\makeatletter \providecommand{\env@proof@save@env}{} \providecommand{\env@proof@process}{} \makeatothersomewhere before using\RenewEnviron. – Werner Apr 22 '14 at 22:08\RenewEnviron{proof}[2][showProof]and use#2instead of the hard-coded nameProof, then it does not work anymore (I getUndefined control sequence ...with many more symbols that tex.stackexchange fails to put in a comment). Do you know why/how to fix it? – Marius Hofert Apr 22 '14 at 22:59solutionwas defined using\NewEnviron, whileproofwas redefined using\RenewEnviron. I think the definition viaenvironworks as expected... it's just a redefinition that needs a little help. – Werner Apr 22 '14 at 23:01\RenewEnviron{proof}[2][showProof]your input needs to be\begin{proof}[<opt>]{<man>}where<opt>is optional (defaults toshowProof) and<man>is mandatory. So you would need\begin{proof}{SHoWPRooF}in order for#2to be properly recognized as a "alternative" toProof. – Werner Apr 22 '14 at 23:04