###### tags: `Latex` {%hackmd aPqG0f7uS3CSdeXvHSYQKQ %} # Latex cheat note ## 看更多 https://en.wikibooks.org/wiki/LaTeX/Mathematics https://www.cmor-faculty.rice.edu/~heinken/latex/symbols.pdf ## $ 是用來顯示算式的 + **顯示在行內: `$...$`, Ex:** `code: $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$` > 輸出為: $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$ + **顯示在外(會較大且置中): `$$..$$`, EX:** `code: $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$` > 輸出為: $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$ # 常用語法 ## 上下標 + 上標: `^` Ex: `code:$x^2$` 輸出: $x^2$ + 下標: `_` Ex:`x_2` 輸出: $x_2$ >Ex: $C^2_3$ code:`C^2_3` ## 向量、射線 + 一個字的向量 : `\vec` 、 `\hat` Ex: `$\vec a$` 輸出: $\vec a$ <span class="EAE239">**注意vec後面要空格**</span> Ex : `$\hat a$` 輸出 : $\hat a$ + bar:`\bar` EX: `$\bar u$` 輸出: $\bar u$ + 多個字的向量 : `\overrightarrow{}` Ex : `$\overrightarrow{xy}$` 輸出 : $\overrightarrow{xy}$ + 射線 : `\overrightarrow`、`$\overleftrightarrow$` Ex : `$\overrightarrow {xy}$` 、 `$\overleftrightarrow {xy}$` 輸出 : $\overrightarrow {xy}$ 、 $\overleftrightarrow {xy}$ ## 字體 + $\mathtt{A}$ : `$\mathtt{A}$` + $\mathbb{A}$ : `$\mathbb{A}$` + $\mathscr{A}$ : `$\mathscr{A}$` + $\mathrm{A}$ : `$\mathrm{A}$` + $\mathfrak{A}$ : `$\mathfrak{A}$` ## 括號、絕對值 + $\langle$ : `$\langle$` + $\rangle$ : `$\rangle$` + $\left(...\right)$ : `$\left(...\right)$` + $\lbrace$ : `$\lbrace$` + $\rbrace$ : `$\rbrace$` > Ex:`$\left(\frac{a}{b}\right)$` > 輸出:$\left(\frac{a}{b}\right)$ + $\lfloor \quad \rfloor$ : `$\lfloor ____ \rfloor$` + $\lceil \quad \rceil$ : `$\lceil ____ \rceil$` + $\vert \quad \vert$ : `$\vert ____ \vert$` + $\Vert \quad \Vert$ : `$\Vert ____ \Vert$` ## Sigma、積分符號、極限 + $\sum$ : `$\sum$` Ex: `$\sum_{i=1}^n{a_i}$` 輸出: $\sum_{i=1}^n{a_i}$ + $\lim$ : `$\lim$` Ex :`$\lim_{x\to 0}$` 輸出 : $\lim_{x\to 0}$ + $\int$ : `$\int$` Ex : `$\int_0^xf(x)dx$` 輸出 : $\int_0^xf(x)dx$ + $\iint$ : `$\iint` Ex : `$\iint_0^xf(x)dx$` 輸出 : $\iint_0^xf(x)dx$ <span class="EAE239"> **(三個同理 -> iiint)** </span> ## 分數、根號 + 分數 : `\frac` Ex : `$\frac{分子}{分母}$` 輸出 : $\frac{分子}{分母}$ Ex : `$\cfrac{分子}{分母}$` 輸出 : $\cfrac{分子}{分母}$ + 根號 : `\sqrt` Ex : `$\sqrt[x]{y}$` 輸出 : $\sqrt[x]{y}$ ## 函數 + \函數名 > Ex : `$\sin x$` ,輸出 : $\sin x$ > Ex : `$ln x$` ,輸出 : $ln x$ > Ex : `$max(A,B,C)$`,輸出 : $max(A,B,C)$ ## 空格 + <span class="EAE239"> **因為Latex會忽略空格,所以要用轉義字符** </span> > `_` 為空白 > Ex : `$a__b$` ,輸出 : $a b$ > Ex : `$a\ b$` ,輸出 : $a\ b$ > Ex : `$a____b$` ,輸出 : $a b$ > Ex : `$a\quad b$` ,輸出 : $a\quad b$ ## 矩陣 + 起始 :`$$\begin{matrix}` 、 結束 : `\end{matrix}` + <div style="color:#2EEFEF;"><strong>每一行末尾要有\\ , 行間元素以$分割</strong></div> + 舉例 : ``` $$\begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{matrix}$$ ``` </a> 輸出: $$\begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{matrix}$$ + ### 矩陣邊框 >pmatrix:小括號邊框 bmatrix:中括號邊框 Bmatrix:大括號邊框 vmatrix:單豎線邊框 Vmatrix:雙豎線邊框 舉例: ``` $$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$ ``` 輸出: $$\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$ ## <div style="color:#F9B066;">方程式</div> + 需要cases環境: 起始、結束處以{cases}聲明 + 起始:`\ begin{cases}` 、 結束:`\ end{cases}` + 以`\\`換行 + 編號: `\tag{n}` 舉例: ``` $$ \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}$$ <br> 舉例:`$f(x)=x\tag{1}$` 輸出:$f(x)=x\tag{1}$ ## <div style="color : #F9B066;">希臘字母</div> | 顯示 | code | 顯示 | code | | ---------- | ------------ | -------- | ---------- | | $\alpha$ | `$\alpha$` | $\beta$ | `$\beta$` | | $\gamma$ | `$\gamma$` | $\delta$ | `$\delta$` | | $\epsilon$ | `$\epsilon$` | $\zeta$ | `$\zeta$` | | $\eta$ | `$\eta$` | $\theta$ | `$\theta$` | | $\iota$ | `$\iota$` | $\kappa$ | `$\kappa$` | | $\lambda$ | `$\lambda$` | $\mu$ | `$\mu$` | | $\nu$ | `$\nu$` | $\xi$ | `$\xi$` | | $\pi$ | `$\pi$` | $\rho$ | `$\rho$` | | $\sigma$ | `$\sigma$` | $\tau$ | `$\tau$` | | $\upsilon$ | `$\upsilon$` | $\phi$ | `$\phi$` | | $\chi$ | `$\chi$` | $\psi$ | `$\psi$` | | $\omega$ | `$\omega$` | | | ## 符號 | 顯示 | code | 顯示 | code | | --------------- | ----------------- | ---------------- | ------------------ | | $\mp$ | `$\mp$` | $\times$ | `$\times$` | | $\ast$ | `$\ast$` | $\star$ | `$\star$` | | $\circ$ | `$\circ$` | $\bullet$ | `$\bullet$` | | $\cdot$ (內積) | `$\cdot$` | $\div$ | `$\div$` | | $\sum$ | `$\sum$` | $\prod$ | `$\prod$` | | $\coprod$ | `$\coprod$` | $\oplus$ | `$\oplus$` | | $\bigoplus$ | `$\bigoplus$` | $\ominus$ | `$\ominus$` | | $\bigotimes$ | `$\bigotimes$` | $\oslash$ | `$\oslash$` | | $\odot$ | `$\odot$` | $\bigodot$ | `$\bigodot$` | | $\diamond$ | `$\diamond$` | $\bigtriangleup$ | `$\bigtriangleup$` | | $\triangleleft$ | `$\triangleleft$` | $\triangleright$ | `$\triangleright$` | | $\bigcirc$ | `$\bigcirc$` | $\not\lt$ | `$\not\lt$` | | $\lt$ | `$\lt$` | $\gt$ | `$\gt$` | | $\le$ | `$\le$` | $\leq$ | `$\leq$` | | $\leqq$ | `$\leqq$` | $\leqslant$ | `$\leqslant$` | | $\ge$ | `$\ge$` | $\geqq$ | `$\geqq$` | | $\geqslant$ | `$\geqslant$` | $\neq$ | `$\neq$` | | $\cup$ | `$\cup$` | $\cap$ | `$\cap$` | | $\setminus$ | `$\setminus$ ` | $\subset$ | `$\subset$` | | $\subseteq$ | `$\subseteq$` | $\subsetneq$ | `$\subsetneq$` | | $\supset$ | `$\supset$ ` | $\in$ | `$\in$` | | $\notin$ | `$\notin$` | $\emptyset$ | `$\emptyset$` | | $\varnothing$ | `$\varnothing$` | $\to$ | `$\to$` | | $\rightarrow$ | `$\rightarrow$` | $\leftarrow$ | `$\leftarrow$` | | $\Rightarrow$ | `$\Rightarrow$` | $\Leftarrow$ | `$\Leftarrow$` | | $\mapsto$ | `$\mapsto$` | $\land$ | `$\land$` | | $\lor$ | `$\lor$` | $\lnot$ | `$\lnot$ ` | | $\forall$ | `$\forall$` | $\exists$ | `$\exists$ ` | | $\top$ | `$\top$ ` | $\bot$ | `$\bot$` | | $\vdash$ | `$\vdash$` | $\vDash$ | `$\vDash$` | | $\approx$ | `$\approx$` | $\sim$ | `$\sim$` | | $\simeq$ | `$\simeq$` | $\cong$ | `$\cong$` | | $\equiv$ | `$\equiv$` | $\prec$ | `$\prec$` | | $\lhd$ | `$\lhd$` | $\therefore$ | `$\therefore$` | | $\infty$ | `$\infty$` | $\aleph_0$ | `$\aleph_0$ ` | | $\nabla$ | `$\nabla$` | $\partial$ | `$\partial$` | | $\Im$ | `$\Im$` | $\Re$ | `$\Re$` | | $\ldots$ | `$\ldots$` | $\cdots$ | `$\cdots$ ` | | $\ddots$ | `$\ddots$ ` | $\vdots$ | `$\vdots$` |