使用 gather 和 align/aligned 自定义语句编号

使用 gather 和 align/aligned 自定义语句编号

以下是 Latex 中的证明,其呈现效果如下:

在此处输入图片描述

我对结果非常满意,但我希望有一种方法可以将(1)(2)转换为右对齐元素,而不必手动写入。

以下是供参考的源代码:

\begin{proof}[Proof.]
    Assumption ($\neg S$): $\sqrt{2}$ is rational.
\begin{align*}
    \sqrt{2} &= \frac{a}{b} \text{ $a, b$ in reduced form, $a, b \in \Z$, gcd($a, b$) = 1} \\
    2 &= \frac{a^{2}}{b^{2}} \\
    2b^{2} &= a^{2}
\end{align*}
(1) Since $a^{2} = 2b^{2}$, can say $a^{2}$ is even. With that, $a = 2k$ for $k in \Z$. Then:
\begin{align*}
    2b^{2} &= (2k)^{2} \\
    2b^{2} &= 4k^{2} \\ 
    b^{2} &= 2k^{2}
\end{align*}
(2) Similarly, since $b^{2} = 2k^{2}$, can say that $b^{2}$ (and $b$) is even.

Given (1) and (2), that both $a, b$ are even, then gcd($a, b$) $\geq$ 2.

\mathcom{Contradiction: gcd($a, b$) $\neq$ 1 when gcd($a, b$) $\geq$ 2.}
$\neg S$ ($\sqrt{2}$ is rational) is clearly false; because of this, $S$ must be true.
\[\therefore \sqrt{2} \text{ is irrational.}\]    
\end{proof}

我曾想到的一个可能的想法是使用\gather环境来定义这些语句并将干扰包装align*在其中,但正如我所假设的那样,尽管我能够使行号正常工作,但间距效果并不好。

在此处输入图片描述

可能的解决方法的源代码:

\begin{gather}
    \text{Statement} \\
\begin{align*}
    2b^{2} &= (2k)^{2} \\
    2b^{2} &= 4k^{2} \\ 
    b^{2} &= 2k^{2}
\end{align*} \\
    \text{Another statement}
\end{gather}

然后我又读了一些,发现了aligned,所以我回复align*aligned。它修复了 的间距,align*但产生了一个新问题 - 该aligned块已编号,但我不希望它被编号。

在此处输入图片描述

有没有办法解决干扰align*环境的问题,使其不会根据gather环境而留出空间有它,这样它就不会像 一样被添加为另一个编号语句aligned?谢谢!

答案1

我建议您使用该enumitem包的机制 - 特别是它的\newlist\setlist宏 - 来创建一个定制的枚举列表,该列表可以使用通常的/机制\item进行交叉引用。\label\ref

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\newcommand\mathcom[1]{\begin{center}#1\end{center}}
\newcommand\N{\mathbb{N}}

\usepackage{enumitem}
%% create a bespoke enumerate-like list:
\newlist{myenum}{enumerate}{1}
\setlist[myenum,1]{label=\upshape(\arabic*), noitemsep, left=0pt}

\begin{document}
\noindent
Prove that $\sqrt{2}$ is irrational.
\begin{proof}
Assumption ($\neg S$): $\sqrt{2}$ is rational, i.e.,
\[
    \sqrt{2} = \frac{a}{b}\text{ for some integers $a, b \in \N$.} 
\]
W.l.o.g.\ we assume that $a$ and $b$ are in reduced form, i.e., $\gcd(a, b) = 1$.

\medskip
By assumption $\neg S$, $2 = a^{2}/b^{2}$ or $2b^{2} = a^{2}$. 

\begin{myenum}
\item \label{point:a} 
Since $a^{2} = 2b^{2}$, we deduce that $a^{2}$ and $a$ even. With that, $a = 2k$ for $k\in\N$. 

Then:
\begin{align*}
    2b^{2} &= (2k)^{2} \\
    2b^{2} &= 4k^{2} \\ 
    b^{2} &= 2k^{2}\,.
\end{align*}
\item \label{point:b} 
Similarly, since $b^{2} = 2k^{2}$, we deduce that $b^{2}$ and $b$ are even.
\end{myenum}

Given  points \ref{point:a} and \ref{point:b}, both $a$ and $b$ are even. Therefore $\gcd(a, b) \geq 2$.

\mathcom{\textsc{Contradiction}: $\gcd(a, b) = 1$ but also $\gcd(a, b) \geq2$.}

Thus, $\neg S$ (``$\sqrt{2}$ is rational'') is false. Because of this, $S$ must be true.
\[
\therefore\ \sqrt{2}\text{ is irrational.}\qedhere
\]    
\end{proof}
\end{document}

相关内容