5

If a proof consists of only a single, less-than-a-line-long equation, there is no reason to put the \emph{Proof.} and the equation not on the same line. How can I tell LaTex this?

Here is a minimal non-working example, i.e. the proof equation is on a separate line even though I would like to have it on the same line as the \emph{Proof.}.

\documentclass{article}
\usepackage{amsmath, amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Binomial formula]
    \[
        (a+b)^2 = a^2 + 2ab + b^2
    \]
    \begin{proof}
        \[
            (a+b)^2 = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2
            \qedhere
        \]
    \end{proof}
\end{theorem}
\end{document} 

Btw, I know that I could use inline math mode, but then the equation is no longer centered and this I would like to keep up.

1
  • 5
    Add some text, you gain in pleasantness of typography and clarity.
    – egreg
    Jan 16 '15 at 15:55
10

You can center a single inline math formula by surrounding it with \hfill statements. (If you need the inline equation to be in display math mode, insert the instruction \displaystyle after the opening $.)

enter image description here

\documentclass{article}
\usepackage{amsmath, amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Binomial formula]
\[
        (a+b)^2 = a^2 + 2ab + b^2
\]
\begin{proof}
\hfill $(a+b)^2 = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2.$\hfill
\end{proof}
\end{theorem}
\end{document} 
0

What about inline math?

\documentclass{article}
\usepackage{amsmath, amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Binomial formula]
    \[
        (a+b)^2 = a^2 + 2ab + b^2
    \]
    \begin{proof}
        $
            (a+b)^2 = a^2 + ab + ba + b^2 = a^2 + 2ab + b^2
            \qedhere
        $
    \end{proof}
\end{theorem}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.