目录
Markdown Cheat Sheet
数学相关LaTeX表达
前言
表 1: 数学模式重音符
示例 | 代码 | 示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|---|---|
a ^ \hat {a} a^ | \hat{a} | a ˇ \check{a} aˇ | \check{a} | a ~ \tilde{a} a~ | \tilde{a} | a ˊ \acute{a} aˊ | \acute{a} |
** a ˋ \grave{a} aˋ ** | \grave{a} | ** a ˙ \dot {a} a˙ ** | \dot{a} | ** a ˉ \bar{a} aˉ ** | \bar{a} | a ¨ \ddot a a¨ | \ddot{a} |
** a ⃗ \vec {a} a ** | \vec{a} | ** A ^ \widehat{A} A ** | \widehat{A} | A ~ \widetilde{A} A | \widetilde{A} | a ˘ \breve a a˘ | \breve{a} |
A ^ \hat{A} A^ | \hat{A} | A ~ \tilde{A} A~ | \tilde{A} |
表2: 小写希腊字母
示例 | 代码 | 示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|---|---|
α \alpha α | \alpha | θ \theta θ | \theta | υ \upsilon υ | \upsilon | $o $ | o |
β \beta β | \beta | ϑ \vartheta ϑ | \vartheta | π \pi π | \pi | ϕ \phi ϕ | \phi |
γ \gamma γ | \gamma | ι \iota ι | \iota | ϖ \varpi ϖ | \varpi | φ \varphi φ | \varphi |
δ \delta δ | \delta | κ \kappa κ | \kappa | ρ \rho ρ | \rho | χ \chi χ | \chi |
ϵ \epsilon ϵ | \epsilon | λ \lambda λ | \lambda | ϱ \varrho ϱ | \varrho | ψ \psi ψ | \psi |
ε \varepsilon ε | \varepsilon | μ \mu μ | \mu | σ \sigma σ | \sigma | ω \omega ω | \omega |
ζ \zeta ζ | \zeta | ν \nu ν | \nu | ς \varsigma ς | \varsigma | ∇ \nabla ∇ | \nabla |
η \eta η | \eta | ξ \xi ξ | \xi | τ \tau τ | \tau |
表 3: 大写希腊字母
示例 | 代码 | 示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|---|---|
Γ \Gamma Γ | \Gamma | Λ \Lambda Λ | \Lambda | KaTeX parse error: Undefined control sequence: \mit at position 7: \Sigma\̲m̲i̲t̲\Sigma | \Sigma\mit\Sigma | Ψ \Psi Ψ | \Psi |
Δ \Delta Δ | \Delta | Ξ \Xi Ξ | \Xi | Υ \Upsilon Υ | \Upsilon | KaTeX parse error: Undefined control sequence: \mit at position 7: \Omega\̲m̲i̲t̲\Omega | \Omega\mit\Omega |
Θ \Theta Θ | \Theta | Π \Pi Π | \Pi | Φ \Phi Φ | \Phi |
表 4: 数学字母
示例 | 代码 |
---|---|
A B C d e f x y z X Y Z 123 \mathbf {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathbf {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathrm {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathrm {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathit {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathit {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathcal {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathcal {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathscr {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathscr {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathfrak {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathfrak {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \mathbb {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \mathbb {ABCdefxyzXYZ123} |
A B C d e f x y z X Y Z 123 \boldsymbol{ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \boldsymbol{ABCdefxyzXYZ123} |
表 5: 运算符与函数
示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|
∑ \sum ∑ | \sum | ∏ \prod ∏ | \prod | x ⋅ y x\cdot{y} x⋅y | x\cdot{y} |
⋃ \bigcup ⋃ | \bigcup | ⨁ \bigoplus ⨁ | \bigoplus | x × y x\times {y} x×y | x\times {y} |
⋁ \bigvee ⋁ | \bigvee | ⋂ \bigcap ⋂ | \bigcap | ∥ w ∥ \left\|w\right\| ∥w∥ | **\left\ |
⋀ \bigwedge ⋀ | \bigwedge | ⨄ \biguplus ⨄ | \biguplus | ∭ \iiint ∭ | \iiint |
⨂ \bigotimes ⨂ | \bigotimes | ∮ \oint ∮ | \oint | ∬ \iint ∬ | \iint |
∫ x d x \int x\,{\rm d}x ∫xdx | \int x,{\rm d}x | ⨆ \bigsqcup ⨆ | \bigsqcup | ⟮ ⟯ \lgroup \rgroup ⟮⟯ | \lgroup \rgroup |
∐ \coprod ∐ | \coprod | ⨀ \bigodot ⨀ | \bigodot | ∂ \partial ∂ | \partial |
det \det det | \det | max \max max | \max | min \min min | \min |
log \log log | \log |
表 6: 常用箭头
示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|
← \leftarrow ← | \leftarrow | → \rightarrow → | \rightarrow | ↔ \leftrightarrow ↔ | \leftrightarrow |
⟵ \longleftarrow ⟵ | \longleftarrow | ⟶ \longrightarrow ⟶ | \longrightarrow | ⟷ \longleftrightarrow ⟷ | \longleftrightarrow |
⇐ \Leftarrow ⇐ | \Leftarrow | ⇒ \Rightarrow ⇒ | \Rightarrow | ⇔ \Leftrightarrow ⇔ | \Leftrightarrow |
⟸ \Longleftarrow ⟸ | \Longleftarrow | ⟹ \Longrightarrow ⟹ | \Longrightarrow | ⟺ \Longleftrightarrow ⟺ | \Longleftrightarrow |
↑ \uparrow ↑ | \uparrow | ↓ \downarrow ↓ | \downarrow | ↕ \updownarrow ↕ | \updownarrow |
表 7: 其他常用符号
示例 | 代码 | 示例 | 代码 | 示例 | 代码 |
---|---|---|---|---|---|
∴ \therefore ∴ | \therefore | ∵ \because ∵ | \because | min f ∈ H \min \limits_{f \in {H}} f∈Hmin | \min \limits_{f \in {H}} |
⩽ \leqslant ⩽ | \leqslant | ⩾ \geqslant ⩾ | \geqslant | KaTeX parse error: Undefined control sequence: \cal at position 1: \̲c̲a̲l̲ ̲{C} \equiv 1 | \equiv |
≈ \thickapprox ≈ | \thickapprox | ∼ ∼ \thicksim \sim ∼∼ | \thicksim \sim | ( A B ) \left(\frac{A}{B}\right) (BA) | \left(\frac{A}{B}\right) |
≠ \neq = | \neq | ∈ \in ∈ | \in | = ^ \hat{=} =^ | \hat{=} |
± \pm ± | \pm | a \sqrt{a} a | \sqrt{a} | ≥ ≤ \geq \leq ≥≤ | \geq \leq |
$\perp $ | \perp | ∠ \angle ∠ | \angle | ∝ \varpropto ∝ | \varpropto |
∞ \infty ∞ | \infty | g ′ g^\prime g′ | g^\prime | ∀ \forall ∀ | \forall |
∃ \exist ∃ | \exist | ⊥ \bot ⊥ | \bot | ⊤ \top ⊤ | \top |
注意**\bot和\perp的区别,垂直是\perp**
表8: 使用字体
示例 | 代码 | 备注 |
---|---|---|
A B C d e f x y z X Y Z 123 \rm {ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \rm {ABCdefXYZ123} | 罗马体 |
A B C d e f x y z X Y Z 123 \it{ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \it{ABCdefXYZ123} | 意大利体 |
A B C d e f x y z X Y Z 123 \bf{ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \bf{ABCdefXYZ123} | 正粗体,黑体 |
KaTeX parse error: Undefined control sequence: \cal at position 1: \̲c̲a̲l̲ ̲{ABCdefxyzXYZ12… | \cal {ABCdefXYZ123} | 花体 |
A B C d e f X Y Z 123 \sf{ABCdefXYZ123} ABCdefXYZ123 | \sf{ABCdefXYZ123} | 等线体 |
KaTeX parse error: Undefined control sequence: \mit at position 1: \̲m̲i̲t̲{ABCdefxyzXYZ12… | \mit{ABCdefXYZ123} | 数字斜体 |
A B C d e f x y z X Y Z 123 \tt{ABCdefxyzXYZ123} ABCdefxyzXYZ123 | \tt{ABCdefXYZ123} | 打印机字体 |
表9: 分段函数与公式对齐
分段函数
示例
f
(
x
,
y
)
=
{
1
x
与
y
满
足
某
一
事
实
0
否
则
f(x,y) = \begin{cases} 1 & x与y满足某一事实\\ 0 & 否则 \end{cases}
f(x,y)={10x与y满足某一事实否则
# 代码
f(x,y) = \begin{cases}
1 & x与y满足某一事实\\
0 & 否则
\end{cases}
L ( w ) = ∑ i = 1 N [ y i log π ( x i ) + ( 1 − y i ) log ( 1 − π ( x i ) ) ] = ∑ i = 1 N [ y i log π ( x i ) 1 − π ( x i ) + log ( 1 − π ( x i ) ) ] = ∑ i = 1 N [ y i ( w ⋅ x i ) − log ( 1 + exp ( w ⋅ x i ) ] \begin{aligned} L(w)&=\sum\limits^{N}_{i=1}[y_i\log\pi(x_i)+(1-y_i)\log(1-\pi(x_i))]\\&=\sum\limits^{N}_{i=1}[y_i\log{\frac{\pi(x_i)}{1-\pi(x_i)}}+\log(1-\pi(x_i))]\\&=\sum\limits^{N}_{i=1}[y_i(w\cdot x_i)-\log(1+\exp(w\cdot{x_i})] \end{aligned} L(w)=i=1∑N[yilogπ(xi)+(1−yi)log(1−π(xi))]=i=1∑N[yilog1−π(xi)π(xi)+log(1−π(xi))]=i=1∑N[yi(w⋅xi)−log(1+exp(w⋅xi)]
对齐控制
# 代码
# 通过\begin{aligned}\end{aligned}控制对齐, 使用&表示对齐点.
\begin{aligned}
L(w)&=\sum\limits^{N}_{i=1}[y_i\log\pi(x_i)+(1-y_i)\log(1-\pi(x_i))]\\
&=\sum\limits^{N}_{i=1}[y_i\log{\frac{\pi(x_i)}{1-\pi(x_i)}}+\log(1-\pi(x_i))]\\
&=\sum\limits^{N}_{i=1}[y_i(w\cdot x_i)-\log(1+\exp(w\cdot{x_i})]
\end{aligned}
另外注意到前面的分段函数自动变好了,但是上面多行对齐的公式没有自动编号,如果需要自动编号,外面嵌入equation
KaTeX parse error: No such environment: equation at position 8: \begin{̲e̲q̲u̲a̲t̲i̲o̲n̲}̲ \begin{aligned…
代码如下
\begin{equation}
\begin{aligned}
L(w)&=\sum\limits^{N}_{i=1}[y_i\log\pi(x_i)+(1-y_i)\log(1-\pi(x_i))]\\&=\sum\limits^{N}_{i=1}[y_i\log{\frac{\pi(x_i)}{1-\pi(x_i)}}+\log(1-\pi(x_i))]\\&=\sum\limits^{N}_{i=1}[y_i(w\cdot x_i)-\log(1+\exp(w\cdot{x_i})]
\end{aligned}
\end{equation}
公式编号
关于编号也可以通过行间公式做如下表达
KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ L(w)&=\sum\lim…
代码如下
\begin{align}
L(w)&=\sum\limits^{N}_{i=1}[y_i\log\pi(x_i)+(1-y_i)\log(1-\pi(x_i))]\\
&=\sum\limits^{N}_{i=1}[y_i\log{\frac{\pi(x_i)}{1-\pi(x_i)}}+\log(1-\pi(x_i))]\nonumber\\
&=\sum\limits^{N}_{i=1}[y_i(w\cdot x_i)-\log(1+\exp(w\cdot{x_i})]
\end{align}
以上代码有两点需要注意体会:
- align
- \nonumber的使用
表X: 矩阵
普通矩阵
M 1 ( x ) = [ a 01 a 02 0 0 ] , M 2 ( x ) = [ b 11 b 12 b 21 b 22 ] M 3 ( x ) = [ c 11 c 12 c 21 c 22 ] , M 4 ( x ) = [ 1 0 1 0 ] \begin{aligned} M_1(x)= \begin{bmatrix} &a_{01}&a_{02}\\ &0&0 \end{bmatrix} &,M_2(x)= \begin{bmatrix} &b_{11}&b_{12}\\ &b_{21}&b_{22} \end{bmatrix} \\ M_3(x)= \begin{bmatrix} &c_{11}&c_{12}\\ &c_{21}&c_{22} \end{bmatrix} &,M_4(x)= \begin{bmatrix} &1&0\\ &1&0 \end{bmatrix} \end{aligned} M1(x)=[a010a020]M3(x)=[c11c21c12c22],M2(x)=[b11b21b12b22],M4(x)=[1100]
\begin{aligned}
M_1(x)=
\begin{bmatrix}
&a_{01}&a_{02}\\
&0&0
\end{bmatrix}
&,M_2(x)=
\begin{bmatrix}
&b_{11}&b_{12}\\
&b_{21}&b_{22}
\end{bmatrix}
\\
M_3(x)=
\begin{bmatrix}
&c_{11}&c_{12}\\
&c_{21}&c_{22}
\end{bmatrix}
&,M_4(x)=
\begin{bmatrix}
&1&0\\
&1&0
\end{bmatrix}
\end{aligned}
带省略符号的Matrix
X T = [ x 11 ⋯ x 1 N ⋮ ⋱ ⋮ x M 1 ⋯ x M N ] X^\mathrm T= \left[ \begin{matrix} x_{11} & \cdots & x_{1N} \\ \vdots & \ddots & \vdots \\ x_{M1} & \cdots & x_{MN} \\ \end{matrix} \right] XT=⎣⎢⎡x11⋮xM1⋯⋱⋯x1N⋮xMN⎦⎥⎤
% 这里稍微注意下转置符号, 《统计学习方法》中的转置用的是正体的T
% 可以参考 https://zhuanlan.zhihu.com/p/27490955 中关于转置写法的讨论。
X^\mathrm T=
\left[
\begin{matrix}
x_{11} & \cdots & x_{1N} \\
\vdots & \ddots & \vdots \\
x_{M1} & \cdots & x_{MN} \\
\end{matrix}
\right]
向量
KaTeX parse error: Got function '\newline' with no arguments as argument to '\begin{array}' at position 1: \̲n̲e̲w̲l̲i̲n̲e̲
\left[
\begin{array}
\\2
\\3
\end{array}
\right]
a b c d e ⏞ f g h i j ⏟ c o m m e n t k l m n ‾ o p q r ‾ s t u v ← w x y z → \overbrace{abcde}\underbrace{fghij}_{comment}\overline{klmn}\underline{opqr}\overleftarrow{stuv}\overrightarrow{wxyz} abcde comment fghijklmnopqrstuvwxyz
\overbrace{abcde}\underbrace{fghij}_{comment}\overline{klmn}\underline{opqr}\overleftarrow{stuv}\overrightarrow{wxyz}
Emoji
表XI: Emoji
😏 smirk | 😄smile | 😆laughing | 😊blush | 😃smiley | 😍heart_eyes |
---|---|---|---|---|---|
😘kissing_heart | 😉wink | 😗kissing | 😕confused | 😓sweat | 😂joy |
😭sob | 😢cry | 😠angry | 😋yum | 😷mask | 😎sunglasses |
💗heartpulse | 👽alien | 💘cupid | 👍+1 | 🇨🇳cn | 💩shit |