LaTeX
LaTeX是在TeX基础上,规范化出了一种格式,一种编写风格。可以理解为LaTeX是由TeX写的。
画符号显示符号名称:Detexify
在线手写公式生成数学表达式代码:https://webdemo.myscript.com/views/math/index.html#
详细文档:https://en.wikibooks.org/wiki/LaTeX/Mathematics
LaTeX存在大量第三方插件扩展,包括不限于:Amsmath、MathTools、mathrsfs、amsfonts、xcolor…
文档尽量不考虑扩展确保兼容
使用方法:
类型 | 内联公式 | 显示的方程 | 显示并自动编号的方程 |
---|---|---|---|
Environment | math | displaymath | equation |
LaTeX | \(...\) | \[...\] | |
TeX | $...$ | $$...$$ | |
Comment | equation* (starred version) suppresses numbering, but requires amsmath |
1$$
2E=mc^2
3$$
4
5\[ f(n) =
6 \begin{cases}
7 n/2 & \quad \text{if } n \text{ is even}\\
8 -(n+1)/2 & \quad \text{if } n \text{ is odd}
9 \end{cases}
10\]
[ f(n) = \begin{cases} n/2 & \quad \text{if } n \text{ is even}\ -(n+1)/2 & \quad \text{if } n \text{ is odd} \end{cases} ]
符号
关系符号
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$<$ | < | $>$ | > | |
$\leq$ | \leq | $\geq$ | \geq | |
$\ll$ | \ll | $\gg$ | \gg | |
$\subset$ | \subset | $\supset$ | \supset | |
$\subseteq$ | \subseteq | $\supseteq$ | \supseteq | |
$\nsubseteq$ | \nsubseteq | $\nsupseteq$ | \nsupseteq | |
$\sqsubset$ | \sqsubset | $\sqsupset$ | \sqsupset | |
$\sqsubseteq$ | \sqsubseteq | $\sqsupseteq$ | \sqsupseteq | |
$\preceq$ | \preceq | $\succeq$ | \succeq | |
$\therefore$ | \therefore | $\because$ | \because | |
$\parallel$ | \parallel | $\nparallel$ | \nparallel | |
$\asymp$ | \asymp | $\bowtie$ | \bowtie | |
$\vdash$ | \vdash | $\dashv$ | \dashv | |
$\in$ | \in | $\ni$ | \ni | |
$\smile$ | \smile | $\frown$ | \frown | |
$\models$ | \models | $\notin$ | \notin | |
$\perp$ | \perp | $\mid$ | \mid | |
$\prec$ | \prec | $\succ$ | \succ | |
$\sphericalangle$ | \sphericalangle | $\measuredangle$ | \measuredangle |
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$=$ | = | $\simeq$ | \simeq | |
$\doteq$ | \doteq | $\sim$ | \sim | |
$\equiv$ | \equiv | $\propto$ | \propto | |
$\approx$ | \approx | $\neq$ | \neq | |
$\cong$ | \cong |
二进制操作
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$\pm$ | \pm | $\cap$ | \cap | |
$\mp$ | \mp | $\cup$ | \cup | |
$\times$ | \times | $\uplus$ | \uplus | |
$\div$ | \div | $\sqcap$ | \sqcap | |
$\ast$ | \ast | $\sqcup$ | \sqcup | |
$\star$ | \star | $\vee$ | \vee | |
$\dagger$ | \dagger | $\wedge$ | \wedge | |
$\ddagger$ | \ddagger | $\cdot$ | \cdot | |
$\diamond$ | \diamond | $\oplus$ | \oplus | |
$\bigtriangleup$ | \bigtriangleup | $\ominus$ | \ominus | |
$\bigtriangledown$ | \bigtriangledown | $\otimes$ | \otimes | |
$\triangleleft$ | \triangleleft | $\oslash$ | \oslash | |
$\triangleright$ | \triangleright | $\odot$ | \odot | |
$\bigcirc$ | \bigcirc | $\circ$ | \circ | |
$\bullet$ | \bullet | $\setminus$ | \setminus | |
$\wr$ | \wr | $\amalg$ | \amalg |
设置和/或逻辑符号
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$\exists$ | \exists | $\rightarrow$ | \rightarrow 或 \to | |
$\nexists$ | \nexists | $\leftarrow$ | \leftarrow 或 \gets | |
$\forall$ | \forall | $\mapsto$ | \mapsto | |
$\neg$ | \neg | $\implies$ | \implies | |
$\impliedby$ | \impliedby | $\Rightarrow$ | \Rightarrow 或 \implies | |
$\leftrightarrow$ | \leftrightarrow | $\Leftrightarrow$ | \Leftrightarrow | |
$\iff$ | \iff | $\angle$ | \angle | |
$\land$ | \land | $\lor$ | \lor | |
$\top$ | \top | $\bot$ | \bot | |
$\emptyset$ | \emptyset | $\varnothing$ | \varnothing | |
$\rightleftharpoons$ | \rightleftharpoons |
分隔符
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$\mid$ | \mid | $|$ | | | |
${$ | \{ | $}$ | \} | |
$\uparrow$ | \uparrow | $\Uparrow$ | \Uparrow | |
$\downarrow$ | \downarrow | $\Downarrow$ | \Downarrow | |
$/$ | / | $\backslash$ | \backslash | |
$\langle$ | \langle | $\rangle$ | \rangle | |
$\lceil$ | \lceil | $\rceil$ | \rceil | |
$\lfloor$ | \lfloor | $\rfloor$ | \rfloor |
希腊字母
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$A$ | A | $\alpha$ | \alpha | |
$B$ | B | $\beta$ | \beta | |
$\Gamma$ | \Gamma | $\gamma$ | \gamma | |
$\Delta$ | \Delta | $\delta$ | \delta | |
$E$ | E | $\epsilon$ $\varepsilon$ | \epsilon \varepsilon | |
$Z$ | Z | $\zeta$ | \zeta | |
$H$ | H | $\eta$ | \eta | |
$\Theta$ | \Theta | $ heta$ $\vartheta$ | \theta \vartheta | |
$I$ | I | $\iota$ | \iota | |
$K$ | K | $\kappa$ $\varkappa$ | \kappa \varkappa | |
$\Lambda$ | \Lambda | $\lambda$ | \lambda | |
$M$ | M | $\mu$ | \mu | |
$N$ | N | $\nu$ | \nu | |
$\Xi$ | \Xi | $\xi$ | \xi | |
$O$ | O | $o$ | o | |
$\Pi$ | \Pi | $\pi$ $\varpi$ | \pi \varpi | |
$P$ | P | $\rho$ $\varrho$ | \rho \varrho | |
$\Sigma$ | \Sigma | $\sigma$ $\varsigma$ | \sigma \varsigma | |
$T$ | T | $\tau$ | \tau | |
$Y$ | Y | $\Upsilon$ $\upsilon$ | \Upsilon \upsilon | |
$\Phi$ | \Phi | $\phi$ $\varphi$ | \phi \varphi | |
$X$ | X | $\chi$ | \chi | |
$\Psi$ | \Psi | $\psi$ | \psi | |
$\Omega$ | \Omega | $\omega$ | \omega |
其他符号
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$\partial$ | \partial | $\imath$ | \imath | |
$\eth$ | \eth | $\jmath$ | \jmath | |
$\hbar$ | \hbar | $\ell$ | \ell | |
$\Re$ | \Re | $\nabla$ | \nabla | |
$\Im$ | \Im | $\Box$ | \Box | |
$\wp$ | \wp | $\infty$ | \infty | |
$\aleph$ | \aleph | $\beth$ | \beth | |
$\gimel$ | \gimel |
三角函数
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$\sin$ | \sin | $\arcsin$ | \arcsin | |
$\cos$ | \cos | $\arccos$ | \arccos | |
$\tan$ | \tan | $\arctan$ | \arctan | |
$\cot$ | \cot | $\arccot$ | \arccot | |
$\sinh$ | \sinh | $\sec$ | \sec | |
$\cosh$ | \cosh | $\csc$ | \csc | |
$\tanh$ | \tanh | $\coth$ | \coth |
和与积分
象征 | 脚本 | 象征 | 脚本 | 象征 | 脚本 |
---|---|---|---|---|---|
$\sum$ | \sum | $\prod$ | \prod | $\coprod$ | \coprod |
$\bigoplus$ | \bigoplus | $\bigotimes$ | \bigotimes | $\bigodot$ | \bigodot |
$\bigcup$ | \bigcup | $\bigcap$ | \bigcap | $\biguplus$ | \biguplus |
$\bigsqcup$ | \bigsqcup | $\bigvee$ | \bigvee | $\bigwedge$ | \bigwedge |
$\int$ | \int | $\oint$ | \oint | $\iint$ | \iint |
$\iiint$ | \iiint | $\iiiint$ | \iiiint | $\idotsint$ | \idotsint |
公式排版
行内公式: 使用$
包裹公式 $E=mc^2$
1$E=mc^2$
独立公式: 使用$$
包裹公式
1$$
2E=mc^2
3$$
特殊转义字符
### $ & ~ _ ^ \ { } %
这些字符在MarkDown中有特殊的意义,在需要使用这些字符的时候,需要进行转义
公式
极限: $\lim\limits_{x \to \infty} \exp(-x) = 0$
1$\lim\limits_{x \to \infty} \exp(-x) = 0$
幂和指数: $k_{n+1} = n^2 + k_n^2 - k_{n-1}$
1$k_{n+1} = n^2 + k_n^2 - k_{n-1}$
分数和二项式: $\frac{n!}{k!(n-k)!} = \binom{n}{k} \neq ^3/_7$
1\frac{n!}{k!(n-k)!} = \binom{n}{k} \neq ^3/_7
连续分数
$$ \begin{equation} x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } } \end{equation} $$
1\begin{equation}
2 x = a_0 + \cfrac{1}{a_1
3 + \cfrac{1}{a_2
4 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }
5\end{equation}
两个数字的乘法
$$ \begin{equation} \frac{ \begin{array}[b]{r} \left( x_1 x_2 \right)\ \times \left( x’_1 x’_2 \right) \end{array} }{ \left( y_1y_2y_3y_4 \right) } \end{equation} $$
1\begin{equation}
2\frac{
3 \begin{array}[b]{r}
4 \left( x_1 x_2 \right)\\
5 \times \left( x'_1 x'_2 \right)
6 \end{array}
7 }{
8 \left( y_1y_2y_3y_4 \right)
9 }
10\end{equation}
根号
$\sqrt{\frac{a}{b}}$
$\sqrt[n]{1+x+x^2+x^3+\dots+x^n}$
1\sqrt{\frac{a}{b}}
2\sqrt[n]{1+x+x^2+x^3+\dots+x^n}
和与积分
$\sum_{i=1}^{10} t_i$
$\displaystyle\sum_{i=1}^{10} t_i$
$\int_0^\infty \mathrm{e}^{-x},\mathrm{d}x$
1\sum_{i=1}^{10} t_i
2\displaystyle\sum_{i=1}^{10} t_i
3\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x
$$ \sum_{\substack{ 0<i<m \ 0<j<n }} P(i,j) $$
1\sum_{\substack{
2 0<i<m \\
3 0<j<n
4 }}
5 P(i,j)
$\int\limits_a^b$
1\int\limits_a^b
矩阵和数组
需要 Amsmath 软件包
[ \begin{matrix} a & b & c \ d & e & f \ g & h & i \end{matrix} ]
1\[
2 \begin{matrix}
3 a & b & c \\
4 d & e & f \\
5 g & h & i
6 \end{matrix}
7\]
$$ A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \ \vdots & \vdots & \ddots & \vdots \ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} $$
1A_{m,n} =
2 \begin{pmatrix}
3 a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
4 a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
5 \vdots & \vdots & \ddots & \vdots \\
6 a_{m,1} & a_{m,2} & \cdots & a_{m,n}
7 \end{pmatrix}
\begin{array}{c|c} 1 & 2 \ \hline 3 & 4 \end{array}
1\begin{array}{c|c}
2 1 & 2 \\
3 \hline
4 3 & 4
5 \end{array}
$$ M = \begin{bmatrix} \frac{5}{6} & \frac{1}{6} & 0 \[0.3em] \frac{5}{6} & 0 & \frac{1}{6} \[0.3em] 0 & \frac{5}{6} & \frac{1}{6} \end{bmatrix} $$
1M = \begin{bmatrix}
2 \frac{5}{6} & \frac{1}{6} & 0 \\[0.3em]
3 \frac{5}{6} & 0 & \frac{1}{6} \\[0.3em]
4 0 & \frac{5}{6} & \frac{1}{6}
5 \end{bmatrix}
分隔符大小
自动调整
$\left(\frac{x^2}{y^3}\right) = (\frac{x^2}{y^3})$
$P\left(A=2\middle|\frac{A^2}{B}>4\right)$
$\left{\frac{x^2}{y^3}\right}$
$\left.\frac{x^3}{3}\right|_0^1$
1\left(\frac{x^2}{y^3}\right) = (\frac{x^2}{y^3})
2
3P\left(A=2\middle|\frac{A^2}{B}>4\right)
4
5\left\{\frac{x^2}{y^3}\right\}
6
7\left.\frac{x^3}{3}\right|_0^1
手动调整
$( \big( \Big( \bigg( \Bigg($
1( \big( \Big( \bigg( \Bigg(
$\frac{\mathrm d}{\mathrm d x} \left( k g(x) \right) = \frac{\mathrm d}{\mathrm d x} \big( k g(x) \big)$
1\frac{\mathrm d}{\mathrm d x} \left( k g(x) \right) = \frac{\mathrm d}{\mathrm d x} \big( k g(x) \big)
常用案例
$f(x)=a^2+b$
1$f(x)=a^2+b$
$$ \begin{Bmatrix} a & b \ c & d \end{Bmatrix} $$
1$$
2\begin{Bmatrix}
3 a & b \\
4 c & d
5\end{Bmatrix}
6$$
加法符号:$x+y=z$
减法符号:$x-y=z$
加减符号:$x pm y=z$
减加符号:$x mp y=z$
叉乘符号:$x times y=z$
点乘符号:$x cdot y=z$
星乘符号:$x ast y=z$
除法符号:$x div y=z$
斜除符号:$x/y=z$
分式1:$frac{x+y}{y+z}$
分式2:${x+y} over {y+z}$
绝对值:$|x+y|$
设置数学符号的格式
默认数学字体: $\mathnormal{ABCDEFabcdef123456}$
1\mathnormal{ABCDEFabcdef123456}
计量单位,一字函数: $\mathrm{ABCDEFabcdef123456}$
1\mathrm{ABCDEFabcdef123456}
多字母函数或变量名称: $\mathit{ABCDEFabcdef123456}$
1\mathit{ABCDEFabcdef123456}
向量: $\mathbf{ABCDEFabcdef123456}$
1\mathbf{ABCDEFabcdef123456}
类别: $\mathsf{ABCDEFabcdef123456}$
1\mathsf{ABCDEFabcdef123456}
无: $\mathtt{ABCDEFabcdef123456}$
1\mathtt{ABCDEFabcdef123456}
向量: $\mathcal{ABCDEF}$
1\mathcal{ABCDEF}
音标
象征 | 脚本 | 象征 | 脚本 | |
---|---|---|---|---|
$a'$ | a' 或 a^{\prime} | $a’'$ | a'' | |
$\hat{a}$ | \hat{a} | $\bar{a}$ | \bar{a} | |
$\grave{a}$ | \grave{a} | $\acute{a}$ | \acute{a} | |
$\dot{a}$ | \dot{a} | $\ddot{a}$ | \ddot{a} | |
$\not{a}$ | \not{a} | $\mathring{a}$ | \mathring{a} | |
$\overrightarrow{AB}$ | \overrightarrow{AB} | $\overleftarrow{AB}$ | \overleftarrow{AB} | |
$a’’'$ | a''' | $a’’’'$ | a'''' | |
$\overline{aaa}$ | \dot{a} | $\check{a}$ | \check{a} | |
$\breve{a}$ | \breve{a} | $\vec{a}$ | \vec{a} | |
$\widehat{AAA}$ | \widehat{AAA} | $\widetilde{AAA}$ | \widetilde{AAA} | |
$\stackrel\frown{AAA}$ | \stackrel\frown{AAA} | $ ilde{a}$ | \tilde{a} | |
$\underline{a}$ | \underline{a} | $\ddot{a}$ | \ddot{a} |
控制水平间距
[ f(n) = \begin{cases} n/2 & \quad \text{if } n \text{ is even}\ -(n+1)/2 & \quad \text{if } n \text{ is odd} \end{cases} ]
1\[ f(n) =
2 \begin{cases}
3 n/2 & \quad \text{if } n \text{ is even}\\
4 -(n+1)/2 & \quad \text{if } n \text{ is odd}
5 \end{cases}
6\]