Markdown與數(shù)學公式

Markdown與數(shù)學公式

1 基本語法

  • Markdown數(shù)學公式的表達形式包括兩種類型:

    • 行內(nèi)公式(inline)
    • 塊間公式(displayed)
  • Markdown數(shù)學公式的書寫形式對應兩種類型:

    • 行內(nèi)公式 $……$,例如本行表達式y=\sum_^{a}x^2的表達形式為:
    $y=\sum_^{a}x^2$
    
    • 塊間公式 $$……$$,例如下行表達式的表達形式為:
      x=\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}
    $$
    x=\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}
    $$
    

2 形式語法

2.1 希臘字母

希臘字母(小寫) Markdown表達形式 希臘字母(大寫) Markdown表達形式
\alpha \alpha \Alpha \Alpha
\beta \beta \Beta \Beta
\gamma \gamma \Gamma \Gamma
\delta \delta \Delta \Delta
\epsilon \epsilon \Epsilon \Epsilon
\zeta \zeta \Zeta \Zeta
\eta \eta \Eta \Eta
\theta \theta \Theta \Theta
\iota \iota \Iota \Iota
\kappa \kappa \Kappa \Kappa
\lambda \lambda \Lambda \Lambda
\mu \mu \Mu \Mu
\nu \nu \Nu \Nu
\xi \xi \Xi \Xi
\omicron \omicron \Omicron \Omicron
\pi \pi \Pi \Pi
\rho \rho \Rho \Rho
\sigma \sigma \Sigma \Sigma
\tau \tau \Tau \Tau
\upsilon \upsilon \Upsilon \Upsilon
\varphi \varphi \varPhi \varPhi
\phi \phi \Phi \Phi
\chi \chi \Chi \Chi
\psi \psi \Psi \Psi
\Omega \omega \Omega \Omega

2.2 上標與下標

  • 下標使用“_“,上標使用“^”,例如x_i^2的表達式為:
$x_i^2$
  • 上下標可以嵌套使用,例如x^{y^z}的表達式為:
$x^{y^z}$
  • 默認情況下,“_“、“^”之后的一位才是上下標的內(nèi)容,當超過一個字符,使用“{ }”括起來,例如x_{2i}^{2+b}的表達式為:
$x_{2i}^{2+b}$
  • 其他表達形式
表達式 Markdown表達形式 表達式 Markdown表達形式
x_i^2 x_i^2 x_{2i}^{2+b} x_{2i}^{2+b}
\hat{a} \hat{a} \acute{a} \acute{a}
\grave{a} \grave{a} \breve{a} \breve{a}
\bar{a} \bar{a} \widetilde{a} \widetilde{a}
\check{a} \check{a} \tilde{a} \tilde{a}
\dot{a} \dot{a} \ddot{a} \ddot{a}
\vec{a} \vec{a} \widehat{a} \widehat{a}

2.3 括號

  • 表達式中()、[]均可正常使用,但{}的表達式分為為:\{、\}
  • 左、右括號的標記形式:
    • 左括號 \left(\left[,\left\{
    • 右括號 \right),\right],\right\}
  • 上、下花括號的表達形式:
    \underbrace{a \dots a}_{24個}?\overbrace{b \dots b}^{17個}
$$
\underbrace{a \dots a}_{24個}?\overbrace{b \dots b}^{17個}
$$
  • 上、下連線符的表達形式:
    • 上連線符:\overline{a+b+c+d}
$\overline{a+b+c+d}$
  • 下連線符:\underline{a+b+c+d}
$\underline{a+b+c+d}$
  • 上、下括號與連線符的混合使用
    A=\overbrace{(a+b)+\underbrace{(c+d)i}_{\text{虛數(shù)}}}^{復數(shù)}+(e+f)+\underline{(g+h)}
$$
A=\overbrace{(a+b)+\underbrace{(c+d)i}_{\text{虛數(shù)}}}^{復數(shù)}+(e+f)+\underline{(g+h)}
$$
  • 大括號右多行賦值的表達形式:
    P(x|pa_x)=\begin{cases} 1, &x=f(pa_x) \\0, &other\ values\end{cases}
$$
P(x|pa_x)=\begin{cases} 1, &x=f(pa_x) \\0, &other\ values\end{cases}
$$
  • 其他表達形式
表達式 Markdown表達形式 表達式 Markdown表達形式
\left(\dots\right) \left(\dots\right)
\vert \vert \Vert \Vert
\langle \langle \rangle \rangle
\lceil \lceil \rceil \rceil
\lfloor \lfloor \rfloor \rfloor
\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)
\vert x \vert \vert x \vert

