等式与证明在同一行

等式与证明在同一行

如果证明仅包含一个长度不足一行的方程式,则没有理由将\emph{Proof.}和方程式放在同一行之外。我该如何告诉 LaTex 这一点?

这是一个最小的非工作示例,即证明方程在单独的行上,即使我想将它与放在同一行上\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} 

顺便说一句,我知道我可以使用内联数学模式,但这样等式就不再居中了,我想保留这一点。

答案1

您可以通过用语句包围单个内联数学公式来使其居中\hfill。(如果您需要内联方程处于显示数学模式,请\displaystyle在开头后插入指令$。)

在此处输入图片描述

\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} 

答案2

那么内联数学怎么样?

\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}

相关内容