In the recent post
How to define a proof environment which can be displayed/hidden? [combining two TeX solutions],
Werner helped me to redefine a proof environment which can be hidden by an
optional boolean argument (showProof). Without an argument, somehow the
line/paragraph breaking is not correct. How can one fix this?
\documentclass{scrartcl}
\usepackage{ifthen}
\usepackage{environ}
\usepackage{amsthm}
\newboolean{showProof}% for showing proofs
\setboolean{showProof}{true}% setting the switch
\newif\ifstarttheorem
% proof environment (with hide feature)
\makeatletter
\providecommand{\env@proof@save@env}{}
\providecommand{\env@proof@process}{}
\RenewEnviron{proof}[2][showProof]{
\gdef\@tmp{#1}%
\ifthenelse{\boolean{#1}}{\par\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist\item[\hskip\labelsep\sffamily\bfseries Proof~#2]\gdef\mycurrenvir{proof}\global\starttheoremtrue\mbox{}\hfill\\*\ignorespaces
\BODY}{\ignorespaces}
}[\ifthenelse{\boolean{\@tmp}}{%
\gdef\mycurrenvir{\relax}
\popQED\endtrivlist\@endpefalse
}{\ignorespacesafterend}]
\makeatother
\begin{document}
Just some text
\begin{proof}
Just some text in a standard proof. As we can see, there is a problem.
\end{proof}
\begin{proof}[false]
Proof with optional argument set to \texttt{false}. This proof correctly does
not appear.
\end{proof}
\begin{proof}[showProof]{(Heading)}
Proof with optional argument (\texttt{true}) and second argument ``(Heading)''
\end{proof}
\end{document}


proofenvironment. Is there any reason why you useenvironspecifically? – Werner Apr 23 '14 at 19:14environ, it was just suggested in the post here http://tex.stackexchange.com/questions/172404/solution-environment-via-true-false-switch?noredirect=1#172408 for asolutionenvironment with show/hide feature, that's why I thought I can adapt it for proofs as well. If there's a simpler/easier approach, that would even be better. – Marius Hofert Apr 23 '14 at 19:18xparsepackage allows great flexibility with optional/mandatory arguments – cmhughes Apr 23 '14 at 19:22\begin{proof}{}, it gives the expected result. – Steven B. Segletes Apr 23 '14 at 19:26xparseseems to be able to address these problems. – Marius Hofert Apr 23 '14 at 19:39[..](..)for the boolean (show/not) and heading. – Werner Apr 23 '14 at 19:41