![使用“align”环境启动“proof”环境时避免换行](https://linux22.com/image/365357/%E4%BD%BF%E7%94%A8%E2%80%9Calign%E2%80%9D%E7%8E%AF%E5%A2%83%E5%90%AF%E5%8A%A8%E2%80%9Cproof%E2%80%9D%E7%8E%AF%E5%A2%83%E6%97%B6%E9%81%BF%E5%85%8D%E6%8D%A2%E8%A1%8C.png)
在 下amsthm
,如果环境中的第一个内容proof
由显示的方程式或align
类似的环境组成,则在“证明。” 标题(对我而言)是相当不受欢迎的。
对于单个方程式,我知道如何避免这种换行(尽管有些笨拙)。 在或类似的环境下,如何避免这种换行align
?
(这是用方程和垂直间距开始定理或证明,其中还询问“以这种方式开始证明是否是不好的风格?”;唯一的答案是评论说“是的,这是不好的风格”,而不是解决技术方面的问题。)
梅威瑟:
\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
我建议您使用{aligned}
带有[t]
定位说明符的环境。
\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}
附录:如果方程式必须水平居中,并且 QED 符号必须放在最右侧,与文本块的右边缘齐平,我建议您使用以下修改后的代码。
\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}
答案2
您可以尝试在之后立即添加\begin{proof}
:
\leavevmode\vadjust{\kern\dimexpr-\abovedisplayskip-\baselineskip\relax}
如果对齐范围较宽,第一行可能会与单词重叠证明。为了避免这种情况,请将其添加\phantom{\text{\itshape Proof.}}\quad
到对齐第一行的开头。
答案3
或多或少与@Harald-Hanche-Olsen 的回答类似,如果您想考虑证明标签的长度,我定义了一个\raisegroup
在之后立即使用的命令\begin{proof}
和一个在进入方程环境时使用的命令:\centregroup
\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}