# How to suppress vertical space between proof environment heads and itemize environments?

The user 'egreg' recently helped me to suppress vertical space between theorem heads and enumitem environments (such as itemize; see the link below). I now have a similar problem: When a proof environment starts with an itemize, there is too much vertical space. How can the proof environment be redefined such that this space is (at least party) suppressed?

Ideally, it should be a "clean" solution, so that one can type \begin{proof} followed by \begin{itemize} and no complicated commands in-between.

By redefining the proof environment as a theorem, one could circumvent the problem, but how can the q.e.d. symbol be nicely placed? Not sure if that's a good approach.

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{etoolbox}
\usepackage{enumitem}

% theorems
\newif\ifstarttheorem
\newtheoremstyle{mythmstyle}%
{0.5em}%
{0.5em}%
{}%
{}%
{\sffamily\bfseries\global\starttheoremtrue}%
{}%
{\newline}%
{\thmname{#1}\ \thmnumber{#2}\ \thmnote{(#3)}}%
\theoremstyle{mythmstyle}%

% proofs
\renewcommand*\proofname{Proof}
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\mbox{}\hfill\\*\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother

% suppress vertical spacing (for itemize) when newtheorems start with an environment
% see http://tex.stackexchange.com/questions/60001/nested-enumerate-enumitem-interferes-with-suppressing-vertical-space-after-the
\makeatletter
\preto\itemize{%
\if@inlabel
\ifstarttheorem
\mbox{}\par\nobreak\vskip\glueexpr-\parskip-\baselineskip+0.3em\relax\hrule\@height\z@
\global\starttheoremfalse
\fi
\fi}
\preto\enditemize{\global\starttheoremfalse}
\makeatother

% document
\begin{document}
Let's prove something:
\begin{proof}
\begin{align*}
\end{align*}
\end{proof}
Here a nicer vertical spacing:
\begin{proof}
Just some text:
\begin{align*}
\end{align*}
\end{proof}
Here a version with itemize:
\begin{proof}
\begin{itemize}
\item $x=y,\quad y=z\quad\Rightarrow\quad x=z.$
\end{itemize}
\end{proof}
\end{document}

-

You can try the following. Here the environment proof gets a new flag \starttheoremtrue and the name of the environment is saved inside the command \mycurrenvir.

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{etoolbox}
\usepackage{enumitem}

% theorems
\newif\ifstarttheorem
\newtheoremstyle{mythmstyle}%
{0.5em}%
{0.5em}%
{}%
{}%
{\sffamily\bfseries\global\starttheoremtrue}%
{}%
{\newline}%
{\thmname{#1}\ \thmnumber{#2}\ \thmnote{(#3)}}%
\theoremstyle{mythmstyle}%

% proofs
\renewcommand*\proofname{Proof}
\makeatletter% q.e.d. adjustment (posted by ???)
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont\topsep2\p@\@plus2\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries #1]\gdef\mycurrenvir{proof}\global\starttheoremtrue\mbox{}\hfill\\*\ignorespaces
}{%
\gdef\mycurrenvir{\relax}
\popQED\endtrivlist\@endpefalse
}
\makeatother

% suppress vertical spacing (for itemize) when newtheorems start with an environment
% see http://tex.stackexchange.com/questions/60001/nested-enumerate-enumitem-interferes-with-suppressing-vertical-space-after-the
\makeatletter
\preto\itemize{%
\if@inlabel
\ifstarttheorem
\mbox{}\par\nobreak\vskip\glueexpr-\parskip-\baselineskip+0.3em\relax\hrule\@height\z@
\global\starttheoremfalse%
\fi%
\fi%
\def\tempa{proof}%
\ifx\tempa\mycurrenvir
\ifstarttheorem
\mbox{}\par\nobreak\vskip\glueexpr-\parskip-\baselineskip+0.3em\relax\hrule\@height\z@
\global\starttheoremfalse%
\fi%
\fi%
}
\preto\enditemize{\global\starttheoremfalse}
\makeatother

% document
\begin{document}
Let's prove something:
\begin{proof}
\begin{align*}
\end{align*}
\end{proof}
Here a nicer vertical spacing:
\begin{proof}
Just some text:
\begin{align*}
\end{align*}
\end{proof}
Here a version with itemize:
\begin{proof}
\begin{itemize}
\item $x=y,\quad y=z\quad\Rightarrow\quad x=z.$
\end{itemize}
\end{proof}
\end{document}


-
works nicely with itemize, even using \qedhere. but with enumerate there's still a big gap between the heading and the first item (and \qedhere isn't the cause). –  barbara beeton Aug 11 '12 at 16:04
Thanks a lot, Marco. @Barbara: Just redefine enumerate (as for itemize) and it works –  Marius Hofert Aug 11 '12 at 16:11
Marco, if a proof environment is directly followed by an align environment, do you know how to suppress the space in this situation? –  Marius Hofert Aug 11 '12 at 16:16
@MariusHofert: I would use the same redefinition. –  Marco Daniel Aug 11 '12 at 18:20
Thanks Marco. It's a bit difficult to understand since I do not see how the trick for the itemize environment can be adapted to an align. If possible, can you give the answer in your answer, please? [I could also file a new question for this] –  Marius Hofert Aug 11 '12 at 20:18