
Latex 公式的书写
在 markdown 中输入
公式块:在两个$$之间就是公式块,在\后加代码
行内公式:在一个$之间就是行内公式
希腊字母


mac电脑可以直接option+p 打出π
上下标
用^ 和 _ 来表示
1 | $$ |
$$
x^2+B_1
$$
注意:如果上下标多于 1 个字符,需要用{}括起来
1 | $$ |
$$
x^{x+y},p_{ij}
$$
分式与根式
用\frac 表示分式,如果上下标多于 1 个字符,需要用{}括起来
1 | $$ |
$$
债务率 = \frac {债务余额} {x+y}
$$
嵌套分式:
1 | $$ |
$$
\frac {\frac 1 x + 1}{y+1}
$$
这样会导致 x 比较小,要解决将嵌套中的 frac 改为 dfrac
1 | $$ |
$$
\frac {\dfrac 1 x + 1}{y+1}
$$
根式用\sqrt表示,开几次方的话用[]把开方次数包起来
1 | $$ |
$$
\sqrt 2,\sqrt {x+y},\sqrt[3]x
$$
普通运算符:
加减就是+ -
乘号用 \times 点号表示的乘用\cdot
除号用\div
加减用\pm (即 plus 、minus)
减加用\mp
大于小于用><
- 大于等于\ge
- 小于等于\le
- 远大于\gg
- 远小于 \ll
- 不等于\ne
- 约等于\approx
- 恒等于\equiv
- 交集与并集:\cap \cup
- 属于与不属于\in \notin
- 子集\真子集\空集\补集:\subseteq \subsetneqq \varnothing \complement
- 任意 \forall
- 存在与不存在 \exists \nexists
- 因为所以 \because \therefore
$$
- \times \cdot \div \pm \mp >< \ge \le \gg \ll \ne \approx \equiv \cap \cup \in \notin \subseteq \subsetneqq \varnothing \complement \forall \exists \nexists \because \therefore
$$
- \times \cdot \div \pm \mp >< \ge \le \gg \ll \ne \approx \equiv \cap \cup \in \notin \subseteq \subsetneqq \varnothing \complement \forall \exists \nexists \because \therefore
- 实数集\mathbb 或者 \R 以及:\N \Q \z \z_+
- 花体字母
1
2
3$$
\R \N \mathcal F \mathscr F
$$
$$
\R \N \mathcal F \mathscr F
$$
- 省略号 \cdots
- 竖向的省略号\vdots
- 斜向省略号 \ddots
1
2
3$$
\cdots \vdots \ddots
$$
$$
\cdots \vdots \ddots
$$
- 其他:无穷 \infty
- 偏微分\partial
- 算子\nabla
- 正比于\propto
- 度 \degree
$$
\infty \partial\nabla\degree
$$
- 函数与对数:
1
2
3$$
\sin x \cos y \cosh x \log_2 x ln x lg x
$$
$$
\sin x \cos y \cosh x \log_2 x ln x lg x
$$
- 极限 \lim
1
2
3$$
\lim_{x \to 0} \frac {x}{sin x}
$$
$$
\lim_{x \to 0} \frac {x}{sin x}
$$
- 大型运算符 求和\sum 求积 \prod
1
2
3$$
\sum \sum_{i=0}^N \prod
$$
$$
\sum \sum_{i=0}^N \prod
$$
1 | $$ |
$$
\frac {\sum_{i=0}^N} {\prod_{i=1}^n x_i}
$$
上图的上下限都是显示在符合的角标位置上,如果想强制显示在上下,可以加入\limits
1 | $$ |
$$
\frac {\sum\limits_{i=0}^N} {\prod\limits_{i=1}^n x_i}
$$
- 积分
1
2
3$$
\int,\iint,\iiint,\oint,\oiint
$$
$$
\int,\iint,\iiint,\oint,\oiint
$$
1 | $$ |
$$
\int_{-\infty}^0 f(x),\text d x
$$
上述的书写中,有几个点需要注意:
- 严谨的写法, d应该是直立体的,所以加入了\text 来限定
- f(x)是应该与 dx有一个微小的间隔的,所以加入了,来实现
标准符号
1
2
3
4
$$
\vec x,\overrightarrow {aB},\bar x,\overline A
$$
$$
\vec x,\overrightarrow {aB},\bar x,\overline A
$$箭头
1
2
3$$
\leftarrow,\Rightarrow,\Leftrightarrow,\longleftarrow
$$
$$
\leftarrow,\Rightarrow,\Leftrightarrow,\longleftarrow
$$
- 括号与定界符
1
2
3$$
()[]\{\}
$$
$$
()[]{}
$$
1 | $$ |
$$
\lceil,\rceil,\lfloor,\rfloor
$$
1 | $$ |
$$
(0,\frac 1 a]
$$
上面的式子括号的尺寸太小,这时可以加上\left 和\right
1 | $$ |
$$
\left(0,\frac 1 a\right]
$$
\left. 是一种虚拟括号(并不实际显示),利用这一特性可以让式子中的某个符号变大
$$
\left.\frac {∂f}{∂x}\right|_{x=0}
$$
上图中的希腊字母在 mac 上可以直接用 option+d 打出来
多行公式
输入多行公式,可以使用 align 环境,这允许对齐等式的不同部分:
1 | $$ |
$$
\begin{align}
x &= y \
y &= z \
\therefore x &= z
\end{align}
$$
使用 cases 环境可以表示分段函数:
1 | $$ |
$$
f(x) = \begin{cases}
x^2, & \text{if } x \geq 0 \
-x^2, & \text{if } x < 0
\end{cases}
$$
使用 array 环境可以创建矩阵或其他数组:
1 | $$ |
$$
\begin{array}{cc}
a & b \
c & d
\end{array}
$$
使用 matrix 环境直接创建矩阵:
1 | $$ |
$$
\begin{pmatrix}
a & b \
c & d
\end{pmatrix}
$$
1 | $$ |
$$
\begin{matrix}
a & b & \cdots & c \
\vdots & \vdots & \ddots & \vdots \
e & f & \cdots &g
\end{matrix}
$$
1 | $$ |
$$
\begin{bmatrix}
a & b & \cdots & c \
\vdots & \vdots & \ddots & \vdots \
e & f & \cdots &g
\end{bmatrix}
$$
1 | $$ |
$$
\begin{pmatrix}
a & b & \cdots & c \
\vdots & \vdots & \ddots & \vdots \
e & f & \cdots &g
\end{pmatrix}
$$
1 | $$ |
$$
\begin{vmatrix}
a & b & \cdots & c \
\vdots & \vdots & \ddots & \vdots \
e & f & \cdots &g
\end{vmatrix}
$$
对于多行方程,还可以使用 gather 环境:
1 | $$ |
$$
\begin{gather}
a = b + c \
d = e + f + g \
h = i + j
\end{gather}
$$
在公式中添加文本说明:
1 | \begin{align} |
$$
\begin{align}
f’(x) &= \lim_{h \to 0}\frac{f(x+h) - f(x)}{h} \
&= \lim_{h \to 0}\frac{(x+h)^2 - x^2}{h} \
&= \lim_{h \to 0}\frac{x^2 + 2xh + h^2 - x^2}{h} \
&= \lim_{h \to 0}(2x + h) \
&= 2x
\end{align}
$$