# Custom statement numbering using gather and align/aligned

Here is a proof in Latex, which renders like so:

I'm fairly pleased with the result, but I wish there were a way to turn the (1) and (2) into right-aligned elements instead of having to be manually written in.

Here is the source code for reference:

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


A possible idea I had was to use \gather environments to define those statements and wrap the meddling align*s within them, but as I had assumed, the spacing did not turn out very well, though I was able to get my line numbers to work.

Source code for the possible workaround:

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


I then read up a little more and found out about aligned, so I replied align* with aligned. It fixed the spacing from align* but created a new issue - the aligned block was numbered, but I don't want it to be numbered.

Is there a way to work around the meddling align* environments so that it doesn't space according to the gather environments and have it so that it doesn't end up being added in as another numbered statement as with aligned? Thanks!

• Strange idea... If you add an equation number to the statement, I assume you also want to only have that statement on the line, not have other elements like "With that, $a = 2k$ for $k in \Z$. Then:" Or what do you propose?
– Werner
Commented Aug 19, 2021 at 5:39
• Thanks for the note - that was a good point to consider. Yes, your assumption is correct. Commented Aug 19, 2021 at 5:49
• Real quick: How or where is \mathcom defined?
– Mico
Commented Aug 19, 2021 at 8:28
• Forgot to define that - thanks for the heads up. \mathcom is defined as {{\centering\small{{'textinput'\par}}} where 'textinput' is where the text goes. Commented Aug 19, 2021 at 8:29
• A small suggestion for code hygiene: Instead of gcd($a, b$) $\geq$ 2, please consider inputting $\gcd(a, b) \geq 2$.
– Mico
Commented Aug 19, 2021 at 10:08

I would like to suggest that you employ the machinery of the enumitem package -- specifically, its \newlist and \setlist macros -- to create a bespoke enumerated list whose \items can be cross-referenced using the usual \label/\ref mechanism.

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