編輯你的數學公式——markdown中latex的使用

前言

最近開始使用起markdown來記學習筆記,由於常常有公式要寫,就須要用到latex,到網上查來查去又不太方便,並且也不多能查到寫的比較全的,就準備寫下這篇文章。html

插入數學公式

在markdown中插入數學公式的語法有兩種:git

  1. 行內公式$數學公式$
  2. 行間公式$$數學公式$$

如:github

函數$ L(Y,f(X))=(Y-f(X))^2 $
函數
$$ 
L(Y,f(X))=(Y-f(X))^2 
$$

函數$ L(Y,f(X))=(Y-f(X))^2 ​$markdown

函數app

\[ L(Y,f(X))=(Y-f(X))^2 \]
若是須要加編號,加上\tag{編號}便可,如:ide

$$ 
L(Y,f(X))=(Y-f(X))^2 
\tag{1}
$$

\[ L(Y,f(X))=(Y-f(X))^2 \tag{1} \]函數

上下標

上標可由^表示,下標可由_表示,若上下標不止一個字符則需用花括號{}括起學習

如:字體

n_x n^x

\(n_x\) \(n^x\)ui

分數

分數輸入格式爲\frac{分子}{分母}

如:

$\frac{1}{N}$

\(\frac{1}{N}\)

括號

() []|都表示本身,可是{}需加\

如:

$() [] | \{\}$

\(() [] | \{\}\)

上下劃線

$$
\begin{array}
\overline{a+b} \\
\underline{a+b} \\
\overleftarrow{a+b} \\
\underleftarrow{a+b} \\
\underleftrightarrow{a+b} \\
\vec x = \vec{AB} \\
\overbrace {a+b}^\text{a,b} \\
a+\rlap{\overbrace{\phantom{b+c+d}}^m}b+\underbrace{c+d+e}_n+f
\end{array}
$$

\[ \begin{array} \overline{a+b} \\ \underline{a+b} \\ \overleftarrow{a+b} \\ \underleftarrow{a+b} \\ \underleftrightarrow{a+b} \\ \vec x = \vec{AB} \\ \overbrace {a+b}^\text{a,b} \\ a+\rlap{\overbrace{\phantom{b+c+d}}^m}b+\underbrace{c+d+e}_n+f \end{array} \]

省略號

$$
\begin{eqnarray*} \\
\ldots \\
\cdots \\
\vdots \\
\ddots \\
\end{eqnarray*}
$$

\[ \begin{eqnarray*} \\ \ldots \\ \cdots \\ \vdots \\ \ddots \\ \end{eqnarray*} \]

線性方程組

使用case環境將多個公式組合

$$
L(Y,f(X))=
\begin{cases}
1,\quad &Y\neq f(X)\\
0,\quad &Y=f(X)
\end{cases}
$$

\[ L(Y,f(X))= \begin{cases} 1,\quad &Y\neq f(X)\\ 0,\quad &Y=f(X) \end{cases} \]
另還有gathered環境

$$
\left. \begin{gathered}
S \subseteq T \\
S \supseteq T
\end{gathered} \right\}
\implies S = T  
$$

\[ \left. \begin{gathered} A \subseteq B \\ A \supseteq B \end{gathered} \right\} \implies A = B \]

數學模式重音符

$$
\hat{a} \check{a} \tilde{a} \acute{a}
\grave{a} \dot{a} \ddot{a} \breve{a}
\bar{a} \vec{a} \widehat{a} \widetilde{a}
$$

\[ \hat{a} \check{a} \tilde{a} \acute{a}\\ \grave{a} \dot{a} \ddot{a} \breve{a}\\ \bar{a} \vec{a} \widehat{a} \widetilde{a} \]

矩陣

$$
X = 
\left[
\begin{matrix}
 x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\
 x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\
 x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\
\end{matrix}
\right]
$$

\[ X = \left[ \begin{matrix} x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\ x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\ x^{(1)} & x^{(2)} & \cdots & x^{(m)} \\ \end{matrix} \right] \]

希臘字母

見下表