2.4 對數(shù)函數(shù)

  • \log_{a}{x}函數(shù)底數(shù)使用“_”表示,其表達式為:
$\log_{a}{x}$

2.5 矩陣

表達式 Markdown表達形式
\begin{matrix} 0&1 \\1&0 \end{matrix} \begin{matrix} 0&1 \1&0 \end{matrix}
\begin{pmatrix} 0&-i \\i&0 \end{pmatrix} \begin{pmatrix} 0&1 \1&0 \end{pmatrix}
\begin{bmatrix} 0&-1 \\1&0 \end{bmatrix} \begin{bmatrix} 0&-1 \1&0 \end{bmatrix}
\begin{Bmatrix} 1&0 \\0&1 \end{Bmatrix} \begin{Bmatrix} 1&0 \0&1 \end{Bmatrix}
\begin{vmatrix} a&b \\c&d \end{vmatrix} \begin{vmatrix} a&b \c&d \end{vmatrix}
\begin{Vmatrix} i&0 \\0&-i\end{Vmatrix} \begin{Vmatrix} i&0 \0&-i\end{Vmatrix}

2.6 求和與積分

表達式 Markdown表達形式 表達式 Markdown表達形式
\sum \sum \int \int
\sum_1^n \sum_1^n \sum_{i=0}^\infty i^2 \sum_{i=0}^\infty i^2
\prod \prod \infty \infty
\bigcup \bigcup \bigcap \bigcap
\iint \iint \iiint \iiint

2.7 條件偏導

  • \partial標記條件偏導
  • 條件偏導的表達形式示例:
    \left.\frac{\partial f(x,y)}{\partial x}\right|_{x=0}
$$
\left.\frac{\partial f(x,y)}{\partial x}\right|_{x=0}
$$

2.7 根號開方

  • \sqrt標記根號開方,基本語法為:$\sqrt[開方次數(shù)]{開方因子}$
  • 根號開方的幾種表達形式:
表達式 Markdown表達形式
\sqrt{x^3} \sqrt{x^3}
\sqrt[3]{\frac xy} \sqrt[3]{\frac xy}

2.8 分數(shù)

  • 分數(shù)的語法單元1 $\frac{分子}{分母}$
  • 分數(shù)的語法單元2 $分子\over 分母$ (用pandoc無法轉(zhuǎn)成Word)
  • 分數(shù)的幾種表達形式:
表達式 Markdown表達形式
\frac ab \frac ab
\frac {a+1}{b-1} \frac {a+1}{b-1}
a+1 \over b+1 a+1 \over b+1
\cfrac{a} \cfrac{a}

2.9 特殊函數(shù)

表達式 Markdown表達形式 表達式 Markdown表達形式
\lim \lim \lim_{x \to 0} \lim_{x \to 0}
\hat{x} \hat{x} \widehat{xy} \widehat{xy}
\check{a} \check{a} \breve{a} \breve{a}
\bar{a} \bar{a} \tilde{a} \tilde{a}
\acute{a} \acute{a} \grave{a} \grave{a}
\mathring{a} \mathring{a}
\imath \imath \jmath \jmath
\overline{xyz} \overline{xyz} \vec{x} \vec{x}
\overleftarrow{xyz} \overleftarrow{xyz} \overrightarrow{xyz} \overrightarrow{xyz}
\overleftrightarrow{xyz} \overleftrightarrow{xyz}
\dot x \dot x \ddot{x} \ddot{x}

2.10 特殊符號

  • 關系運算符
表達式 Markdown表達形式 表達式 Markdown表達形式
\pm \pm \mp \mp
\times \times \div \div
\mid \mid \nmid \nmid
\not\gt \not\gt \not\lt \not\lt
\lt \lt \gt \gt
\le \le \ge \ge
\leq \leq \geq \geq
\leqslant \leqslant \geqslant \geqslant
\leqq \leqq \geqq \geqq
\approx \approx \sim \sim
\simeq \simeq \cong \cong
\equiv \equiv \neq \neq
\sum \sum \prod \prod
\ast \ast
  • 集合運算符
表達式 Markdown表達形式 表達式 Markdown表達形式
\in \in \notin \notin
\subset \subset \supset \supset
\subseteq \subseteq \subsetneq \subsetneq
\supseteq \supseteq \supsetneq \supsetneq
\cup \cup \cap \cap
\bigcup \bigcup \bigcap \bigcap
\emptyset \emptyset \varnothing \varnothing
\vee \vee \wedge \wedge
\bigvee \bigvee \bigwedge \bigwedge
\bigodot \bigodot \bigotimes \bigotimes
\mathbb{R} \mathbb{R} \mathbb{Z} \mathbb{Z}
  • 對數(shù)運算符
表達式 Markdown表達形式
\log \log
\lg \lg
\ln \ln
  • 三角運算符
表達式 Markdown表達形式 表達式 Markdown表達形式
\angle \angle n^\circ n^\circ
\sin \sin \sec \sec
\cos \cos \csc \csc
\tan \tan \cot \cot
  • 微積分運算符
表達式 Markdown表達形式 表達式 Markdown表達形式
\prime \prime \int \int
\iint \iint \iiint \iiint
\oint \oint \oiint \oiint
\oiiint \oiiint \infty \infty
\lim \lim \nabla \nabla
  • 邏輯運算符
表達式 Markdown表達形式 表達式 Markdown表達形式
\because \because \therefore \therefore
\forall \forall \exists \exists
\not ={} \not ={} \not \subset \not \subset
  • 箭頭符號
表達式 Markdown表達形式 表達式 Markdown表達形式
\rightarrow \rightarrow \leftarrow \leftarrow
\Rightarrow \Rightarrow \Leftarrow \Leftarrow
\longrightarrow \longrightarrow \longleftarrow \longleftarrow
\Longrightarrow \Longrightarrow \Longleftarrow \Longleftarrow
\downarrow \downarrow \uparrow \uparrow
\Downarrow \Downarrow \Uparrow \Uparrow
\leftrightarrow \leftrightarrow \Leftrightarrow \Leftrightarrow
  • 其他符號
表達式 Markdown表達形式 表達式 Markdown表達形式
\setminus \setminus \to \to
\land \land \lor \lor
\top \top \bot \bot
\lnot \lnot \mapsto \mapsto
\vdash \vdash \vDash \vDash
\star \star \bullet \bullet
\oplus \oplus \prec \prec
\lhd \lhd \nabla \nabla
\aleph_0 \aleph_0 \Re \Re
\varepsilon \varepsilon \ell \ell
{n+1 \choose 2K} {n+1 \choose 2K} \binom{n+1}{2K} \binom{n+1}{2K}

2.11 空格與省略號

  • 空格包括三種表達形式(間隔空間依次增大):
表達式 Markdown表達形式 備注
a\!b $a\!b$ 緊貼
ab ab 默認空格
a\ b $a\ b$ 大空格
a\quad b $a\quad b$ quad空格
a\qquad b $a\qquad b$ 兩個quad空格
  • 省略號包括兩種類型:
    • 與文本底線對齊:\ldots
    • 與文本中線對齊:\cdots
    • 豎直對齊:\vdots
    • 斜對齊:\ddtos
    • 省略號的表達形式示例:f(x_1,x_2,\ldots,x_n)=x_1^2+x_2^2+\cdots+x_n^n
$f(x_1,x_2,\ldots,x_n)=x_1^2+x_2^2+\cdots+x_n^n$

2.12 字體

表達式 Markdown表達形式 表達式 Markdown表達形式
\mathbb{ABCDE} \mathbb{ABCDE} \Bbb{ABCDE} \Bbb{ABCDE}
\mathbf{abcde} \mathbf{abcde} \mathtt{ABCDE} \mathtt{ABCDE}
\mathrm{ABCDE} \mathrm{ABCDE} \mathsf{ABCDE} \mathsf{ABCDE}
\mathcal{ABCDE} \mathcal{ABCDE} \mathscr{ABCDE} \mathscr{ABCDE}
\mathfrak{abcde} \mathfrak{abcde} \boldsymbol{A} \boldsymbol{A}

2.13 其他

  • 文本內(nèi)容 \mbox{文本內(nèi)容}
  • 字體控制(使得符號大小適中) \displaystyle
  • 數(shù)字標簽 \tag{數(shù)字}

3 高級應用

3.1 方程式

  • 方程式語法單元1 $$\begin{equation}…\end{equation},使用\\換行
    \begin{equation} E=mc^2 \\ \end{equation}
$$
\begin{equation}
    E=mc^2 \\
