数学公式
背景
科研小白在Latex中踩了不少坑,在此记录一下。
准备资料
以下两份文档可以说贯穿写作始终,务必下载(快速过一遍即可,知道怎么用)
一份(不太)简短的 LATEX 2ε 介绍:CTAN: /tex-archive/info/lshort/chinesehttps://ctan.org/tex-archive/info/lshort/chinese
上述文档包含了数学公式的环境、常用的字符以及格式。
公式环境
这里先介绍常用的公式环境
行内公式
行内公式(在文本中间随时可插入使用):
例如: $\alpha$
行间公式
行间公式有两种,一种是无环境的,一种是有环境的
无环境
单独成段,无编号
例如:$$ x = y$$
有环境
equation 与 equation*
加星的公式环境不会被编号
\begin{equation*}
x = y
\end{equation*}
\begin{equation}\label{by_mat}
y = x + 1
\end{equation}
多行公式环境:align 与 align*
加星的公式环境不会被编号
& 为对齐标志
% 多行不编号
\begin{align*}
y &= x^2 + 1 \\
x &= 5
\end{align*}
%多行编号(每个都编)
\begin{align}\label{align_by_mat}
y &= x^2 + 1 \\
x &= 5
\end{align}
%多行编号(只编一个号)
\begin{equation}\label{eq_align1_by_mat}
\begin{aligned}
y &= x^2 + 1 \\
x &= 5
\end{aligned}
\end{equation}
居中环境:gather
公式内嵌套使用为 gathered
% 无gather环境
\begin{equation}\label{eq_align1_by_mat}
\begin{aligned}
y = x^2 + 1 \\
x = 5
\end{aligned}
\end{equation}
% 有gather环境
\begin{equation}\label{eq_align2_by_mat}
\begin{aligned}
\begin{gathered}
y = x^2 + 1 \\
x = 5
\end{gathered}
\end{aligned}
\end{equation}
环境嵌套
Latex允许环境嵌套,外层为equation,但内嵌的数学环境有些要做出修改:
gather | -> | gathered |
align | -> | aligned |
编写公式
关于复杂公式这里,我将会针对遇到的不同情况,先进行图片展示,再讲解编写技巧。
大括号内多行公式
代码展示:
\begin{equation*}
\begin{aligned}
&\mathbf{Adv}_{\mathcal{A}}^{\mathbf{E}}(\lambda)= \\
&Pr\left[
\begin{gathered}
\left(\begin{array}{cc}
Algorithm1(PP,B)=1 \wedge \\
Algorithm2(PP,B')=1 \wedge \\
Algorithm3(PP,B,B') = pk_c \\
\end{array}\right) : \\
(p) \leftarrow Algorithm4(PP) \\
T \leftarrow \mathcal{A}^{\mathcal{O}_{C}}(PP)\\
(\sigma,\sigma') \leftarrow \mathcal{A}^{\mathcal{O}_{test}}(PP)\\
\end{gathered}
\right] \le \epsilon
\end{aligned}
\end{equation*}
目前暂时想到这么多,后续遇到其他的问题再补充....