LaTex公式编写
MarkDown中引用LaTex公式
特殊字符 | 说明 | 示例 |
---|---|---|
$公式$ | LaTex公式前后加$是行内公式 | $y=ax+b$ |
$$公式$$ | 两个$括起来的是独占一行的公式 | $$y=ax+b$$ |
\ | 转义字符 | 要表示$可输入\$ |
通常我们使用单个$括住公式,来表示行内公式如 y = a x + b y=ax+b y=ax+b,他是不会换行的。
如果是两个$$来括住公式,那么这个公式独占一行,如:
y = a x + b y=ax+b y=ax+b
会占用单独的一行空间。
LaTex公式的表示
简单运算
像拉丁字母(az,AZ)、阿拉伯数字(0~9)和 + − ∗ / = +-*/= +−∗/=运算符均可以直接输入获得,没有特殊的表示方法,如:
y = a b c + 9 ∗ 8 − d / 5 y=abc+9*8-d/5 y=abc+9∗8−d/5
还有些特殊的运算符:
符号 | 意义 | 展示 |
---|---|---|
\cdot | 乘法的圆点 | ⋅ \cdot ⋅ |
\neq | 不等号 | ≠ \neq = |
\equiv | 恒等于 | ≡ \equiv ≡ |
\bmod | 取模 | m o d \bmod mod |
\sim | 波形号 | ∼ \sim ∼ |
\times | 乘法符号 | × \times × |
\div | 除法符号 | ÷ \div ÷ |
\approx | 约等于 | ≈ \approx ≈ |
\ldots | 跟本文底线对齐的省略号 | … \ldots … |
\cdots | 跟文本中线对齐的省略号 | ⋯ \cdots ⋯ |
上下标
通常 _ 表示下标、 ^ 表示上标;当上下标内容不止一个字符时,需用大括号 {} 括起来;单引号 ’ 表示求导,如:
y''=x^{x^2}_0
y ′ ′ = x 0 x 2 y''=x^{x^2}_0 y′′=x0x2
上下标记(水平线&括弧)
通常用 \overline 和 \underline 分别在表达式上、下方画出水平线,例如:
\overline{y}=\underline{x_1+x_2}
y ‾ = x 1 + x 2 ‾ \overline{y}=\underline{x_1+x_2} y=x1+x2
\overbrace 和 \underbrace 分别在表达式上、下方画出花括弧,例如:
\overbrace{1+2+3+\cdots+n}^{n} \qquad \underbrace{1^2+2^2+3^2+\cdots+10^2}_{10}
1 + 2 + 3 + ⋯ + n ⏞ n 1 2 + 2 2 + 3 2 + ⋯ + 1 0 2 ⏟ 10 \overbrace{1+2+3+\cdots+n}^{n} \qquad \underbrace{1^2+2^2+3^2+\cdots+10^2}_{10} 1+2+3+⋯+n n10 12+22+32+⋯+102
分式
通常用 \frac 表示分式,即 \frac{分子}{分母} ,如:
\frac{x^2_0}{x_1+x_2}
x 0 2 x 1 + x 2 \frac{x^2_0}{x_1+x_2} x1+x2x02
根号
通常用 \sqrt 表示平方根,即 \sqrt{根号下的公式} 。 \sqrt[n] 表示n次方根,即 \sqrt[n]{根号下的公式} ,例如:
y=\sqrt[3]{\frac{x_1^2}{x_2}}+\sqrt{x_1^2+x_2^2}
y = x 1 2 x 2 3 + x 1 2 + x 2 2 y=\sqrt[3]{\frac{x_1^2}{x_2}}+\sqrt{x_1^2+x_2^2} y=3x2x12+x12+x22
向量
通常用 \vec 表示向量, \overrightarrow 表示箭头向右的向量, \overleftarrow 表示箭头向左的向量。使用时后面还要跟上 {} ,即 \vec{向量字母} ,如:
\vec{a_0}=\overrightarrow{AB}-\overleftarrow{AC}
a 0 ⃗ = A B → − A C ← \vec{a_0}=\overrightarrow{AB}-\overleftarrow{AC} a0=AB−AC
积分
通常用 \int 表示积分,格式为 \int_{积分下限}^{积分上限}{公式}\mathrm{d}x ,例如:
y'=\int_{1}^{x}{(x^2+3x+3)}\mathrm{d}x
y ′ = ∫ 1 x ( x 2 + 3 x + 3 ) d x y'=\int_{1}^{x}{(x^2+3x+3)}\mathrm{d}x y′=∫1x(x2+3x+3)dx
此外还有二重积分 \iint ,闭合积分 \oint ,闭合二重积分 \oiint :
\iint \oint \oiint_{1}^{x}
∬ ∮ ∯ 1 x \iint \oint \oiint_{1}^{x} ∬∮∬1x
极限
通常用 \lim 表示极限, \infty 表示无穷,+\infty 表示正无穷, -\infty 表示负无穷, \to 表示向右的箭头(或者 \rightarrow ),格式为 \lim_{条件} ,例如:
\lim_{x \to +\infty}e^{-x}=0
lim x → + ∞ e − x = 0 \lim_{x \to +\infty}e^{-x}=0 x→+∞lime−x=0
求和
通常用 \sum 表示求和,格式 \sum_{下条件}^{上条件} ,如:
\sum_{i=1}^{100}x^{-1}=1^{-1}+2^{-1}+\cdots+100^{-1}
∑ i = 1 100 x − 1 = 1 − 1 + 2 − 1 + ⋯ + 10 0 − 1 \sum_{i=1}^{100}x^{-1}=1^{-1}+2^{-1}+\cdots+100^{-1} i=1∑100x−1=1−1+2−1+⋯+100−1
乘积
可以用 \prod 表示乘积,格式为 \prod_{下条件}^{上条件} ,例如:
\prod_{j=1}^{10}x^3=1^3\cdot2^3\cdots10^3
∏ j = 1 10 x 3 = 1 3 ⋅ 2 3 ⋯ 1 0 3 \prod_{j=1}^{10}x^3=1^3\cdot2^3\cdots10^3 j=1∏10x3=13⋅23⋯103
矩阵
对于不带任何括号的矩阵,通常以 \begin{matrix} 开始, \end{matrix} 结束,用 & 来分割列,用 \\ 来分割行,例如:
\begin{matrix}
1 & 2 \\
3 & 4 \\
\end{matrix}
1 2 3 4 \begin{matrix} 1 & 2 \\ 3 & 4 \\ \end{matrix} 1324
还有带方括弧的矩阵 bmatrix ,例如:
\begin{bmatrix}
a & b & \cdots \\
c & d & \cdots \\
\vdots & \vdots & \ddots \\
\end{bmatrix}
[ a b ⋯ c d ⋯ ⋮ ⋮ ⋱ ] \begin{bmatrix} a & b & \cdots \\ c & d & \cdots \\ \vdots & \vdots & \ddots \\ \end{bmatrix} ⎣⎢⎡ac⋮bd⋮⋯⋯⋱⎦⎥⎤
也有带两条竖线的矩阵 vmatrix ,例如:
\begin{vmatrix}
1 & 2 \\
3 & 4 \\
\end{vmatrix}
∣ 1 2 3 4 ∣ \begin{vmatrix} 1 & 2 \\ 3 & 4 \\ \end{vmatrix} ∣∣∣∣1324∣∣∣∣
最后有带圆括弧的矩阵 pmatrix ,例如:
\begin{pmatrix}
x_{11} & x_{12} & \cdots & x_{1j} \\
x_{21} & x_{22} & \cdots & x_{2j} \\
\vdots & \vdots & \ddots & \vdots \\
x_{i1} & x_{i2} & \cdots & x_{ij} \\
\end{pmatrix}
( x 11 x 12 ⋯ x 1 j x 21 x 22 ⋯ x 2 j ⋮ ⋮ ⋱ ⋮ x i 1 x i 2 ⋯ x i j ) \begin{pmatrix} x_{11} & x_{12} & \cdots & x_{1j} \\ x_{21} & x_{22} & \cdots & x_{2j} \\ \vdots & \vdots & \ddots & \vdots \\ x_{i1} & x_{i2} & \cdots & x_{ij} \\ \end{pmatrix} ⎝⎜⎜⎜⎛x11x21⋮xi1x12x22⋮xi2⋯⋯⋱⋯x1jx2j⋮xij⎠⎟⎟⎟⎞
证明
常用的证明符号如下:
公式 | 符号 | 说明 |
---|---|---|
\therefore | ∴ \therefore ∴ | 所以 |
\because | ∵ \because ∵ | 因为 |
\forall | ∀ \forall ∀ | 对于所有 |
\exist | ∃ \exist ∃ | 存在 |
\bigvee | ⋁ \bigvee ⋁ | 且 |
\bigwedge | ⋀ \bigwedge ⋀ | 或 |
\Leftarrow | ⇐ \Leftarrow ⇐ | |
\Rightarrow | ⇒ \Rightarrow ⇒ | |
\Leftrightarrow | ⇔ \Leftrightarrow ⇔ |
集合
对于常见的集合符号,有:
公式 | 符号 | 说明 |
---|---|---|
\bigcup | ⋃ \bigcup ⋃ | 并集 |
\bigcap | ⋂ \bigcap ⋂ | 交集 |
\subset | ⊂ \subset ⊂ | 属于 |
\supset | ⊃ \supset ⊃ | 属于 |
\subseteq | ⊆ \subseteq ⊆ | 真属于 |
\supseteq | ⊇ \supseteq ⊇ | 真属于 |
\in | ∈ \in ∈ | |
\notin | ∉ \notin ∈/ | |
\subsetneq | ⊊ \subsetneq ⊊ | |
\supsetneq | ⊋ \supsetneq ⊋ |
比较符
常见的比较符号如下:
公式 | 符号 | 说明 |
---|---|---|
< | < < < | 小于 |
> | > > > | 大于 |
\leq | ≤ \leq ≤ | 小于等于 |
\geq | ≥ \geq ≥ | 大于等于 |
\ll | ≪ \ll ≪ | 远小于 |
\gg | ≫ \gg ≫ | 远大于 |
= | = = = | 等于 |
\approx | ≈ \approx ≈ | 约等于 |
\neq | ≠ \neq = | 不等于 |
\equiv | ≡ \equiv ≡ | 恒等于 |
箭头
常用的箭头如下:
公式 | 符号 | 说明 |
---|---|---|
\leftarrow | ← \leftarrow ← | |
\rightarrow | → \rightarrow → | |
\leftrightarrow | ↔ \leftrightarrow ↔ | |
\Leftarrow | ⇐ \Leftarrow ⇐ | |
\Rightarrow | ⇒ \Rightarrow ⇒ | |
\Leftrightarrow | ⇔ \Leftrightarrow ⇔ | |
\uparrow | ↑ \uparrow ↑ | |
\downarrow | ↓ \downarrow ↓ | |
\updownarrow | ↕ \updownarrow ↕ | |
\Uparrow | ⇑ \Uparrow ⇑ | |
\Downarrow | ⇓ \Downarrow ⇓ | |
\Updownarrow | ⇕ \Updownarrow ⇕ | |
\leftharpoonup | ↼ \leftharpoonup ↼ | |
\leftharpoondown | ↽ \leftharpoondown ↽ | |
\rightharpoonup | ⇀ \rightharpoonup ⇀ | |
\rightharpoondown | ⇁ \rightharpoondown ⇁ | |
\rightleftharpoons | ⇌ \rightleftharpoons ⇌ | |
\leftrightharpoons | ⇋ \leftrightharpoons ⇋ | |
\iff | ⟺ \iff ⟺ | |
\mapsto | ↦ \mapsto ↦ |
希腊字母
通常大写希腊字母只需将小写希腊字母中LaTeX语法的第一个字母改为大写即可,如 \alpha α \alpha α 的大写为 \Alpha A \Alpha A ,小写希腊字母语法见下表:
公式 | 符号 | 说明 |
---|---|---|
\alpha | α \alpha α | |
\beta | β \beta β | |
\gamma | γ \gamma γ | |
\delta | δ \delta δ | |
\epsilon | ϵ \epsilon ϵ | |
\zeta | ζ \zeta ζ | |
\eta | η \eta η | |
\theta | θ \theta θ | |
\iota | ι \iota ι | |
\kappa | κ \kappa κ | |
\lambda | λ \lambda λ | |
\mu | μ \mu μ | |
\xi | ξ \xi ξ | |
o | o o o | |
\pi | π \pi π | |
\rho | ρ \rho ρ | |
\sigma | σ \sigma σ | |
\tau | τ \tau τ | |
\upsilon | υ \upsilon υ | |
\phi | ϕ \phi ϕ | |
\chi | χ \chi χ | |
\psi | ψ \psi ψ |
空格&间隔
- 两个单词之间使用 \! ,使输入的单词之间内容紧贴,缩进1/6宽度:
Embrace\!the\!glorious\!mess\!that\!you\!are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\!the\!glorious\!mess\!that\!you\!are. Embracethegloriousmessthatyouare.
- 单词之间使用 \, ,使输出的单词之间有了较小的空格,间隔1/6宽度:
Embrace\,the\,glorious\,mess\,that\,you\,are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\,the\,glorious\,mess\,that\,you\,are. Embracethegloriousmessthatyouare.
- 单词之间使用";",使输出的单词之间有了中等的空格,间隔2/7宽度:
Embrace\;the\;glorious\;mess\;that\;you\;are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\;the\;glorious\;mess\;that\;you\;are. Embracethegloriousmessthatyouare.
- 单词之间使用"\ ",使输出的单词之间有了大空格,间隔1/3宽度:
Embrace\ the\ glorious\ mess\ that\ you\ are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\ the\ glorious\ mess\ that\ you\ are. Embrace the glorious mess that you are.
- 单词之间使用"\quad ",使输出的单词之间有了大空格,间隔1宽度:
Embrace\quad the\quad glorious\quad mess\quad that\quad you\quad are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\quad the\quad glorious\quad mess\quad that\quad you\quad are. Embracethegloriousmessthatyouare.
- 单词之间使用"\qquad ",使输出的单词之间有了大空格,间隔2宽度:
Embrace\qquad the\qquad glorious\qquad mess\qquad that\qquad you\quad are.
E m b r a c e t h e g l o r i o u s m e s s t h a t y o u a r e . Embrace\qquad the\qquad glorious\qquad mess\qquad that\qquad you\quad are. Embracethegloriousmessthatyouare.
字母上标
字母上标就是字母头上的标记,如 a ^ \hat{a} a^ 。
所有类型的上标如下表格所示:
公式 | 符号 |
---|---|
\hat{a} | a ^ \hat{a} a^ |
\ddot{a} | a ¨ \ddot{a} a¨ |
\bar{a} | a ˉ \bar{a} aˉ |
\vec{a} | a ⃗ \vec{a} a |
\grave{a} | a ˋ \grave{a} aˋ |
\breve{a} | a ˘ \breve{a} a˘ |
\overline{a} | a ‾ \overline{a} a |
\widehat{a} | a ^ \widehat{a} a |
\dot{a} | a ˙ \dot{a} a˙ |
\check{a} | a ˇ \check{a} aˇ |
\tilde{a} | a ~ \tilde{a} a~ |
\acute{a} | a ˊ \acute{a} aˊ |
\widetilde{a} | a ~ \widetilde{a} a |
\sim | ∼ \sim ∼ |
其中里面的 a 可以换成其他字母或者表达式!
公式组合
通过 cases 语句可以实现公式的组合,用 & 来分割公式和条件,用 \\ 来换行,例如:
F(x)=
\begin{cases}
x^2+x+1 & x<3 \\
1 & 3<=x<4 \\
\int_4^{x}{x^3}\mathrm{d}x & x>=4 \\
\end{cases}
F ( x ) = { x 2 + x + 1 x < 3 1 3 < = x < 4 ∫ 4 x x 3 d x x > = 4 F(x)= \begin{cases} x^2+x+1 & x<3 \\ 1 & 3<=x<4 \\ \int_4^{x}{x^3}\mathrm{d}x & x>=4 \\ \end{cases} F(x)=⎩⎪⎨⎪⎧x2+x+11∫4xx3dxx<33<=x<4x>=4
公式拆分
可以用 split 语句来拆分公式,用 & 来分割,用 \\ 来换行,例如:
\begin{split}
\cos 2x & = \cos^2 2x-\sin^22x \\
&=2\cos^2x-1 \\
\end{split}
KaTeX parse error: No such environment: split at position 8: \begin{̲s̲p̲l̲i̲t̲}̲ \cos 2x & = \c…