Try   HackMD
tags: Latex

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}$

輸出為:

i=0ni2=(n2+n)(2n+1)6

  • 顯示在外(會較大且置中): $$..$$, EX:
    code: $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$

輸出為:

i=0ni2=(n2+n)(2n+1)6

常用語法

上下標

  • 上標: ^
    Ex: code:$x^2$
    輸出:

    x2

  • 下標: _
    Ex:x_2
    輸出:

    x2

Ex:

C32
code:C^2_3

向量、射線

  • 一個字的向量 : \vec\hat
    Ex: $\vec a$
    輸出:

    a
    注意vec後面要空格
    Ex : $\hat a$
    輸出 :
    a^

  • bar:\bar
    EX: $\bar u$
    輸出:

    u¯

  • 多個字的向量 : \overrightarrow{}
    Ex : $\overrightarrow{xy}$
    輸出 :

    xy

  • 射線 : \overrightarrow$\overleftrightarrow$
    Ex : $\overrightarrow {xy}$$\overleftrightarrow {xy}$
    輸出 :

    xy
    xy

字體

  • A
    : $\mathtt{A}$
  • A
    : $\mathbb{A}$
  • A
    : $\mathscr{A}$
  • A
    : $\mathrm{A}$
  • A
    : $\mathfrak{A}$

括號、絕對值

  • : $\langle$
  • : $\rangle$
  • (...)
    : $\left(...\right)$
  • {
    : $\lbrace$
  • }
    : $\rbrace$

Ex:$\left(\frac{a}{b}\right)$
輸出:

(ab)

  • : $\lfloor ____ \rfloor$
  • : $\lceil ____ \rceil$
  • ||
    : $\vert ____ \vert$
  • : $\Vert ____ \Vert$

Sigma、積分符號、極限

  • : $\sum$
    Ex: $\sum_{i=1}^n{a_i}$
    輸出:
    i=1nai

  • lim : $\lim$
    Ex :$\lim_{x\to 0}$
    輸出 :
    limx0

  • : $\int$
    Ex : $\int_0^xf(x)dx$
    輸出 :
    0xf(x)dx

  • : $\iint
    Ex : $\iint_0^xf(x)dx$
    輸出 :
    0xf(x)dx

    (三個同理 -> iiint)

分數、根號

  • 分數 : \frac
    Ex : $\frac{分子}{分母}$
    輸出 :

    Ex : $\cfrac{分子}{分母}$
    輸出 :
  • 根號 : \sqrt
    Ex : $\sqrt[x]{y}$
    輸出 :
    yx

函數

  • \函數名

Ex : $\sin x$ ,輸出 :

sinx
Ex : $ln x$ ,輸出 :
lnx

Ex : $max(A,B,C)$,輸出 :
max(A,B,C)

空格

  • 因為Latex會忽略空格,所以要用轉義字符

_ 為空白
Ex : $a__b$ ,輸出 :

ab
Ex : $a\ b$ ,輸出 :
a b

Ex : $a____b$ ,輸出 :
ab

Ex : $a\quad b$ ,輸出 :
ab

矩陣

  • 起始 :$$\begin{matrix} 、 結束 : \end{matrix}
  • 每一行末尾要有\\ , 行間元素以$分割
  • 舉例 :
$$\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}$$

輸出:

[100010001]

方程式

  • 需要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}$$

輸出:

{a1x+b1y+c1z=d1a2x+b2y+c2z=d2a3x+b3y+c3z=d3


舉例:$f(x)=x\tag{1}$

輸出:

f(x)=x

希臘字母

顯示 code 顯示 code
α
$\alpha$
β
$\beta$
γ
$\gamma$
δ
$\delta$
ϵ
$\epsilon$
ζ
$\zeta$
η
$\eta$
θ
$\theta$
ι
$\iota$
κ
$\kappa$
λ
$\lambda$
μ
$\mu$
ν
$\nu$
ξ
$\xi$
π
$\pi$
ρ
$\rho$
σ
$\sigma$
τ
$\tau$
υ
$\upsilon$
ϕ
$\phi$
χ
$\chi$
ψ
$\psi$
ω
$\omega$

符號

顯示 code 顯示 code
$\mp$
×
$\times$
$\ast$
$\star$
$\circ$
$\bullet$
(內積)
$\cdot$
÷
$\div$
$\sum$
$\prod$
$\coprod$
$\oplus$
$\bigoplus$
$\ominus$
$\bigotimes$
$\oslash$
$\odot$
$\bigodot$
$\diamond$
$\bigtriangleup$
$\triangleleft$
$\triangleright$
$\bigcirc$
$\not\lt$
<
$\lt$
>
$\gt$
$\le$
$\leq$
$\leqq$
$\leqslant$
$\ge$
$\geqq$
$\geqslant$
$\neq$
$\cup$
$\cap$
$\setminus$
$\subset$
$\subseteq$
$\subsetneq$
$\supset$
$\in$
$\notin$
$\emptyset$
$\varnothing$
$\to$
$\rightarrow$
$\leftarrow$
$\Rightarrow$
$\Leftarrow$
$\mapsto$
$\land$
$\lor$
¬
$\lnot$
$\forall$
$\exists$
$\top$
$\bot$
$\vdash$
$\vDash$
$\approx$
$\sim$
$\simeq$
$\cong$
$\equiv$
$\prec$
$\lhd$
$\therefore$
$\infty$
0
$\aleph_0$
$\nabla$
$\partial$
$\Im$
$\Re$
$\ldots$
$\cdots$
$\ddots$
$\vdots$