代碼 大寫 代碼 小寫
A A \alpha α
B B \beta β
\Gamma Γ \gamma γ
\Delta Δ \delta δ
E E \epsilon ϵ
Z Z \zeta ζ
H H \eta η
\Theta Θ \theta θ
I I \iota ι
K K \kappa κ
\Lambda Λ \lambda λ
M M \mu μ
N N \nu ν
\Xi Ξ \xi ξ
O O \omicron ο
\Pi Π \pi π
P P \rho ρ
\Sigma Σ \sigma σ
T T \tau τ
\Upsilon Υ \upsilon υ
\Phi Φ \phi ϕ
X X \chi χ
\Psi Ψ \psi ψ
\Omega Ω \omega ω

經常使用數學符號

包括積分符號、集合符號、累乘累加符號等

見下表:

轉義符號 效果
\log_{x}y = \arccos z \(\log_{x}y = \arccos z\)
\frac{a} {b} \(\frac{a} {b}\)
_{a}^{b}\textrm{C} \(_{a}^{b}\textrm{C}\)
\frac{\partial {z_x}}{\partial x} \(\frac{\partial {z_x}}{\partial x}\)
\frac{\partial^2 {x}}{\partial x^2} \(\frac{\partial^2 {x}}{\partial x^2}\)
\frac{\mathrm{d} y}{\mathrm{d} x} \(\frac{\mathrm{d} y}{\mathrm{d} x}\)
\int x \(\int x\)
\int_{a}^{b}x \(\int_{a}^{b}x\)
\oint a \(\oint a\)
\oint_{a}^{b}C \(\oint_{a}^{b}C\)
\iint_{a}^{v}C \(\iint_{a}^{v}C\)
\bigcap A \(\bigcap A\)
\bigcap_{a}^{b}C \(\bigcap_{a}^{b}C\)
\bigcup c \(\bigcup c\)
\bigcup_{a}^{b}C \(\bigcup_{a}^{b}C\)
\lim_{c}X \(\lim_{c}X\)
\sum a \(\sum a\)
\sum_{a}^{b}C \(\sum_{a}^{b}C\)
\sqrt{X} \(\sqrt{X}\)
\sqrt[a]{X} \(\sqrt[a]{X}\)
\prod X \(\prod X\)
\prod_{a}^{b} X \(\prod_{a}^{b} X\)
\coprod X \(\coprod X\)
\coprod_{a}^{b} X \(\coprod_{a}^{b} X\)
\left [ a \right ] \(\left [ a \right ]\)
\left ( a\right ) \(\left ( a\right )\)
\left \{ a \right \} \(\left \{ a \right \}\)
\left \langle a \right \rangle \(\left \langle a \right \rangle\)
\left \lfloor a \right \rfloor \(\left \lfloor a \right \rfloor\)
\left \lceil a \right \rceil \(\left \lceil a \right \rceil\)
\supseteqq A \(\supseteqq A\)

二元關係符

\[ \begin{array} & < &\texttt{"<"} & > &\texttt{">"} &= &\texttt{"="}\\ \leq &\texttt{"\leq or \le"} & \geq &\texttt{"\geq or \ge"} &\equiv &\texttt{"\equiv"}\\ \ll &\texttt{"\ll"} & \gg &\texttt{"\gg"} &\doteq &\texttt{"\doteq"}\\ \prec &\texttt{"\prec"} & \succ &\texttt{"\succ"} &\sim &\texttt{"\sim"}\\ \preceq &\texttt{"\preceq"} & \succeq &\texttt{"\succeq"} &\simeq &\texttt{"\simeq"}\\ \subset &\texttt{"\subset"} & \supset &\texttt{"\supset"} &\approx &\texttt{"\approx"}\\ \subseteq &\texttt{"\subseteq"} & \supseteq &\texttt{"\supseteq"} &\approxeq &\texttt{"\approxeq"}\\ \sqsubset &\texttt{"\sqsubset"} & \sqsupset&\texttt{"\sqsupset"} &\Join &\texttt{"\Join"}\\ \sqsubseteq &\texttt{"\sqsubseteq"} & \sqsupseteq&\texttt{"\sqsupseteq"} &\bowtie &\texttt{"\bowtie"}\\ \in &\texttt{"\in"} & \ni &\texttt{"\ni or \owns"} &\propto &\texttt{"\propto"}\\ \vdash &\texttt{"\vdash"} & \dashv &\texttt{"\dashv"} &\models &\texttt{"\models"}\\ \mid &\texttt{"\mid"} & \parallel &\texttt{"\parallel"} &\perp &\texttt{"\perp"}\\ \smile &\texttt{"\smile"} & \frown &\texttt{"\frown"} &\asymp &\texttt{"\asymp"}\\ : &\texttt{":"} & \notin &\texttt{"\notin"} &\neq &\texttt{"\neq or \ne"}\\ \end{array} \]

三角函數與邏輯數學字符

數學字符 輸入 數學字符 輸入
± \pm × \times
÷ \div | \mid
∤∤ \nmid \cdot
\circ \ast
\bigodot \bigotimes
\bigoplus \emptyset
\bigvee \bigwedge
\biguplus \bigsqcup
\angle 30^∘ 30 ^ \circ
sin \sin cos \cos
tan \tan cot \cot
\prime \iiint
\iiiint \infty
\nabla \because
\therefore \forall
\exists \not>
\not\subset sec \sec
\uparrow \downarrow
\Uparrow \Downarrow
\rightarrow \leftarrow
\Rightarrow \Leftarrow
\longrightarrow \longleftarrow
\Longrightarrow \Longleftarrow
\quad (空格) # #
\bot

數學字體

字體表

\[ \begin{array} \texttt{"normal"} &\texttt{} & ABCDEFGHIJKLMNOPQRSTUVWXYZ\\ \texttt{"blackboard"} &\texttt{\mathbb} &\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"boldface"} &\texttt{\mathbf} &\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"typewriter"} &\texttt{\mathtt} &\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"roman"} &\texttt{\mathrm} &\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"sans-serif"} &\texttt{\mathsf} &\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"calligraphic"}&\texttt{\mathcal} &\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"script"} &\texttt{\mathscr} &\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \texttt{"fraktur"} &\texttt{\mathfrak}&\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ \end{array} \]

色彩表

\[ \begin{array} \hline \verb+\color{black}{黑色}+ & \color{black}{黑色} \\ \verb+\color{darkgray}{深灰}+ & \color{darkgray}{深灰}\\ \verb+\color{gray}{灰色}+ & \color{gray}{灰色} \\ \verb+\color{silver}{銀色}+ & \color{silver}{銀色} \\ \verb+\color{lightgray}{淺灰}+&\color{lightgray}{淺灰}\\ \verb+\color{white}{白色}+ & \color{white}{白色} \\ \hline \verb+\color{brown}{棕色}+ & \color{brown}{棕色} \\ \verb+\color{maroon}{栗色}+ & \color{maroon}{栗色} \\ \verb+\color{red}{紅色}+ & \color{red}{紅色} \\ \verb+\color{fuchsia}{桃紅}+ & \color{fuchsia}{桃紅} \\ \verb+\color{magenta}{品紅}+ & \color{magenta}{品紅} \\ \verb+\color{pink}{粉紅}+ & \color{pink}{粉紅} \\ \verb+\color{orange}{橙色}+ & \color{orange}{橙色} \\ \verb+\color{yellow}{黃色}+ & \color{yellow}{黃色} \\ \verb+\color{lime}{青檸}+ & \color{lime}{青檸} \\ \verb+\color{olive}{橄欖}+ & \color{olive}{橄欖} \\ \verb+\color{green}{綠色}+ & \color{green}{綠色} \\ \verb+\color{aqua}{水綠}+ & \color{aqua}{水綠} \\ \verb+\color{cyan}{青色}+ & \color{cyan}{青色} \\ \verb+\color{teal}{靛青}+ & \color{teal}{靛青} \\ \verb+\color{blue}{藍色}+ & \color{blue}{藍色} \\ \verb+\color{navy}{海藍}+ & \color{navy}{海藍} \\ \verb+\color{violet}{羅蘭}+ & \color{purple}{羅蘭} \\ \verb+\color{purple}{紫色}+ & \color{purple}{紫色} \\ \hline \end{array}參考 \]

參考:

https://www.cnblogs.com/nowgood/p/Latexstart.html

http://jzqt.github.io/2015/06/30/Markdown%E4%B8%AD%E5%86%99%E6%95%B0%E5%AD%A6%E5%85%AC%E5%BC%8F/

https://blog.csdn.net/u014630987/article/details/70156489

http://www.javashuo.com/article/p-aaxlftci-nk.html

相關文章
相關標籤/搜索