7

Under amsthm, if the first content in a proof environment consists of a displayed equation, or an align or similar environment, the linebreak after the “Proof.” heading is (to my taste) rather undesirable.

In the case of a single equation, I know how to forestall this linebreak (albeit rather kludgily). How can I avoid this linebreak in the case of an align or similar environment?

(This is a partial duplicate of Starting a theorem or a proof with an equation and vertical spacing, which also asks “Is it bad style to start a proof this way?”; the only answers there are comments are comment saying “Yes, it is bad style”, and not addressing the technical aspect.)

MWE:

\documentclass{article}
\usepackage{amssymb,amsmath,amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
  For all $x \in \mathbb{R}$, it holds that $(x+1)(x-1) + 1 = x^2$.
\end{theorem}

Single equation, with initial linebreak:
%
\begin{proof}
 \[  (x+1)(x-1) + 1 = (x^2 - x + x + 1) + 1 = x^2  \qedhere \]
\end{proof}

Single equation, without initial linebreak:
%
\begin{proof}
 \hfill $  (x+1)(x-1) + 1 = (x^2 - x + x + 1) + 1 = x^2  $ \hfill
\end{proof}

Multiple equation, with initial linebreak:
%
\begin{proof}
 \begin{align*}
   (x+1)(x-1) + 1 &= x(x-1) + 1(x-1) + 1 \\
    &= (x^2 - x) + (x - 1) + 1)  \\
    &= x^2 + (- x + x) + (-1 + 1)  \\
    &= x^2 && \qedhere
 \end{align*}
\end{proof}


\end{document}
1
  • 1
    Yes, it is bad style. ;-)
    – egreg
    Commented Nov 11, 2017 at 21:39

3 Answers 3

7

I suggest you use an {aligned} environment with a [t] positioning specifier.

enter image description here

\documentclass{article}
\usepackage{amssymb,amsmath,amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
For all $x\in\mathbb{R}$, it holds that $(x+1)(x-1)+1=x^2$.
\end{theorem}

\noindent
Single-line equation, \emph{without} initial linebreak:
\begin{proof}\quad
$\displaystyle (x+1)(x-1) + 1 = (x^2 - x + x + 1) + 1 = x^2$ 
\end{proof}

\medskip\noindent
Multi-line equation, \emph{without} initial linebreak:
\begin{proof}\quad
$\begin{aligned}[t]
   (x+1)(x-1) + 1 &= x(x-1) + 1(x-1) + 1 \\
    &= (x^2 - x) + (x - 1) + 1)  \\
    &= x^2 + (- x + x) + (-1 + 1)  \\
    &= x^2 && \qedhere
\end{aligned}$
\end{proof}

\end{document}

Addendum: if the equations have to be centered horizontally and the QED symbol has to be placed on the far right, flush with the right-hand edge of the textblock, I suggest you use the following, modified code.

\noindent
Single-line equation, \emph{without} initial linebreak:
\begin{proof}
\hfill$\displaystyle (x+1)(x-1) + 1 = (x^2 - x + x + 1) + 1 = x^2$\hfill
\end{proof}

\medskip\noindent
Multi-line equation, \emph{without} initial linebreak:
\begin{proof}
\hfill$\begin{aligned}[t]
   (x+1)(x-1) + 1 
       &= x(x-1) + 1(x-1) + 1 \\
       &= (x^2 - x) + (x - 1) + 1)  \\
       &= x^2 + (- x + x) + (-1 + 1)  \\
       &= x^2 & \qquad\qquad\qedhere
\end{aligned}$
\end{proof}

enter image description here

2
  • Your final \hfill doesn't do a thing, because the following implied \par undoes it. So you must resort to adjusting the spacing by hand, as you did here with \qquad\qquad. I actually think my solution is cleaner (but the voters disagree, so I could be mistaken about that). Commented Nov 11, 2017 at 20:59
  • @HaraldHanche-Olsen - Thanks for this. I've edited the second code block to omit the final \hfill directive.
    – Mico
    Commented Nov 11, 2017 at 21:55
6

You could try adding this immediately after \begin{proof}:

\leavevmode\vadjust{\kern\dimexpr-\abovedisplayskip-\baselineskip\relax}

If your alignment is wide, the first line might overlap the word Proof. To avoid this, add \phantom{\text{\itshape Proof.}}\quad to the beginning of the first line of your alignment.

4

More or less in the vein of @Harald-Hanche-Olsen's answer, I define a \raisegroup command to be used just after \begin{proof} and a \centregroup to be used on entering the equation environment if you want to take into account the length of the proof label:

\documentclass{article}
\usepackage{amssymb,amsmath,amsthm}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}

\newlength{\movedby}
\settowidth{\movedby}{\textit{Proof.}}
\newcommand\centregroup{\hspace*{0.5\movedby}}
\newcommand{\raisegroup}{\leavevmode\setlength{\abovedisplayskip}{0pt}\vspace{-\baselineskip}}

\begin{document}

\begin{theorem}
  For all $x \in \mathbb{R}$, it holds that $(x+1)(x-1) + 1 = x^2$.
\end{theorem}

Single equation:
%
\begin{proof}\raisegroup
 \[ \centregroup(x+1)(x-1) + 1 = (x^2 - x + x + 1) + 1 = x^2 \qedhere \]
\end{proof}

Multiple equation:
%
\begin{proof}\raisegroup
 \begin{align*}
 (x+1)(x-1) + 1 &= x(x-1) + 1(x-1) + 1 \\
    &= (x^2 - x) + (x - 1) + 1) \\
    &= x^2 + (- x + x) + (-1 + 1) \\
    &= x^2 && \qedhere
 \end{align*}
\end{proof}

\end{document} 

enter image description here

10
  • 1
    Probably a new environment called mathonlyproof (or whatever), is better. But I'd discourage such formula only proofs.
    – egreg
    Commented Nov 11, 2017 at 21:38
  • 1
    I agree with you. However there may be some rare special cases for which it might be useful.
    – Bernard
    Commented Nov 11, 2017 at 21:42
  • 1
    “The above answer” is rather ambiguous, don't you think? The order seems to change according to votes, the moon phase, and possibly other factors. I like it, though. Perhaps because I imagine it is my answer you are referring to. ;-) Commented Nov 11, 2017 at 21:56
  • 1
    It is indeed. I'll fix my answer, as you're no more ‘above’ ;o)
    – Bernard
    Commented Nov 11, 2017 at 22:01
  • 1
    However, this approach will fail if the first line of the alignment is really tall, like a matrix or something. But in that case, perhaps it will be better to abandon the notion of lining the equation up with the word Proof. I think it might look silly, in fact. Then there are in-between cases, where the first line contains sums or integrals. For that, perhaps just add some vertical space before the proof environment. Commented Nov 13, 2017 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .