My question is very similar to this one, however my situation is more specific and I'm wondering whether there isn't a simpler (and more performant) solution than executing code for every paragraph:
I wrote a small macro to structure lengthy proofs and highlight key steps, called \proofpart
. To set apart the step in question from the preceding step of the proof it uses \noindent
and, before, adds some \vspace
. Now the problem arises when I use it at the very beginning of a proof: In this case \vspace
influences the positioning of my entire proof and increases its top margin. How can I fix this?
MWE:
\documentclass[12pt,a4paper]{memoir}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{blindtext}
\usepackage{amsthm}
\usepackage{thmtools}
\newcommand{\proofpart}[1]{%
\vspace{0.7em}%
\noindent%
\textsc{#1}%
}
\declaretheoremstyle[
spaceabove=2em,
spacebelow=2em,
postheadspace=1em,
headfont=\upshape\bfseries,
notefont=\mdseries,
notebraces={(}{)},
bodyfont=\normalfont,
]{mytheoremstyle}
\declaretheoremstyle[
spaceabove=-1em, % <-- reduce margin, so that it is clear that the
% proof belongs to the previous theorem/lemma/…
%
spacebelow=2em,
postheadspace=1em,
% headfont=\itshape,
headfont=\upshape\bfseries,
bodyfont = \normalfont,
qed=$\qedsymbol$,
headpunct={:},
]{myproofstyle}
\newcounter{mathcounter}
\numberwithin{mathcounter}{chapter}
\declaretheorem[
name={Theorem},
style=mytheoremstyle,
numberlike=mathcounter
]{theorem}
% Remove amsthm's proof environment, so that we can override it below.
\let\proof\undefined
\let\endproof\undefined
\declaretheorem[
name={Proof},
style=myproofstyle,
numbered=no
]{proof}
\begin{document}
\begin{theorem}
\blindtext
\end{theorem}
\begin{proof}
Some preliminary remarks.
\proofpart{Step 1:} % <-- No problem here
Foo
\proofpart{Step 2:} % <-- No problem here
Bar
\end{proof}
\begin{theorem}
\blindtext
\end{theorem}
\begin{proof}
\proofpart{Step 1:} % <-- This will increase spacing between theorem and proof
Foo
\proofpart{Step 2:} % <-- No problem here
Bar
\end{proof}
\end{document}