\end{equation}
$$
  • 方程式語法單元2 $$\begin{align}…\end{align},使用\\換行,&\text{注釋}添加方程式的注釋說明,\tag n添加公式編號
    \begin{align} \sqrt{37} &= \sqrt{\frac{73^2-1}{12^2}} &\text{方程式注釋} \tag 1 \\ &= \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \tag 2 \\ &= \sqrt{\frac{73^2}{12^2}}\cdot\sqrt{\frac{73^2-1}{73^2}} \tag 3 \\ &= \frac{73}{12}\sqrt{1-\frac{1}{73^2}} \tag 4 \\ & \approx \frac{73}{12}\left(1-\frac{1}{2\cdot 73^2}\right) \tag 5 \\ \end{align}
$$
\begin{align}
    \sqrt{37} &= \sqrt{\frac{73^2-1}{12^2}} &\text{方程式注釋} \tag 1 \\
    &= \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \tag 2 \\
    &= \sqrt{\frac{73^2}{12^2}}\cdot\sqrt{\frac{73^2-1}{73^2}} \tag 3 \\
    &= \frac{73}{12}\sqrt{1-\frac{1}{73^2}} \tag 4 \\
    & \approx \frac{73}{12}\left(1-\frac{1}{2\cdot 73^2}\right) \tag 5 \\
\end{align}
$$
  • 方程式語法單元3 $$\begin{eqnarray}…\end{eqnarray},使用\\換行
    \begin{eqnarray}f(x,y) &=& 2xy+(x-y)^2 \\ &=& x^2+y^2 \\ \end{eqnarray}
$$
\begin{eqnarray}f(x,y)
    &=& 2xy+(x-y)^2 \\
    &=& x^2+y^2 \\
\end{eqnarray}
$$

3.2 矩陣與行列式

  • 矩陣語法單元 $$\begin{matrix}…\end{matrix}$$,使用&分隔同行元素,\\換行
    \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix}
$$
    \begin{matrix}
        1 & x & x^2 \\
        1 & y & y^2 \\
        1 & z & z^2 \\
    \end{matrix}
$$
  • 行列式語法單元 $$\left|\begin{matrix}…\end{matrix}\right|$$,使用&分隔同行元素,\\換行
    \left| \begin{matrix} x_{11} & x_{12} & \cdots & x_{1d} \\ x_{21} & x_{22} & \cdots & x_{2d} \\ \vdots & \vdots & \ddots & \vdots \\ x_{m1} & x_{m2} & \cdots & x_{md} \\ \end{matrix} \right|
$$
    \left|
    \begin{matrix}
        x_{11} & x_{12} & \cdots & x_{1d} \\
        x_{21} & x_{22} & \cdots & x_{2d} \\
        \vdots & \vdots & \ddots & \vdots \\
        x_{m1} & x_{m2} & \cdots & x_{md} \\
    \end{matrix}
    \right|
$$
  • 使用begin{array}end{array}輸入數(shù)組,其中使用c、l、r分別表示居中對齊、左對齊和右對齊,\hline輸入水平分割線,&隔開每個元素
    \begin{array}{c|clr} n & \text{a} & \text & \text{c} \\ \hline 1 & 0.97 & 0.83 & 123 \\ 2 & 0.87 & 0.68 & 129 \\ 3 & -0.02 & 0.88 & 101 \\ \end{array}
$$
\begin{array}{c|clr}
    n & \text{a} & \text & \text{c} \\
    \hline
    1 & 0.97 & 0.83 & 123 \\
    2 & 0.87 & 0.68 & 129 \\
    3 & -0.02   & 0.88 & 101 \\
\end{array}
$$

\left( \begin{array}{ccccc} 1 & 2 & 3 & 4 & 5 \\ 1 & 2 & 3 & 4 & 5 \\ 1 & 2 & 3 & 4 & 5 \\ \end{array} \right)

$$
\left(
    \begin{array}{ccccc}
        1 & 2 & 3 & 4 & 5 \\
        1 & 2 & 3 & 4 & 5 \\
        1 & 2 & 3 & 4 & 5 \\
    \end{array}
\right)
$$

\left[ \begin{array}{cc|c} 1 & 1 & 1 \\ 2 & 2 & 2 \\ \hline 3 & 3 & 3 \\ \end{array} \right]

$$
\left[
    \begin{array}{cc|c}
        1 & 1 & 1 \\
        2 & 2 & 2 \\
        \hline
        3 & 3 & 3 \\
    \end{array}
\right]
$$

