我已经有一段时间没用过 LaTeX 了,我有一个格式问题。好吧,如果我只展示我的代码并询问为什么我在调用案例时格式会乱掉,那就更好了!我该怎么做才能让我的证明直线下降?注意,我没有包括我所有的文档,这是一个入门逻辑课程的项目。
\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}
答案1
这整理了评论中提到的几件事以及一些未提及的事情。align*
不过,我不知道这是否真的是呈现这种证明时的最佳环境选择。
\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}
答案2
我会使用enumerate
环境来处理这些案例,并可以wide
选择enumitem
。我还喜欢使用ntheorem
包,它很容易定制定理环境,并且它有一个自动的 证明结束符号的放置。
\documentclass{article}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\theorempreskip{\bigskipamount}
\theoremstyle{nonumberbreak}
\theoremheaderfont{\itshape}
\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}