# Formatting Question

It has been sometime since I have used LaTeX, and I have a formatting question. Well, it would be better if I just show my code and ask why the format is messing up when I call in cases! What can I do to get my proof to go down in a straight line? Note I am not including all my document, this a project for an intro logic class.

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

\begin{document}
section{RSA Proof of Correctness}
\begin{center}
Recall(From RSA Methodology): $p$ and $q$ are two prime numbers, then we compute $n = pq$. Next we define $\phi{n} = (p-1)(q-1)$ and choose an $e$ such that $\gcd{e, \phi{n}} = 1$. Then there exists a $d$ such that $ed \equiv 1 \pmod{\phi{n}}$. We can define the encryption as $E(m) = m^e \pmod{n}$, and decryption as $D(c) = c^d \pmod{n}$
\begin{proof}
\begin{align*}
\shortintertext{To prove RSA we must prove:} D(c) = D(E(m)) = (m^e)^d = m^(ed) \equiv m \pmod{n}\\
\shortintertext{Recall: $ed \equiv 1 \pmod{\phi{n}}$}  \\
\exists k \ni \to de-1 = (p-1)*(q-1)*k \\
\to ec = 1+k(p-1)(q-1)\\
\shortintertext{Case 1: $m$ divides $p$ and $p$ divides $m$, then $m = 0 \pmod{p} \land m^{ed} \equiv 0 \pmod{p}$} \\
\to m = m^{ed} \pmod{p} \text{Then we are done}\\
\Shortintertext{Case 2: $m \land p are relatively prime$}

\end{align*}
\end{proof}
\end{center}
\end{document}

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. This makes it a lot easier to understand your question, reproduce the problem and construct solutions. We want code we can copy-paste-compile to see the issue you are asking about.
– cfr
Nov 22, 2014 at 20:12
• Updated the code cfr Nov 22, 2014 at 20:18
• Not Shortintertext, it is shortintertex and delete blank line before \end{align*}
– user31034
Nov 22, 2014 at 20:24
• @ferahfeza I think you mean \shortintertext (only the cap is wrong - not the final t). Also \section not section. Do you really want this in a center environment? It looks very odd to me.
– cfr
Nov 22, 2014 at 20:33
• @cfr, yes you are right, it is may mistake. It is \shortintertext
– user31034
Nov 22, 2014 at 20:38

This tidies up a few things mentioned in comments and a few more not mentioned there. I don't know if align* is really the optimal choice of environment when presenting this kind of proof, though.

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

\begin{document}
\section{RSA Proof of Correctness}
Recall (From RSA Methodology): $p$ and $q$ are two prime numbers, then we compute $n = pq$. Next we define $\phi{n} = (p-1)(q-1)$ and choose an $e$ such that $\gcd{e, \phi{n}} = 1$. Then there exists a $d$ such that $ed \equiv 1 \pmod{\phi{n}}$. We can define the encryption as $E(m) = m^e \pmod{n}$, and decryption as $D(c) = c^d \pmod{n}$
\begin{proof}
\begin{align*}
\shortintertext{To prove RSA we must prove:} D(c) = D(E(m)) = (m^e)^d = m^{ed} \equiv m \pmod{n}\\
\shortintertext{Recall: $ed \equiv 1 \pmod{\phi{n}}$}  \\
\exists k \ni \to de-1 = (p-1)*(q-1)*k \\
\to ec = 1+k(p-1)(q-1)\\
\shortintertext{Case 1: $m$ divides $p$ and $p$ divides $m$, then $m = 0 \pmod{p} \land m^{ed} \equiv 0 \pmod{p}$} \\
\to m = m^{ed} \pmod{p} \text{ Then we are done}\\
\shortintertext{Case 2: $m \land p$ are relatively prime}
\end{align*}
\end{proof}
\end{document}


• Thanks, why would align* not be a good idea? Nov 22, 2014 at 20:42
• @Redspart I'm not saying it isn't but I don't typeset this kind of thing much myself so I am not familiar with all the possibilities. But I know there are special facilities for handling proofs involving cases provided by the AMS classes/packages so I wondered if something like that might be more helpful. But, as I say, I'm going beyond what I feel confident recommending here!
– cfr
Nov 22, 2014 at 20:46
• @Redspart: you actually don't align whatever. Nov 22, 2014 at 23:39

I would use an enumerate environment for the cases, with the wide option of enumitem. I also prefer to use the ntheorem package at it is easy to customise theorem environments and it has an automatic placement of the end-of-proof symbol.

\documentclass{article}

\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}

\usepackage[thmmarks, amsmath, thref]{ntheorem}

\theorempreskip{\bigskipamount}
\theoremstyle{nonumberbreak}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\square}}
\theoremseparator{: \smallskip}
\newtheorem{myproof}{Proof}

\begin{document}
\section{RSA Proof of Correctness}
Recall (From RSA Methodology): $p$ and $q$ are two prime numbers, then we compute $n = pq$. Next we define $ϕ{n} = (p-1)(q-1)$ and choose an $e$ such that $\gcd{e, ϕ{n}} = 1$. Then there exists a $d$ such that $ed ≡ 1 \pmod{ϕ{n}}$. We can define the encryption as $E(m) = m^e \pmod{n}$, and decryption as $D(c) = c^d \pmod{n}$

\begin{myproof}
To prove RSA we must prove:
$D(c) = D(E(m)) = (m^e)^d = m^{ed} ≡ m \pmod{n}$
Recall: $ed ≡ 1 \pmod{ϕ{n}}$
\begin{align*}
∃ k \ni & \to de-1 = (p-1)*(q-1)*k \\
& \to ec = 1+k(p-1)(q-1)
\end{align*}
\begin{enumerate}[label = Case \arabic*: , wide = 0pt]
\item $m$ divides $p$ and $p$ divides $m$, then $m = 0 \pmod{p} \land m^{ed} ≡ 0 \pmod{p}$
$\to m = m^{ed} \pmod{p} \text{ Then we are done}$
\item $m \land p$ are relatively prime.
\end{enumerate}
\end{myproof}

\end{document}