Cmd Markdown 公式指導手冊
標簽: Tutorial
2018-03-20 補檔:
收到很多小伙伴對本文的源文檔轉載需求,故傳了一份 md 文件,請按需 下載 。
本文固定鏈接: https://www.zybuluo.com/codeep/note/163962
點擊跳轉至 Cmd Markdown 簡明語法手冊 ,立刻開始 Cmd Markdown 編輯閱讀器的記錄和寫作之旅!
本文為 MathJax 在 Cmd Markdown 環境下的語法指引。
Cmd Markdown 編輯閱讀器支持 \(\LaTeX\) 編輯顯示支持,例如:\(\sum_{i=1}^n a_i=0\),訪問 MathJax 以參考更多使用方法。
右鍵點擊每一個公式,選擇 [Show Math As] → [TeX Commands] 以查看該公式的命令詳情。
一、公式使用參考
1.如何插入公式
\(\LaTeX\) 的數學公式有兩種:行中公式和獨立公式。行中公式放在文中與其它文字混編,獨立公式單獨成行。
- 行中公式可以用如下方法表示:
-
$ 數學公式 $
- 獨立公式可以用如下方法表示:
-
$$ 數學公式 $$
- 自動編號的公式可以用如下方法表示:
-
若需要手動編號,參見 大括號和行標的使用 。
-
\begin{equation}
數學公式
\label{eq:當前公式名}
\end{equation}
自動編號后的公式可在全文任意處使用 \eqref{eq:公式名}
語句引用。
- 例子:
$ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha} \text {,行內公式示例} $
-
顯示:$ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha} \text {,行內公式示例} $
-
例子:
$$ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha} \text {,獨立公式示例} $$
-
顯示:$$ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha} \text {,獨立公式示例} $$
-
例子:
在公式 \eqref{eq:sample} 中,我們看到了這個被自動編號的公式。
\begin{equation}
E=mc^2 \text{,自動編號公式示例}
\label{eq:Sample}
\end{equation}
- 顯示:
\begin{equation}
E=mc^2 \text{,自動編號公式示例}
\label{eq:sample}
\end{equation}
2.如何輸入上下標
^
表示上標, _
表示下標。如果上下標的內容多於一個字符,需要用 {}
將這些內容括成一個整體。上下標可以嵌套,也可以同時使用。
- 例子:
$$ x^{y^z}=(1+{\rm e}^x)^{-2xy^w} $$
- 顯示:$$ x^{y^z}=(1+{\rm e}^x)^{-2xy^w} $$
另外,如果要在左右兩邊都有上下標,可以用 \sideset
命令。
- 例子:
$$ \sideset{^1_2}{^3_4}\bigotimes $$
- 顯示:$$\sideset{^1_2}{^3_4}\bigotimes$$
3.如何輸入括號和分隔符
()
、[]
和 |
表示符號本身,使用 \{\}
來表示 {}
。當要顯示大號的括號或分隔符時,要用 \left
和 \right
命令。
一些特殊的括號:
輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|
\langle | \(\langle\) | \rangle | \(\rangle\) |
\lceil | \(\lceil\) | \rceil | \(\rceil\) |
\lfloor | \(\lfloor\) | \rfloor | \(\rfloor\) |
\lbrace | \(\lbrace\) | \rbrace | \(\rbrace\) |
- 例子:
$$ f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right) $$
- 顯示:$$ f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right) $$
有時候要用 \left.
或 \right.
進行匹配而不顯示本身。
- 例子:
$$ \left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0} $$
- 顯示:$$ \left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0} $$
4.如何輸入分數
通常使用 \frac {分子} {分母}
命令產生一個分數,分數可嵌套。
便捷情況可直接輸入 \frac ab
來快速生成一個 \(\frac ab\) 。
如果分式很復雜,亦可使用 分子 \over 分母
命令,此時分數僅有一層。
- 例子:
$$\frac{a-1}{b-1} \quad and \quad {a+1\over b+1}$$
- 顯示:$$\frac{a-1}{b-1} \quad and \quad {a+1\over b+1}$$
5.如何輸入開方
使用 \sqrt [根指數,省略時為2] {被開方數}
命令輸入開方。
- 例子:
$$\sqrt{2} \quad and \quad \sqrt[n]{3}$$
- 顯示:$$\sqrt{2} \quad and \quad \sqrt[n]{3}$$
6.如何輸入省略號
數學公式中常見的省略號有兩種,\ldots
表示與文本底線對齊的省略號,\cdots
表示與文本中線對齊的省略號。
- 例子:
$$f(x_1,x_2,\underbrace{\ldots}_{\rm ldots} ,x_n) = x_1^2 + x_2^2 + \underbrace{\cdots}_{\rm cdots} + x_n^2$$
- 顯示:$$f(x_1,x_2,\underbrace{\ldots}{\rm ldots} ,x_n) = x_1^2 + x_2^2 + \underbrace{\cdots}{\rm cdots} + x_n^2$$
7.如何輸入矢量
使用 \vec{矢量}
來自動產生一個矢量。也可以使用 \overrightarrow
等命令自定義字母上方的符號。
- 例子:
$$\vec{a} \cdot \vec{b}=0$$
-
顯示:$$\vec{a} \cdot \vec{b}=0$$
-
例子:
$$\overleftarrow{xy} \quad and \quad \overleftrightarrow{xy} \quad and \quad \overrightarrow{xy}$$
- 顯示:$$\overleftarrow{xy} \quad and \quad \overleftrightarrow{xy} \quad and \quad \overrightarrow{xy}$$
8.如何輸入積分
使用 \int_積分下限^積分上限 {被積表達式}
來輸入一個積分。
例子:
$$\int_0^1 {x^2} \,{\rm d}x$$
顯示:$$\int_0^1 {x^2} ,{\rm d}x$$
本例中 \,
和 {\rm d}
部分可省略,但建議加入,能使式子更美觀。
9.如何輸入極限運算
使用 \lim_{變量 \to 表達式} 表達式
來輸入一個極限。如有需求,可以更改 \to
符號至任意符號。
例子:
$$ \lim_{n \to +\infty} \frac{1}{n(n+1)} \quad and \quad \lim_{x\leftarrow{示例}} \frac{1}{n(n+1)} $$
顯示:$$\lim_{n \to +\infty} \frac{1}{n(n+1)} \quad and \quad \lim_{x\leftarrow{示例}} \frac{1}{n(n+1)}$$
10.如何輸入累加、累乘運算
使用 \sum_{下標表達式}^{上標表達式} {累加表達式}
來輸入一個累加。
與之類似,使用 \prod
\bigcup
\bigcap
來分別輸入累乘、並集和交集。
此類符號在行內顯示時上下標表達式將會移至右上角和右下角。
- 例子:
$$\sum_{i=1}^n \frac{1}{i^2} \quad and \quad \prod_{i=1}^n \frac{1}{i^2} \quad and \quad \bigcup_{i=1}^{2} R$$
- 顯示:$$\sum_{i=1}^n \frac{1}{i^2} \quad and \quad \prod_{i=1}^n \frac{1}{i^2} \quad and \quad \bigcup_{i=1}^{2} R$$
11.如何輸入希臘字母
輸入 \小寫希臘字母英文全稱
和 \首字母大寫希臘字母英文全稱
來分別輸入小寫和大寫希臘字母。
對於大寫希臘字母與現有字母相同的,直接輸入大寫字母即可。
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|---|---|
\alpha | \(\alpha\) | A | \(A\) | \beta | \(\beta\) | B | \(B\) |
\gamma | \(\gamma\) | \Gamma | \(\Gamma\) | \delta | \(\delta\) | \Delta | \(\Delta\) |
\epsilon | \(\epsilon\) | E | \(E\) | \zeta | \(\zeta\) | Z | \(Z\) |
\eta | \(\eta\) | H | \(H\) | \theta | \(\theta\) | \Theta | \(\Theta\) |
\iota | \(\iota\) | I | \(I\) | \kappa | \(\kappa\) | K | \(K\) |
\lambda | \(\lambda\) | \Lambda | \(\Lambda\) | \mu | \(\mu\) | M | \(M\) |
\nu | \(\nu\) | N | \(N\) | \xi | \(\xi\) | \Xi | \(\Xi\) |
o | \(o\) | O | \(O\) | \pi | \(\pi\) | \Pi | \(\Pi\) |
\rho | \(\rho\) | P | \(P\) | \sigma | \(\sigma\) | \Sigma | \(\Sigma\) |
\tau | \(\tau\) | T | \(T\) | \upsilon | \(\upsilon\) | \Upsilon | \(\Upsilon\) |
\phi | \(\phi\) | \Phi | \(\Phi\) | \chi | \(\chi\) | X | \(X\) |
\psi | \(\psi\) | \Psi | \(\Psi\) | \omega | \(\omega\) | \Omega | \(\Omega\) |
部分字母有變量專用形式,以 \var-
開頭。
小寫形式 | 大寫形式 | 變量形式 | 顯示 |
---|---|---|---|
\epsilon | E | \varepsilon | \(\epsilon \mid E \mid \varepsilon\) |
\theta | \Theta | \vartheta | \(\theta \mid \Theta \mid \vartheta\) |
\rho | P | \varrho | \(\rho \mid P \mid \varrho\) |
\sigma | \Sigma | \varsigma | \(\sigma \mid \Sigma \mid \varsigma\) |
\phi | \Phi | \varphi | \(\phi \mid \Phi \mid \varphi\) |
12.如何輸入其它特殊字符
若需要顯示更大或更小的字符,在符號前插入
\large
或\small
命令。
若找不到需要的符號,使用 \(\rm{Detexify^2}\) 來畫出想要的符號。
(1).關系運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|---|---|
\pm | \(\pm\) | \times | \(\times\) | \div | \(\div\) | \mid | \(\mid\) |
\nmid | \(\nmid\) | \cdot | \(\cdot\) | \circ | \(\circ\) | \ast | \(\ast\) |
\bigodot | \(\bigodot\) | \bigotimes | \(\bigotimes\) | \bigoplus | \(\bigoplus\) | \leq | \(\leq\) |
\geq | \(\geq\) | \neq | \(\neq\) | \approx | \(\approx\) | \equiv | \(\equiv\) |
\sum | \(\sum\) | \prod | \(\prod\) | \coprod | \(\coprod\) | \backslash | \(\backslash\) |
(2).集合運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|
\emptyset | \(\emptyset\) | \in | \(\in\) | \notin | \(\notin\) |
\subset | \(\subset\) | \supset | \(\supset\) | \subseteq | \(\subseteq\) |
\supseteq | \(\supseteq\) | \bigcap | \(\bigcap\) | \bigcup | \(\bigcup\) |
\bigvee | \(\bigvee\) | \bigwedge | \(\bigwedge\) | \biguplus | \(\biguplus\) |
(3).對數運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|
\log | \(\log\) | \lg | \(\lg\) | \ln | \(\ln\) |
(4).三角運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|
30^\circ | \(30^\circ\) | \bot | \(\bot\) | \angle A | \(\angle A\) |
\sin | \(\sin\) | \cos | \(\cos\) | \tan | \(\tan\) |
\csc | \(\csc\) | \sec | \(\sec\) | \cot | \(\cot\) |
(5).微積分運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|
\int | \(\int\) | \iint | \(\iint\) | \iiint | \(\iiint\) |
\iiiint | \(\iiiint\) | \oint | \(\oint\) | \prime | \(\prime\) |
\lim | \(\lim\) | \infty | \(\infty\) | \nabla | \(\nabla\) |
(6).邏輯運算符
輸入 | 顯示 | 輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|---|---|
\because | \(\because\) | \therefore | \(\therefore\) | ||
\forall | \(\forall\) | \exists | \(\exists\) | \not\subset | \(\not\subset\) |
\not< | \(\not<\) | \not> | \(\not>\) | \not= | \(\not=\) |
(7).戴帽符號
輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|
\hat{xy} | \(\hat{xy}\) | \widehat{xyz} | \(\widehat{xyz}\) |
\tilde{xy} | \(\tilde{xy}\) | \widetilde{xyz} | \(\widetilde{xyz}\) |
\check{x} | \(\check{x}\) | \breve{y} | \(\breve{y}\) |
\grave{x} | \(\grave{x}\) | \acute{y} | \(\acute{y}\) |
(8).連線符號
輸入 | 顯示 |
---|---|
\fbox{a+b+c+d} | \(\fbox{a+b+c+d}\) |
\overleftarrow{a+b+c+d} | \(\overleftarrow{a+b+c+d}\) |
\overrightarrow{a+b+c+d} | \(\overrightarrow{a+b+c+d}\) |
\overleftrightarrow{a+b+c+d} | \(\overleftrightarrow{a+b+c+d}\) |
\underleftarrow{a+b+c+d} | \(\underleftarrow{a+b+c+d}\) |
\underrightarrow{a+b+c+d} | \(\underrightarrow{a+b+c+d}\) |
\underleftrightarrow{a+b+c+d} | \(\underleftrightarrow{a+b+c+d}\) |
\overline{a+b+c+d} | \(\overline{a+b+c+d}\) |
\underline{a+b+c+d} | \(\underline{a+b+c+d}\) |
\overbrace{a+b+c+d}^{Sample} | \(\overbrace{a+b+c+d}^{Sample}\) |
\underbrace{a+b+c+d}_{Sample} | \(\underbrace{a+b+c+d}_{Sample}\) |
\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0} | \(\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}\) |
\underbrace{a\cdot a\cdots a}_{b\text{ times}} | \(\underbrace{a\cdot a\cdots a}_{b\text{ times}}\) |
(9).箭頭符號
-
推薦使用符號:
|輸入|顯示|輸入|顯示|輸入|顯示|
|:--😐:--😐:--😐:--😐:--😐:--😐
|\to|\(\to\)|\mapsto|\(\mapsto\)|
|\implies|\(\implies\)|\iff|\(\iff\)|\impliedby|\(\impliedby\)| -
其它可用符號:
|輸入|顯示|輸入|顯示|
|:--😐:--😐:--😐:--😐
|\uparrow|\(\uparrow\)|\Uparrow|\(\Uparrow\)|
|\downarrow|\(\downarrow\)|\Downarrow|\(\Downarrow\)|
|\leftarrow|\(\leftarrow\)|\Leftarrow|\(\Leftarrow\)|
|\rightarrow|\(\rightarrow\)|\Rightarrow|\(\Rightarrow\)|
|\leftrightarrow|\(\leftrightarrow\)|\Leftrightarrow|\(\Leftrightarrow\)|
|\longleftarrow|\(\longleftarrow\)|\Longleftarrow|\(\Longleftarrow\)|
|\longrightarrow|\(\longrightarrow\)|\Longrightarrow|\(\Longrightarrow\)|
|\longleftrightarrow|\(\longleftrightarrow\)|\Longleftrightarrow|\(\Longleftrightarrow\)|
13.如何進行字體轉換
若要對公式的某一部分字符進行字體轉換,可以用 {\字體 {需轉換的部分字符}}
命令,其中 \字體
部分可以參照下表選擇合適的字體。一般情況下,公式默認為意大利體 \(italic\) 。
示例中 全部大寫 的字體僅大寫可用。
輸入 | 說明 | 顯示 | 輸入 | 說明 | 顯示 |
---|---|---|---|---|---|
\rm | 羅馬體 | \(\rm{Sample}\) | \cal | 花體 | \(\cal{SAMPLE}\) |
\it | 意大利體 | \(\it{Sample}\) | \Bbb | 黑板粗體 | \(\Bbb{SAMPLE}\) |
\bf | 粗體 | \(\bf{Sample}\) | \mit | 數學斜體 | \(\mit{SAMPLE}\) |
\sf | 等線體 | \(\sf{Sample}\) | \scr | 手寫體 | \(\scr{SAMPLE}\) |
\tt | 打字機體 | \(\tt{Sample}\) | |||
\frak | 舊德式字體 | \(\frak{Sample}\) |
轉換字體十分常用,例如在積分中:
- 例子:
\begin{array}{cc}
\mathrm{Bad} & \mathrm{Better} \\
\hline \\
\int_0^1 x^2 dx & \int_0^1 x^2 \,{\rm d}x
\end{array}
- 顯示:
\begin{array}{cc}
\mathrm{Bad} & \mathrm{Better} \
\hline \
\int_0^1 x^2 dx & \int_0^1 x^2 ,{\rm d}x
\end{array}
注意比較兩個式子間 \(dx\) 與 \({\rm d} x\) 的不同。
使用 \operatorname
命令也可以達到相同的效果,詳見 定義新的符號 \operatorname 。
14.大括號和行標的使用
使用 \left
和 \right
來創建自動匹配高度的 (圓括號),[方括號] 和 {花括號} 。
在每個公式末尾前使用 \tag{行標}
來實現行標。
- 例子:
$$
f\left(
\left[
\frac{
1+\left\{x,y\right\}
}{
\left(
\frac{x}{y}+\frac{y}{x}
\right)
\left(u+1\right)
}+a
\right]^{3/2}
\right)
\tag{行標}
$$
- 顯示:
如果你需要在不同的行顯示對應括號,可以在每一行對應處使用 \left.
或 \right.
來放一個"影子"括號:
- 例子:
$$
\begin{aligned}
a=&\left(1+2+3+ \cdots \right. \\
& \cdots+ \left. \infty-2+\infty-1+\infty\right)
\end{aligned}
$$
- 顯示:
如果你需要將行內顯示的分隔符也變大,可以使用 \middle
命令:
- 例子:
$$
\left\langle
q
\middle\|
\frac{\frac{x}{y}}{\frac{u}{v}}
\middle|
p
\right\rangle
$$
- 顯示:
15.其它命令
(1).定義新的符號 \operatorname
查詢 關於此命令的定義 和 關於此命令的討論 來進一步了解此命令。
- 例子:
$$ \operatorname{Symbol} A $$
- 顯示: $$\operatorname{Symbol} A$$
(2).添加注釋文字 \text
在 \text {文字}
中仍可以使用 $公式$
插入其它公式。
- 例子:
$$ f(n)= \begin{cases} n/2, & \text {if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases} $$
- 顯示:
(3).在字符間加入空格
有四種寬度的空格可以使用: \,
、\;
、\quad
和 \qquad
。
- 例子:
$$ a \, b \mid a \; b \mid a \quad b \mid a \qquad b $$
- 顯示:$$ a , b \mid a ; b \mid a \quad b \mid a \qquad b $$
當然,使用 \text {n個空格}
也可以達到同樣效果。
(4).更改文字顏色
使用 \color{顏色}{文字}
來更改特定的文字顏色。
更改文字顏色 需要瀏覽器支持 ,如果瀏覽器不知道你所需的顏色,那么文字將被渲染為黑色。
對於較舊的瀏覽器(HTML4與CSS2),以下顏色是被支持的:
輸入 | 顯示 | 輸入 | 顯示 |
---|---|---|---|
black | \(\color{black}{text}\) | grey | \(\color{grey}{text}\) |
silver | \(\color{silver}{text}\) | white | \(\color{white}{text}\) |
maroon | \(\color{maroon}{text}\) | red | \(\color{red}{text}\) |
yellow | \(\color{yellow}{text}\) | lime | \(\color{lime}{text}\) |
olive | \(\color{olive}{text}\) | green | \(\color{green}{text}\) |
teal | \(\color{teal}{text}\) | auqa | \(\color{auqa}{text}\) |
blue | \(\color{blue}{text}\) | navy | \(\color{navy}{text}\) |
purple | \(\color{purple}{text}\) | fuchsia | \(\color{fuchsia}{text}\) |
對於較新的瀏覽器(HTML5與CSS3),額外的124種顏色將被支持:
輸入 \color {#rgb} {text}
來自定義更多的顏色,其中 #rgb
的 r
g
b
可輸入 0-9
和 a-f
來表示紅色、綠色和藍色的純度(飽和度)。
- 例子:
\begin{array}{|rrrrrrrr|}\hline
\verb+#000+ & \color{#000}{text} & & &
\verb+#00F+ & \color{#00F}{text} & & \\
& & \verb+#0F0+ & \color{#0F0}{text} &
& & \verb+#0FF+ & \color{#0FF}{text}\\
\verb+#F00+ & \color{#F00}{text} & & &
\verb+#F0F+ & \color{#F0F}{text} & & \\
& & \verb+#FF0+ & \color{#FF0}{text} &
& & \verb+#FFF+ & \color{#FFF}{text}\\
\hline
\end{array}
-
顯示:
\begin{array}{|rrrrrrrr|}\hline
\verb+#000+ & \color{#000}{text} & & &
\verb+#00F+ & \color{#00F}{text} & & \
& & \verb+#0F0+ & \color{#0F0}{text} &
& & \verb+#0FF+ & \color{#0FF}{text}\
\verb+#F00+ & \color{#F00}{text} & & &
\verb+#F0F+ & \color{#F0F}{text} & & \
& & \verb+#FF0+ & \color{#FF0}{text} &
& & \verb+#FFF+ & \color{#FFF}{text}\
\hline
\end{array} -
例子:
\begin{array}{|rrrrrrrr|}
\hline
\verb+#000+ & \color{#000}{text} & \verb+#005+ & \color{#005}{text} & \verb+#00A+ & \color{#00A}{text} & \verb+#00F+ & \color{#00F}{text} \\
\verb+#500+ & \color{#500}{text} & \verb+#505+ & \color{#505}{text} & \verb+#50A+ & \color{#50A}{text} & \verb+#50F+ & \color{#50F}{text} \\
\verb+#A00+ & \color{#A00}{text} & \verb+#A05+ & \color{#A05}{text} & \verb+#A0A+ & \color{#A0A}{text} & \verb+#A0F+ & \color{#A0F}{text} \\
\verb+#F00+ & \color{#F00}{text} & \verb+#F05+ & \color{#F05}{text} & \verb+#F0A+ & \color{#F0A}{text} & \verb+#F0F+ & \color{#F0F}{text} \\
\hline
\verb+#080+ & \color{#080}{text} & \verb+#085+ & \color{#085}{text} & \verb+#08A+ & \color{#08A}{text} & \verb+#08F+ & \color{#08F}{text} \\
\verb+#580+ & \color{#580}{text} & \verb+#585+ & \color{#585}{text} & \verb+#58A+ & \color{#58A}{text} & \verb+#58F+ & \color{#58F}{text} \\
\verb+#A80+ & \color{#A80}{text} & \verb+#A85+ & \color{#A85}{text} & \verb+#A8A+ & \color{#A8A}{text} & \verb+#A8F+ & \color{#A8F}{text} \\
\verb+#F80+ & \color{#F80}{text} & \verb+#F85+ & \color{#F85}{text} & \verb+#F8A+ & \color{#F8A}{text} & \verb+#F8F+ & \color{#F8F}{text} \\
\hline
\verb+#0F0+ & \color{#0F0}{text} & \verb+#0F5+ & \color{#0F5}{text} & \verb+#0FA+ & \color{#0FA}{text} & \verb+#0FF+ & \color{#0FF}{text} \\
\verb+#5F0+ & \color{#5F0}{text} & \verb+#5F5+ & \color{#5F5}{text} & \verb+#5FA+ & \color{#5FA}{text} & \verb+#5FF+ & \color{#5FF}{text} \\
\verb+#AF0+ & \color{#AF0}{text} & \verb+#AF5+ & \color{#AF5}{text} & \verb+#AFA+ & \color{#AFA}{text} & \verb+#AFF+ & \color{#AFF}{text} \\
\verb+#FF0+ & \color{#FF0}{text} & \verb+#FF5+ & \color{#FF5}{text} & \verb+#FFA+ & \color{#FFA}{text} & \verb+#FFF+ & \color{#FFF}{text} \\
\hline
\end{array}
- 顯示:
\begin{array}{|rrrrrrrr|}
\hline
\verb+#000+ & \color{#000}{text} & \verb+#005+ & \color{#005}{text} & \verb+#00A+ & \color{#00A}{text} & \verb+#00F+ & \color{#00F}{text} \
\verb+#500+ & \color{#500}{text} & \verb+#505+ & \color{#505}{text} & \verb+#50A+ & \color{#50A}{text} & \verb+#50F+ & \color{#50F}{text} \
\verb+#A00+ & \color{#A00}{text} & \verb+#A05+ & \color{#A05}{text} & \verb+#A0A+ & \color{#A0A}{text} & \verb+#A0F+ & \color{#A0F}{text} \
\verb+#F00+ & \color{#F00}{text} & \verb+#F05+ & \color{#F05}{text} & \verb+#F0A+ & \color{#F0A}{text} & \verb+#F0F+ & \color{#F0F}{text} \
\hline
\verb+#080+ & \color{#080}{text} & \verb+#085+ & \color{#085}{text} & \verb+#08A+ & \color{#08A}{text} & \verb+#08F+ & \color{#08F}{text} \
\verb+#580+ & \color{#580}{text} & \verb+#585+ & \color{#585}{text} & \verb+#58A+ & \color{#58A}{text} & \verb+#58F+ & \color{#58F}{text} \
\verb+#A80+ & \color{#A80}{text} & \verb+#A85+ & \color{#A85}{text} & \verb+#A8A+ & \color{#A8A}{text} & \verb+#A8F+ & \color{#A8F}{text} \
\verb+#F80+ & \color{#F80}{text} & \verb+#F85+ & \color{#F85}{text} & \verb+#F8A+ & \color{#F8A}{text} & \verb+#F8F+ & \color{#F8F}{text} \
\hline
\verb+#0F0+ & \color{#0F0}{text} & \verb+#0F5+ & \color{#0F5}{text} & \verb+#0FA+ & \color{#0FA}{text} & \verb+#0FF+ & \color{#0FF}{text} \
\verb+#5F0+ & \color{#5F0}{text} & \verb+#5F5+ & \color{#5F5}{text} & \verb+#5FA+ & \color{#5FA}{text} & \verb+#5FF+ & \color{#5FF}{text} \
\verb+#AF0+ & \color{#AF0}{text} & \verb+#AF5+ & \color{#AF5}{text} & \verb+#AFA+ & \color{#AFA}{text} & \verb+#AFF+ & \color{#AFF}{text} \
\verb+#FF0+ & \color{#FF0}{text} & \verb+#FF5+ & \color{#FF5}{text} & \verb+#FFA+ & \color{#FFA}{text} & \verb+#FFF+ & \color{#FFF}{text} \
\hline
\end{array}
(5).添加刪除線
使用刪除線功能必須聲明 $$
符號。
在公式內使用 \require{cancel}
來允許 片段刪除線 的顯示。
聲明片段刪除線后,使用 \cancel{字符}
、\bcancel{字符}
、\xcancel{字符}
和 \cancelto{字符}
來實現各種片段刪除線效果。
- 例子:
$$
\require{cancel}\begin{array}{rl}
\verb|y+\cancel{x}| & y+\cancel{x}\\
\verb|\cancel{y+x}| & \cancel{y+x}\\
\verb|y+\bcancel{x}| & y+\bcancel{x}\\
\verb|y+\xcancel{x}| & y+\xcancel{x}\\
\verb|y+\cancelto{0}{x}| & y+\cancelto{0}{x}\\
\verb+\frac{1\cancel9}{\cancel95} = \frac15+& \frac{1\cancel9}{\cancel95} = \frac15 \\
\end{array}
$$
- 顯示:
使用 \require{enclose}
來允許 整段刪除線 的顯示。
聲明整段刪除線后,使用 \enclose{刪除線效果}{字符}
來實現各種整段刪除線效果。
其中,刪除線效果有 horizontalstrike
、verticalstrike
、updiagonalstrike
和 downdiagonalstrike
,可疊加使用。
- 例子:
$$
\require{enclose}\begin{array}{rl}
\verb|\enclose{horizontalstrike}{x+y}| & \enclose{horizontalstrike}{x+y}\\
\verb|\enclose{verticalstrike}{\frac xy}| & \enclose{verticalstrike}{\frac xy}\\
\verb|\enclose{updiagonalstrike}{x+y}| & \enclose{updiagonalstrike}{x+y}\\
\verb|\enclose{downdiagonalstrike}{x+y}| & \enclose{downdiagonalstrike}{x+y}\\
\verb|\enclose{horizontalstrike,updiagonalstrike}{x+y}| & \enclose{horizontalstrike,updiagonalstrike}{x+y}\\
\end{array}
$$
- 顯示:
此外, \enclose
命令還可以產生包圍的邊框和圓等,參見 MathML Menclose Documentation 以查看更多效果。
二、矩陣使用參考
1.如何輸入無框矩陣
在開頭使用 begin{matrix}
,在結尾使用 end{matrix}
,在中間插入矩陣元素,每個元素之間插入 &
,並在每行結尾處使用 \\
。
使用矩陣時必須聲明 $
或 $$
符號。
- 例子:
$$
\begin{matrix}
1 & x & x^2 \\
1 & y & y^2 \\
1 & z & z^2 \\
\end{matrix}
$$
- 顯示:
2.如何輸入邊框矩陣
在開頭將 matrix
替換為 pmatrix
bmatrix
Bmatrix
vmatrix
Vmatrix
。
- 例子:
$ \begin{matrix} 1 & 2 \\ 3 & 4 \\ \end{matrix} $
$ \begin{pmatrix} 1 & 2 \\ 3 & 4 \\ \end{pmatrix} $
$ \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} $
$ \begin{Bmatrix} 1 & 2 \\ 3 & 4 \\ \end{Bmatrix} $
$ \begin{vmatrix} 1 & 2 \\ 3 & 4 \\ \end{vmatrix} $
$ \begin{Vmatrix} 1 & 2 \\ 3 & 4 \\ \end{Vmatrix} $
- 顯示:
|matrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix|
|:--😐:--😐:--😐:--😐:--😐:--😐
|$ \begin{matrix} 1 & 2 \ 3 & 4 \ \end{matrix} \(|\) \begin{pmatrix} 1 & 2 \ 3 & 4 \ \end{pmatrix} \(|\) \begin{bmatrix} 1 & 2 \ 3 & 4 \ \end{bmatrix} \(|\) \begin{Bmatrix} 1 & 2 \ 3 & 4 \ \end{Bmatrix} \(|\) \begin{vmatrix} 1 & 2 \ 3 & 4 \ \end{vmatrix} \(|\) \begin{Vmatrix} 1 & 2 \ 3 & 4 \ \end{Vmatrix} $|
3.如何輸入帶省略符號的矩陣
使用 \cdots
\(\cdots\) , \ddots
\(\ddots\) , \vdots
\(\vdots\) 來輸入省略符號。
- 例子:
$$
\begin{pmatrix}
1 & a_1 & a_1^2 & \cdots & a_1^n \\
1 & a_2 & a_2^2 & \cdots & a_2^n \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & a_m & a_m^2 & \cdots & a_m^n \\
\end{pmatrix}
$$
- 顯示:
4.如何輸入帶分割符號的矩陣
詳見"數組使用參考"。
- 例子:
$$
\left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right]
$$
- 顯示:
其中 cc|c
代表在一個三列矩陣中的第二和第三列之間插入分割線。
5.如何輸入行中矩陣
若想在一行內顯示矩陣,
使用\bigl(\begin{smallmatrix} ... \end{smallmatrix}\bigr)
。
- 例子:
這是一個行中矩陣的示例 $\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$ 。
- 顯示:這是一個行中矩陣的示例 \(\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)\) 。
三、方程式序列使用參考
1.如何輸入一個方程式序列
人們經常想要一列整齊且居中的方程式序列。使用 \begin{align}…\end{align}
來創造一列方程式,其中在每行結尾處使用 \\
。
使用方程式序列無需聲明公式符號 $
或 $$
。
請注意 {align}
語句是 自動編號 的。
- 例子:
\begin{align}
\sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\
& = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\
& = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\
& = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\
& \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right)
\end{align}
- 顯示:
\begin{align}
\sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \
& = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \
& = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \
& = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \
& \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right)
\end{align}
本例中每行公式的編號續自 如何插入公式 中的自動編號公式 \eqref{eq:sample} 。
2.在一個方程式序列的每一行中注明原因
在 {align}
中靈活組合 \text
和 \tag
語句。\tag
語句編號優先級高於自動編號。
- 例子:
\begin{align}
v + w & = 0 &\text{Given} \tag 1\\
-w & = -w + 0 & \text{additive identity} \tag 2\\
-w + 0 & = -w + (v + w) & \text{equations $(1)$ and $(2)$}
\end{align}
- 顯示:
\begin{align}
v + w & = 0 &\text{Given} \tag 1\
-w & = -w + 0 & \text{additive identity} \tag 2\
-w + 0 & = -w + (v + w) & \text{equations \((1)\) and \((2)\)}
\end{align}
本例中第一、第二行的自動編號被 \tag
語句覆蓋,第三行的編號為自動編號。
四、條件表達式使用參考
1.如何輸入一個條件表達式
使用 begin{cases}
來創造一組條件表達式,在每一行條件中插入 &
來指定需要對齊的內容,並在每一行結尾處使用 \\
,以 end{cases}
結束。
條件表達式無需聲明 $
或 $$
符號。
- 例子:
$$
f(n) =
\begin{cases}
n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
$$
- 顯示:
2.如何輸入一個左側對齊的條件表達式
若想讓文字在 左側對齊顯示 ,則有如下方式:
- 例子:
$$
\left.
\begin{array}{l}
\text{if $n$ is even:}&n/2\\
\text{if $n$ is odd:}&3n+1
\end{array}
\right\}
=f(n)
$$
- 顯示:
3.如何使條件表達式適配行高
在一些情況下,條件表達式中某些行的行高為非標准高度,此時使用 \\[2ex]
語句代替該行末尾的 \\
來讓編輯器適配。
- 例子:
|不適配[2ex]|
|:--😐
|
$$
f(n) =
\begin{cases}
\frac{n}{2}, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
$$
適配[2ex] |
---|
$$
f(n) =
\begin{cases}
\frac{n}{2}, & \text{if $n$ is even} \\[2ex]
3n+1, & \text{if $n$ is odd}
\end{cases}
$$
- 顯示:
|不適配[2ex]|
|:--😐
|$$
f(n) =
\begin{cases}
\frac{n}{2}, & \text{if \(n\) is even} \
3n+1, & \text{if \(n\) is odd}
\end{cases}
f(n) =
\begin{cases}
\frac{n}{2}, & \text{if \(n\) is even} \[2ex]
3n+1, & \text{if \(n\) is odd}
\end{cases}
% outer vertical array of arrays 外層垂直表格
\begin{array}{c}
% inner horizontal array of arrays 內層水平表格
\begin{array}{cc}
% inner array of minimum values 內層"最小值"數組
\begin{array}{c|cccc}
\text{min} & 0 & 1 & 2 & 3\
\hline
0 & 0 & 0 & 0 & 0\
1 & 0 & 1 & 1 & 1\
2 & 0 & 1 & 2 & 2\
3 & 0 & 1 & 2 & 3
\end{array}
&
% inner array of maximum values 內層"最大值"數組
\begin{array}{c|cccc}
\text{max}&0&1&2&3\
\hline
0 & 0 & 1 & 2 & 3\
1 & 1 & 1 & 2 & 3\
2 & 2 & 2 & 2 & 3\
3 & 3 & 3 & 3 & 3
\end{array}
\end{array}
% 內層第一行表格組結束
\
% inner array of delta values 內層第二行Delta值數組
\begin{array}{c|cccc}
\Delta&0&1&2&3\
\hline
0 & 0 & 1 & 2 & 3\
1 & 1 & 0 & 1 & 2\
2 & 2 & 1 & 0 & 1\
3 & 3 & 2 & 1 & 0
\end{array}
% 內層第二行表格組結束
\end{array}
% outer vertical array of arrays 外層垂直表格
\begin{array}{c}
% inner horizontal array of arrays 內層水平表格
\begin{array}{cc}
% inner array of minimum values 內層"最小值"數組
\begin{array}{c|cccc}
\text{min} & 0 & 1 & 2 & 3\
\hline
0 & 0 & 0 & 0 & 0\
1 & 0 & 1 & 1 & 1\
2 & 0 & 1 & 2 & 2\
3 & 0 & 1 & 2 & 3
\end{array}
&
% inner array of maximum values 內層"最大值"數組
\begin{array}{c|cccc}
\text{max}&0&1&2&3\
\hline
0 & 0 & 1 & 2 & 3\
1 & 1 & 1 & 2 & 3\
2 & 2 & 2 & 2 & 3\
3 & 3 & 3 & 3 & 3
\end{array}
\end{array}
% 內層第一行表格組結束
\
% inner array of delta values 內層第二行Delta值數組
\begin{array}{c|cccc}
\Delta&0&1&2&3\
\hline
0 & 0 & 1 & 2 & 3\
1 & 1 & 0 & 1 & 2\
2 & 2 & 1 & 0 & 1\
3 & 3 & 2 & 1 & 0
\end{array}
% 內層第二行表格組結束
\end{array}
\left{
\begin{array}{c}
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{array}
\right.
\left{
\begin{array}{c}
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{array}
\right.
x = a_0 + \cfrac{1^2}{a_1
+ \cfrac{2^2}{a_2
+ \cfrac{3^2}{a_3 + \cfrac{4^4}{a_4 + \cdots}}}}
x = a_0 + \cfrac{1^2}{a_1
+ \cfrac{2^2}{a_2
+ \cfrac{3^2}{a_3 + \cfrac{4^4}{a_4 + \cdots}}}}
x = a_0 + \frac{1^2}{a_1
+ \frac{2^2}{a_2
+ \frac{3^2}{a_3 + \frac{4^4}{a_4 + \cdots}}}}
x = a_0 + \frac{1^2}{a_1
+ \frac{2^2}{a_2
+ \frac{3^2}{a_3 + \frac{4^4}{a_4 + \cdots}}}}
x = a_0 + \frac{1^2}{a_1+}
\frac{2^2}{a_2+}
\frac{3^2}{a_3 +} \frac{4^4}{a_4 +} \cdots
x = a_0 + \frac{1^2}{a_1+}
\frac{2^2}{a_2+}
\frac{3^2}{a_3 +} \frac{4^4}{a_4 +} \cdots
Use \,
, to insert a thin space before differentials; without this \(\TeX\) will mash them together:
在微分符號前加入 \,
來插入一個小的間隔空隙;沒有 \,
符號的話,\(\TeX\) 將會把不同的微分符號堆在一起。
- 例子:
\begin{array}{cc}
\mathrm{Bad} & \mathrm{Better} \\
\hline \\
\iiint_V f(x){\rm d}z {\rm d}y {\rm d}x & \iiint_V f(x)\,{\rm d}z\,{\rm d}y\,{\rm d}x
\end{array}
- 顯示:
\begin{array}{cc}
\mathrm{Bad} & \mathrm{Better} \
\hline \
\iiint_V f(x){\rm d}z {\rm d}y {\rm d}x & \iiint_V f(x),{\rm d}z,{\rm d}y,{\rm d}x
\end{array}
感謝您花費時間閱讀這份指導手冊,本手冊內容可能有疏漏之處,歡迎更改指正。
更多語法請參見:Cmd Markdown 簡明語法手冊,Cmd Markdown 高階語法手冊。
祝您記錄、閱讀、分享愉快!
Drafted & Translated by Eric P.
2015-10-02