3.3 方程組

  • 方程組語法單元1 $$\left\{\begin{array}…\end{array}\right\}$$,使用\\換行
    \left\{ \begin{array}{c} a_1x + a_2y + a_3z=d_1 \\ b_1x + b_2y + b_3z=d_2 \end{array} \right.
$$
\left\{
\begin{array}{c}
    a_1x + a_2y + a_3z=d_1 \\
    b_1x + b_2y + b_3z=d_2
\end{array}
\right.
$$
  • 方程組語法單元2 $$\begin{cases}…\end{cases}$$,使用\\換行
    \begin{cases} a_1x + b_1y + c_1z =d_1 \\ a_2x + b_2y + c_2z =d_2 \\ a_3x + b_3y + c_3z =d_3 \end{cases}
$$
\begin{cases}
    a_1x + b_1y + c_1z =d_1 \\
    a_2x + b_2y + c_2z =d_2 \\
    a_3x + b_3y + c_3z =d_3
\end{cases}
$$

3.4 分段函數(shù)

  • 分段函數(shù)語法單元 $$f(x)=\begin{cases}…\end{cases}$$,使用\\換行
    f(x)= \begin{cases} \dfrac{x}{2}, & \text{if $x$ is even} \\ 3x+1, & \text{if $x$ is odd} \end{cases}
$$
f(x)=
\begin{cases}
    \dfrac{x}{2}, & \text{if $x$ is even} \\
    3x+1, & \text{if $x$ is odd}
\end{cases}
$$

3.5 求和

  • 默認求和公式
    \sum_{k=1}^n{x_k}
$$
\sum_{k=1}^n{x_k}
$$
  • 強制求和公式
    \sum\limits_{k=1}^n{x_k}
$$
\sum\limits_{k=1}^n{x_k}
$$

\sum\nolimits_{k=1}^n{x_k}

$$
\sum\nolimits_{k=1}^n{x_k}
$$
  • 多行限制條件求和公式
    \prod_{k_0,k_1,\ldots>0\atop k_0+k_1+\cdots=n}{A_{k_0}A_{k_1}\cdots}
$$
\prod_{k_0,k_1,\ldots>0\atop k_0+k_1+\cdots=n}{A_{k_0}A_{k_1}\cdots}
$$

3.6 常用數(shù)學公式

  • 線性模型
    h(\theta)= \sum_{j=0}^n \theta_jx_j
$$
h(\theta)= \sum_{j=0}^n \theta_jx_j
$$
  • 均方誤差
    J(\theta)= \frac{1}{2m} \sum_{i=0}^m (y^i-h_{\theta} (x^i))^2
$$
J(\theta)= \frac{1}{2m} \sum_{i=0}^m (y^i-h_{\theta} (x^i))^2
$$
  • 批量梯度下降
    \frac{\partial J(\theta)}{\partial {\theta}_j}= -\frac1m \sum_{i=0}^m(y^i-h_{\theta}(x^i))x_j^i
$$
\frac{\partial J(\theta)}{\partial {\theta}_j}= -\frac1m \sum_{i=0}^m(y^i-h_{\theta}(x^i))x_j^i
$$
  • 其他公式
    \sideset {^a_b}{^c_d}\prod ^e_f
$$
\sideset {^a_b}{^c_d}\prod ^e_f
$$

\underset{e}{\overset{f}{_a^bM_c^d}}

$$
\underset{e}{\overset{f}{_a^bM_c^d}}
$$

\lim_{x\rightarrow{\infty}}(1+\frac{1}{x})^{x}=e

$$
\lim_{x\rightarrow{\infty}}(1+\frac{1}{x})^{x}=e
$$

\int_{a}^f(x)dx=F(b)-F(a)

$$
\int_{a}^f(x)dx=F(b)-F(a)
$$

3.7 解決\frac字符顯示過小的問題

使用\dfrac解決\frac字符顯示過小的問題,例如:
x_1^*=\dfrac{a_{22}r_1-a_{12}r_2}{a_{11}a_{22}-a_{12}a_{21}}

$$
x_1^*=\dfrac{a_{22}r_1-a_{12}r_2}{a_{11}a_{22}-a_{12}a_{21}}
$$

參閱資料

1.超詳細 LaTex數(shù)學公式
2.math-上花括號或下花括號
3.LaTeX技巧心得255:用laTeX排版大括號的三種方法
4.使用CSDN的markdown編輯器插入數(shù)學公式
5.CSDN-markdown 之 LaTeX 特殊公式格式筆記
6.試試LaTeX插入數(shù)學公式
7.LaTeX快速入門:一文淺談TeX排版語法
8.latex排版知識點總結(jié)——(特殊符號、公式)
9.Latex語法(符號及數(shù)學公式)
10.在博客中使用LaTeX插入數(shù)學公式

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容