1

I am new to Latex, and I am having some trouble with the align* environment. In the code below, the first two equations are horizontally spaced differently from the second two equations:

\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{amsmath,amsthm,amssymb}
\usepackage{amsmath}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\ex}{\:\exists\,}
\newcommand{\nex}{\:\nexists\,}
\newcommand{\all}{\:\forall\,}
\newcommand{\imp}{\Longrightarrow}
\begin{document}
For $A:=\left\{\dfrac{1}{n}-\dfrac{1}{m}:n,m\in\N\right\}$, $\sup(A) = 1, \inf(A)=-1$.\\\\

\textit{Proof}. Suppose for contradiction that $1$ is not an upper bound for $A$, i.e. $\exists n,m \in \mathbb{N} \mid \dfrac{1}{n} - \dfrac{1}{m} > 1$.

\begin{align*}
\iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} > 1\\
\iff&\frac{m-n}{mn}>1\\
\iff& m-n> mn\\
\iff& m > mn + n\\
\iff& m > n(m+1)\\
\text{Because }n(m+1)\geq m+1,\text{ we have}\\
\iff& m > n(m+1) \geq m+1\\
\iff& m > m+1 &\bot\\
\end{align*}

$\newline$Suppose for contradiction that $-1$ is not a lower bound for $A$, i.e. $\ex n,m \in \N \mid$\\$ \dfrac{1}{n} - \dfrac{1}{m} < -1$.
\begin{align*}
\iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} < -1\\
\iff&\frac{m-n}{mn}<-1\\
\iff& m-n<-mn\\
\iff& m +mn < n\\
\iff& m(1+n)< n\\
\text{Because }m(1+n)\geq 1+n, \text{ we have}\\
\iff& 1+n \leq m(1+n) < n\\
\iff& 1+n < n &\bot
\end{align*}
$\newline\newline$ Claim that $\lim\limits_{n=1, m \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = 1$, or $\all \epsilon \in (0,\infty) \ex M \in \N \mid m \in \N: m>M \imp$\\$ \left|(1 - \dfrac{1}{m}) - 1\right| < \epsilon $.

\begin{align*}
\iff& \left| 1 - 1 - \frac{1}{m}\right|<\epsilon\\
\iff& \left|-\frac{1}{m}\right|<\epsilon\\
\iff& \frac{1}{m}<\epsilon\\
\iff& m > \frac{1}{\epsilon}
\end{align*}
Hence, for $M:=\left\lceil\dfrac{1}{\epsilon}\right\rceil+1$, $ m > M \imp \left| 1 - 1 - \dfrac{1}{m}\right|<\epsilon$. Because $\epsilon$ was arbitrarily chosen, it follows that $\lim\limits_{n=1, m \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = 1$.

$\newline\newline$ Claim that $\lim\limits_{m=1, n \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = -1$, or $\all \epsilon \in (0,\infty) \ex N \in \N \mid n \in \N: n>N \imp$\\$ \left|(\dfrac{1}{n}-1) -(-1)\right| < \epsilon $.

\begin{align*}
\iff& \left| -1 - (-1) + \frac{1}{n}\right|<\epsilon\\
\iff& \left| \frac{1}{n}\right|<\epsilon\\
\iff& \frac{1}{n} < \epsilon\\
\iff& n > \frac{1}{\epsilon}
\end{align*}
Hence, for $N:=\left\lceil \dfrac{1}{\epsilon}\right\rceil+1, n > N \imp \left|(\dfrac{1}{n}-1) -(-1)\right| < \epsilon$. Because $\epsilon$ was arbitrarily chosen, it follows that $\lim\limits_{m=1, n \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = -1$.
\end{document}

I'm not exactly sure why this is happening. Perhaps it has something to with the \frac{}{} equations in the second two equations... and if so, how can I fix the spacing so that all the equations are aligned the same? Thank you.

6
  • What do you consider the first and the second equation in your code? It's not very clear...
    – Werner
    Nov 7 '17 at 4:11
  • 1
    Welcome to TeX.SE. If your issue is with alignment across separate align*, you need to combine them into a single align* enironment and use \intertext{} for the text that you have between the two align* blocks. Nov 7 '17 at 6:07
  • Well, the space between the lines are probably the same, but as you say the lines are higher in the second two align blocks due to the \fracs. But do you really want to change that? You don't need more space between the lines for the first two. (You can of course do it, see e.g. tex.stackexchange.com/questions/2929/…, ) Nov 7 '17 at 8:27
  • @Werner The first two equations are the proofs by contradiction. The last two equations are the limit proofs. I want to fix the horizontal alignment since the first two proofs are spaced differently than the second two.
    – user147592
    Nov 7 '17 at 13:19
  • @TorbjørnT. I apologize for not being more clear. I want to fix the horizontal alignment, not the vertical alignment. The first two equations are horizontally aligned differently from the second two, and I want to fix that.
    – user147592
    Nov 7 '17 at 13:21
1

You're probably looking for \intertext:

\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{amsmath,amsthm,amssymb}
\usepackage{amsmath}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\ex}{\:\exists\,}
\newcommand{\nex}{\:\nexists\,}
\newcommand{\all}{\:\forall\,}
\newcommand{\imp}{\Longrightarrow}
\begin{document}

For $A:=\left\{\dfrac{1}{n}-\dfrac{1}{m}:n,m\in\N\right\}$, $\sup(A) = 1$, $\inf(A)=-1$.

\begin{proof}
Suppose for contradiction that $1$ is not an upper bound for $A$, i.e.\@
$\exists n,m \in \mathbb{N} \mid \dfrac{1}{n} - \dfrac{1}{m} > 1$.

\begin{align*}
\iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} > 1\\
\iff&\frac{m-n}{mn}>1\\
\iff& m-n> mn\\
\iff& m > mn + n\\
\iff& m > n(m+1)\\
\intertext{Because $n(m+1)\geq m+1$, we have}
\iff& m > n(m+1) \geq m+1\\
\iff& m > m+1 &\bot\\
\intertext{\indent Suppose for contradiction that $-1$ is not a lower bound for $A$,
i.e.\@ $\ex n,m \in \N \mid \dfrac{1}{n} - \dfrac{1}{m} < -1$.}
\iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} < -1\\
\iff&\frac{m-n}{mn}<-1\\
\iff& m-n<-mn\\
\iff& m +mn < n\\
\iff& m(1+n)< n\\
\intertext{Because $m(1+n)\geq 1+n$, we have}
\iff& 1+n \leq m(1+n) < n\\
\iff& 1+n < n &\bot
\intertext{\indent Claim that $\lim\limits_{n=1, m \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = 1$,
or $\all \epsilon \in (0,\infty) \ex M \in \N \mid m \in \N: m>M \imp
\left|(1 - \dfrac{1}{m}) - 1\right| < \epsilon $.}
\iff& \left| 1 - 1 - \frac{1}{m}\right|<\epsilon\\
\iff& \left|-\frac{1}{m}\right|<\epsilon\\
\iff& \frac{1}{m}<\epsilon\\
\iff& m > \frac{1}{\epsilon}
\intertext{Hence, for $M:=\left\lceil\dfrac{1}{\epsilon}\right\rceil+1$,
$ m > M \imp \left| 1 - 1 - \dfrac{1}{m}\right|<\epsilon$. Because $\epsilon$ 
was arbitrarily chosen, it follows that 
$\lim\limits_{n=1, m \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = 1$.\endgraf\medskip
\indent Claim that $\lim\limits_{m=1, n \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = -1$, 
or $\all \epsilon \in (0,\infty) \ex N \in \N \mid n \in \N: n>N \imp
 \left|(\dfrac{1}{n}-1) -(-1)\right| < \epsilon $.}
\iff& \left| -1 - (-1) + \frac{1}{n}\right|<\epsilon\\
\iff& \left| \frac{1}{n}\right|<\epsilon\\
\iff& \frac{1}{n} < \epsilon\\
\iff& n > \frac{1}{\epsilon}
\end{align*}
Hence, for $N:=\left\lceil \dfrac{1}{\epsilon}\right\rceil+1$, 
$n > N \imp \left|(\dfrac{1}{n}-1) -(-1)\right| < \epsilon$. 
Because $\epsilon$ was arbitrarily chosen, it follows that 
$\lim\limits_{m=1, n \to \infty} \dfrac{1}{n} - \dfrac{1}{m} = -1$.
\end{proof}

\end{document}

enter image description here

0
1

EDIT: Found the error: you have too many & in the last line of the first two align envs


Below is a cleaned up MWE (with the error still present)

  • don't use \dfrac in the text, causes excessive line spacing
  • don't use \\ or \newline in the text, you never want manual line breaks in the text (this is a very common mistake among new users)
  • use \intertext{...} for comments inside align (mathtools provides \shortintertext which has different spacing)

Cleaned MWE

\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{amsmath,amsthm,amssymb}
\usepackage{amsmath}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\ex}{\:\exists\,}
\newcommand{\nex}{\:\nexists\,}
\newcommand{\all}{\:\forall\,}
\newcommand{\imp}{\Longrightarrow}
\begin{document}
For $A:=\left\{\frac{1}{n}-\frac{1}{m}:n,m\in\N\right\}$, $\sup(A) = 1, \inf(A)=-1$.

\begin{proof}
  Suppose for contradiction that $1$ is not an upper bound for $A$,
  i.e.
  $\exists n,m \in \mathbb{N} \mid \frac{1}{n} - \frac{1}{m} > 1$.
  \begin{align*}
    \iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} > 1\\
    \iff&\frac{m-n}{mn}>1\\
    \iff& m-n> mn\\
    \iff& m > mn + n\\
    \iff& m > n(m+1)\\
    \intertext{Because $n(m+1)\geq m+1$, we have}
    \iff& m > n(m+1) \geq m+1\\
    \iff& m > m+1 &\bot
  \end{align*}

  Suppose for contradiction that $-1$ is not a lower bound for $A$,
  i.e. $\ex n,m \in \N \mid \frac{1}{n} - \frac{1}{m} < -1$.
  \begin{align*}
    \iff&\frac{m}{m}\cdot\frac{1}{n} - \frac{n}{n}\cdot\frac{1}{m} < -1\\
    \iff&\frac{m-n}{mn}<-1\\
    \iff& m-n<-mn\\
    \iff& m +mn < n\\
    \iff& m(1+n)< n\\
    \intertext{Because $m(1+n)\geq 1+n$, we have}
    \iff& 1+n \leq m(1+n) < n\\
    \iff& 1+n < n &\bot
  \end{align*}
  Claim that $\lim_{n=1, m \to \infty} \frac{1}{n} -
  \frac{1}{m} = 1$, or $\all \epsilon \in (0,\infty) \ex M \in \N \mid
  m \in \N: m>M \imp$ $ \left|(1 - \frac{1}{m}) - 1\right| < \epsilon
  $.
  \begin{align*}
    \iff& \left| 1 - 1 - \frac{1}{m}\right|<\epsilon\\
    \iff& \left|-\frac{1}{m}\right|<\epsilon\\
    \iff& \frac{1}{m}<\epsilon\\
    \iff& m > \frac{1}{\epsilon}
  \end{align*}
  Hence, for $M:=\left\lceil\frac{1}{\epsilon}\right\rceil+1$,
  $ m > M \imp \left| 1 - 1 - \frac{1}{m}\right|<\epsilon$. Because
  $\epsilon$ was arbitrarily chosen, it follows that
  $\lim_{n=1, m \to \infty} \frac{1}{n} - \frac{1}{m} = 1$.

  Claim that
  $\lim_{m=1, n \to \infty} \frac{1}{n} - \frac{1}{m} = -1$, or
  $\all \epsilon \in (0,\infty) \ex N \in \N \mid n \in \N: n>N \imp$
  $ \left|(\frac{1}{n}-1) -(-1)\right| < \epsilon $.
  \begin{align*}
    \iff& \left| -1 - (-1) + \frac{1}{n}\right|<\epsilon\\
    \iff& \left| \frac{1}{n}\right|<\epsilon\\
    \iff& \frac{1}{n} < \epsilon\\
    \iff& n > \frac{1}{\epsilon}
  \end{align*}
  Hence, for $N:=\left\lceil \frac{1}{\epsilon}\right\rceil+1, n > N
  \imp \left|(\frac{1}{n}-1) -(-1)\right| <
  \epsilon$. Because
  $\epsilon$ was arbitrarily chosen, it follows that
  $\lim\limits_{m=1, n \to \infty} \frac{1}{n} - \frac{1}{m} = -1$.
\end{proof}
\end{document}

Here is a image of the first page (after cleaning), I can see what you mean about the unevenness

enter image description here

5
  • So there isn't a way to fix the unevenness?
    – user147592
    Nov 7 '17 at 15:14
  • @SuhasHoysala See my update, I just left the image and the clean MWE for others to actually see the problem. You have to unnecessary &
    – daleif
    Nov 7 '17 at 15:27
  • I removed the extra & (before the \bot command), but it still was uneven... I'm not sure what I'm doing wrong.
    – user147592
    Nov 7 '17 at 20:33
  • @SuhasHoysala did you also remember to use \intertext as I did in my cleanup? My fix was literally the mwe cleanup I posted and then removing the two excessive &
    – daleif
    Nov 7 '17 at 20:35
  • Yes, I copy-pasted your code verbatim and removed the two excessive &. It still doesn't seem to be fixed.
    – user147592
    Nov 7 '17 at 21:44

Your Answer

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