日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Markdown中插入公式

發(fā)布時間:2023/12/15 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Markdown中插入公式 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Cmd Markdown 公式指導手冊

標簽: Tutorial

2018-03-20 補檔:收到很多小伙伴對本文的源文檔轉(zhuǎn)載需求,故傳了一份 md 文件,請按需 下載 。本文固定鏈接: https://www.zybuluo.com/codeep/note/163962


點擊跳轉(zhuǎn)至 Cmd Markdown 簡明語法手冊 ,立刻開始 Cmd Markdown 編輯閱讀器的記錄和寫作之旅!


本文為 MathJax 在 Cmd Markdown 環(huán)境下的語法指引。

Cmd Markdown 編輯閱讀器支持 $\LaTeX$ 編輯顯示支持,例如:$\sum_{i=1}^n a_i=0$,訪問 MathJax 以參考更多使用方法。

右鍵點擊每一個公式,選擇 [Show Math As] → [TeX Commands] 以查看該公式的命令詳情。

Cmd Markdown 公式指導手冊一、公式使用參考1.如何插入公式2.如何輸入上下標3.如何輸入括號和分隔符4.如何輸入分數(shù)5.如何輸入開方6.如何輸入省略號7.如何輸入矢量8.如何輸入積分9.如何輸入極限運算10.如何輸入累加、累乘運算11.如何輸入希臘字母12.如何輸入其它特殊字符(1).關系運算符(2).集合運算符(3).對數(shù)運算符(4).三角運算符(5).微積分運算符(6).邏輯運算符(7).戴帽符號(8).連線符號(9).箭頭符號13.如何進行字體轉(zhuǎn)換14.大括號和行標的使用15.其它命令(1).定義新的符號 \operatorname(2).添加注釋文字 \text(3).在字符間加入空格(4).更改文字顏色(5).添加刪除線二、矩陣使用參考1.如何輸入無框矩陣2.如何輸入邊框矩陣3.如何輸入帶省略符號的矩陣4.如何輸入帶分割符號的矩陣5.如何輸入行中矩陣三、方程式序列使用參考1.如何輸入一個方程式序列2.在一個方程式序列的每一行中注明原因四、條件表達式使用參考1.如何輸入一個條件表達式2.如何輸入一個左側(cè)對齊的條件表達式3.如何使條件表達式適配行高五、數(shù)組與表格使用參考1.如何輸入一個數(shù)組或表格2.如何輸入一個嵌套的數(shù)組或表格3.如何輸入一個方程組六、連分數(shù)使用參考1.如何輸入一個連分式七、交換圖表使用參考1.如何輸入一個交換圖表八、一些特殊的注意事項


一、公式使用參考

1.如何插入公式

$\LaTeX$ 的數(shù)學公式有兩種:行中公式和獨立公式。行中公式放在文中與其它文字混編,獨立公式單獨成行。

行中公式可以用如下方法表示:

: $ 數(shù)學公式 $

獨立公式可以用如下方法表示:

: $$ 數(shù)學公式 $$

自動編號的公式可以用如下方法表示:: 若需要手動編號,參見 大括號和行標的使用 。

: \begin{equation}數(shù)學公式\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 {,行內(nèi)公式示例} $
  • 顯示:$ J\alpha(x) = \sum{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha} \text {,行內(nèi)公式示例} $

  • 例子:

$$ 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}
  • 顯示:

$$在公式 \eqref{eq:sample} 中,我們看到了這個被自動編號的公式。$$

\begin{equation}E=mc^2 \text{,自動編號公式示例}\label{eq:sample}\end{equation}

2.如何輸入上下標

^ 表示上標, _ 表示下標。如果上下標的內(nèi)容多于一個字符,需要用 {} 將這些內(nèi)容括成一個整體。上下標可以嵌套,也可以同時使用。

  • 例子:

$$ 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.如何輸入分數(shù)

通常使用 \frac {分子} {分母} 命令產(chǎn)生一個分數(shù),分數(shù)可嵌套。便捷情況可直接輸入 \frac ab 來快速生成一個 $\frac ab$ 。如果分式很復雜,亦可使用 分子 \over 分母 命令,此時分數(shù)僅有一層。

  • 例子:

$$\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 [根指數(shù),省略時為2] {被開方數(shù)} 命令輸入開方。

  • 例子:

$$\sqrt{2} \quad and \quad \sqrt[n]{3}$$
  • 顯示:$$\sqrt{2} \quad and \quad \sqrt[n]{3}$$

6.如何輸入省略號

數(shù)學公式中常見的省略號有兩種,\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{矢量} 來自動產(chǎn)生一個矢量。也可以使用 \overrightarrow 等命令自定義字母上方的符號。

  • 例子:

$$\vec{a} \cdot \vec=0$$
  • 顯示:$$\vec{a} \cdot \vec=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 來分別輸入累乘、并集和交集。此類符號在行內(nèi)顯示時上下標表達式將會移至右上角和右下角。

  • 例子:

$$\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.如何輸入希臘字母

輸入 \小寫希臘字母英文全稱 和 \首字母大寫希臘字母英文全稱 來分別輸入小寫和大寫希臘字母。對于大寫希臘字母與現(xiàn)有字母相同的,直接輸入大寫字母即可。

輸入顯示輸入顯示輸入顯示輸入顯示
\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- 開頭。

小寫形式大寫形式變量形式顯示
\epsilonE\varepsilon$\epsilon \mid E \mid \varepsilon$
\theta\Theta\vartheta$\theta \mid \Theta \mid \vartheta$
\rhoP\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).對數(shù)運算符

輸入顯示輸入顯示輸入顯示
\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.如何進行字體轉(zhuǎn)換

若要對公式的某一部分字符進行字體轉(zhuǎn)換,可以用 {\字體 {需轉(zhuǎn)換的部分字符}} 命令,其中 \字體 部分可以參照下表選擇合適的字體。一般情況下,公式默認為意大利體 $italic$ 。

示例中 全部大寫 的字體僅大寫可用。

輸入說明顯示輸入說明顯示
\rm羅馬體$\rm{Sample}$\cal花體$\cal{SAMPLE}$
\it意大利體$\it{Sample}$\Bbb黑板粗體$\Bbb{SAMPLE}$
\bf粗體$\bf{Sample}$\mit數(shù)學斜體$\mit{SAMPLE}$
\sf等線體$\sf{Sample}$\scr手寫體$\scr{SAMPLE}$
\tt打字機體$\tt{Sample}$???
\frak舊德式字體$\frak{Sample}$???

轉(zhuǎn)換字體十分常用,例如在積分中:

  • 例子:

\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 來創(chuàng)建自動匹配高度的 (圓括號),[方括號] 和 {花括號} 。在每個公式末尾前使用 \tag{行標} 來實現(xiàn)行標。

  • 例子:

$$ 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} $$
  • 顯示:

如果你需要將行內(nèi)顯示的分隔符也變大,可以使用 \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} $$
  • 顯示:$$ 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).添加刪除線

使用刪除線功能必須聲明 $$ 符號。

在公式內(nèi)使用 \require{cancel} 來允許 片段刪除線 的顯示。聲明片段刪除線后,使用 \cancel{字符}、\bcancel{字符}、\xcancel{字符} 和 \cancelto{字符} 來實現(xiàn)各種片段刪除線效果。

  • 例子:

$$ \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{刪除線效果}{字符} 來實現(xiàn)各種整段刪除線效果。其中,刪除線效果有 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 命令還可以產(chǎn)生包圍的邊框和圓等,參見 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} $
  • 顯示:

matrixpmatrixbmatrixBmatrixvmatrixVmatrix
$ \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.如何輸入帶分割符號的矩陣

詳見"數(shù)組使用參考"。

  • 例子:

$$ \left[\begin{array}{cc|c}1&2&3\\4&5&6\end{array} \right] $$
  • 顯示:

其中 cc|c 代表在一個三列矩陣中的第二和第三列之間插入分割線。

5.如何輸入行中矩陣

若想在一行內(nèi)顯示矩陣,使用\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.如何輸入一個方程式序列

人們經(jīng)常想要一列整齊且居中的方程式序列。使用 \begin{align}…\end{align} 來創(chuàng)造一列方程式,其中在每行結尾處使用 \\ 。使用方程式序列無需聲明公式符號 $ 或 $$ 。

請注意 {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}

本例中每行公式的編號續(xù)自 如何插入公式 中的自動編號公式 \eqref{eq:sample} 。

2.在一個方程式序列的每一行中注明原因

在 {align} 中靈活組合 \text 和 \tag 語句。\tag 語句編號優(yōu)先級高于自動編號。

  • 例子:

\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} 來創(chuàng)造一組條件表達式,在每一行條件中插入 & 來指定需要對齊的內(nèi)容,并在每一行結尾處使用 \\,以 end{cases} 結束。條件表達式無需聲明 $ 或 $$ 符號。

  • 例子:

$$f(n) =\begin{cases}n/2, & \text{if $n$ is even} \\3n+1, & \text{if $n$ is odd}\end{cases} $$
  • 顯示:

2.如何輸入一個左側(cè)對齊的條件表達式

若想讓文字在 左側(cè)對齊顯示 ,則有如下方式:

  • 例子:

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

|適配[2ex]||:--:||$$f(n) =\begin{cases}\frac{n}{2}, & \text{if $n$ is even} \[2ex]3n+1, & \text{if $n$ is odd}\end{cases}$$|

一個 [ex] 指一個 "X-Height",即x字母高度??梢愿鶕?jù)情況指定多個 [ex],如 [3ex]、[4ex] 等。其實可以在任何地方使用 \\[2ex] 語句,只要你覺得合適。

五、數(shù)組與表格使用參考

1.如何輸入一個數(shù)組或表格

通常,一個格式化后的表格比單純的文字或排版后的文字更具有可讀性。數(shù)組和表格均以 begin{array} 開頭,并在其后定義列數(shù)及每一列的文本對齊屬性,c l r 分別代表居中、左對齊及右對齊。若需要插入垂直分割線,在定義式中插入 | ,若要插入水平分割線,在下一行輸入前插入 \hline 。與矩陣相似,每行元素間均須要插入 & ,每行元素以 \\ 結尾,最后以 end{array} 結束數(shù)組。使用單個數(shù)組或表格時無需聲明 $ 或 $$ 符號。

  • 例子:

\begin{array}{c|lcr} n & \text{左對齊} & \text{居中對齊} & \text{右對齊} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \end{array}
  • 顯示:\begin{array}{c|lcr}n & \text{左對齊} & \text{居中對齊} & \text{右對齊} \\hline1 & 0.24 & 1 & 125 \2 & -1 & 189 & -8 \3 & -20 & 2000 & 1+10i\end{array}

2.如何輸入一個嵌套的數(shù)組或表格

多個數(shù)組/表格可 互相嵌套 并組成一組數(shù)組/一組表格。使用嵌套前必須聲明 $$ 符號。

  • 例子:

$$ % outer vertical array of arrays 外層垂直表格 \begin{array}{c}% inner horizontal array of arrays 內(nèi)層水平表格\begin{array}{cc}% inner array of minimum values 內(nèi)層"最小值"數(shù)組\begin{array}{c|cccc}\text{min} & 0 & 1 & 2 & 3\\\hline0 & 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 內(nèi)層"最大值"數(shù)組\begin{array}{c|cccc}\text{max}&0&1&2&3\\\hline0 & 0 & 1 & 2 & 3\\1 & 1 & 1 & 2 & 3\\2 & 2 & 2 & 2 & 3\\3 & 3 & 3 & 3 & 3\end{array}\end{array}% 內(nèi)層第一行表格組結束\\% inner array of delta values 內(nèi)層第二行Delta值數(shù)組\begin{array}{c|cccc}\Delta&0&1&2&3\\\hline0 & 0 & 1 & 2 & 3\\1 & 1 & 0 & 1 & 2\\2 & 2 & 1 & 0 & 1\\3 & 3 & 2 & 1 & 0\end{array}% 內(nèi)層第二行表格組結束 \end{array} $$
  • 顯示:

3.如何輸入一個方程組

使用 \begin{array}…\end{array} 和 \left\{…\right. 來創(chuàng)建一個方程組。

  • 例子:

$$ \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. $$
  • 顯示:

或者使用條件表達式組 \begin{cases}…\end{cases} 來實現(xià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}

六、連分數(shù)使用參考

1.如何輸入一個連分式

就像輸入分式時使用 \frac 一樣,使用 \cfrac 來創(chuàng)建一個連分數(shù)。

  • 例子:

$$ x = a_0 + \cfrac{1^2}{a_1+ \cfrac{2^2}{a_2+ \cfrac{3^2}{a_3 + \cfrac{4^4}{a_4 + \cdots}}}} $$
  • 顯示:

不要使用普通的 \frac 或 \over 來創(chuàng)建,否則會看起來 很惡心 。

  • 反例:

$$ x = a_0 + \frac{1^2}{a_1+ \frac{2^2}{a_2+ \frac{3^2}{a_3 + \frac{4^4}{a_4 + \cdots}}}} $$
  • 顯示:

當然,你可以使用 \frac 來表達連分數(shù)的 緊縮記法 。

  • 例子:

$$ x = a_0 + \frac{1^2}{a_1+}\frac{2^2}{a_2+}\frac{3^2}{a_3 +} \frac{4^4}{a_4 +} \cdots $$
  • 顯示:

連分數(shù)通常都太大以至于不易排版,所以建議在連分數(shù)前后聲明 $$ 符號,或使用像 [a0;a1,a2,a3,…] 一樣的緊縮記法。

七、交換圖表使用參考

1.如何輸入一個交換圖表

使用一行 $ \require{AMScd} $ 語句來允許交換圖表的顯示。聲明交換圖表后,語法與矩陣相似,在開頭使用 begin{CD},在結尾使用 end{CD},在中間插入圖表元素,每個元素之間插入 & ,并在每行結尾處使用 \\ 。

  • 例子:

$\require{AMScd}$ \begin{CD}A @>a>> B\\@V b V V\# @VV c V\\C @>>d> D \end{CD}
  • 顯示:$\require{AMScd}$\begin{CD} A @>a>> B\ @V b V V# @VV c V\ C @>>d> D\end{CD}

其中,@>>> 代表右箭頭、@<<< 代表左箭頭、@VVV 代表下箭頭、@AAA 代表上箭頭、@= 代表水平雙實線、@| 代表豎直雙實線、@.代表沒有箭頭。在 @>>> 的 >>> 之間任意插入文字即代表該箭頭的注釋文字。

  • 例子:

\begin{CD}A @>>> B @>{\text{very long label}}>> C \\@. @AAA @| \\D @= E @<<< F \end{CD}
  • 顯示:\begin{CD} A @>>> B @>{\text{very long label}}>> C \ @. @AAA @| \ D @= E @<<< F\end{CD}

在本例中, "very long label"自動延長了它所在箭頭以及對應箭頭的長度。

八、一些特殊的注意事項

|!! 本段內(nèi)容為個人翻譯,可能有不準確之處 !!||:--:|

These are issues that won't affect the correctness of formulas, but might make them look significantly better or worse. Beginners should feel free to ignore this advice; someone else will correct it for them, or more likely nobody will care.

現(xiàn)在指出的小問題并不會影響方程式及公式等的正確顯示,但能讓它們看起來明顯更好看。初學者可無視這些建議,自然會有強迫癥患者替你們改掉它的,或者更可能地,根本沒人發(fā)現(xiàn)這些問題。

Don't use \frac in exponents or limits of integrals; it looks bad and can be confusing, which is why it is rarely done in professional mathematical typesetting. Write the fraction horizontally, with a slash:

在以e為底的指數(shù)函數(shù)、極限和積分中盡量不要使用 \frac 符號:它會使整段函數(shù)看起來很怪,而且可能產(chǎn)生歧義。也正是因此它在專業(yè)數(shù)學排版中幾乎從不出現(xiàn)。橫著寫這些分式,中間使用斜線間隔 / (用斜線代替分數(shù)線)。

  • 例子:

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ e^{i\frac{\pi}2} \quad e^{\frac{i\pi}2}& e^{i\pi/2} \\ \int_{-\frac\pi2}^\frac\pi2 \sin x\,dx & \int_{-\pi/2}^{\pi/2}\sin x\,dx \\ \end{array}
  • 顯示:\begin{array}{cc}\mathrm{Bad} & \mathrm{Better} \\hline \e^{i\frac{\pi}2} \quad e^{\frac{i\pi}2}& e^{i\pi/2} \\int{-\frac\pi2}^\frac\pi2 \sin x\,dx & \int{-\pi/2}^{\pi/2}\sin x\,dx \\end{array}

The | symbol has the wrong spacing when it is used as a divider, for example in set comprehensions. Use \mid instead:

| 符號在被當作分隔符時會產(chǎn)生錯誤的間隔,因此在需要分隔時最好使用 \mid 來代替它。

  • 例子:

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \{x|x^2\in\Bbb Z\} & \{x\mid x^2\in\Bbb Z\} \\ \end{array}
  • 顯示:\begin{array}{cc}\mathrm{Bad} & \mathrm{Better} \\hline \{x|x^2\in\Bbb Z} & {x\mid x^2\in\Bbb Z} \\end{array}

For double and triple integrals, don't use \int\int or \int\int\int. Instead use the special forms \iint and \iiint:

使用多重積分符號時,不要多次使用 \int 來聲明,直接使用 \iint 來表示 二重積分 ,使用 \iiint 來表示 三重積分 等。對于無限次積分,可以用 \int \cdots \int 表示。

  • 例子:

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \int\int_S f(x)\,dy\,dx & \iint_S f(x)\,dy\,dx \\ \int\int\int_V f(x)\,dz\,dy\,dx & \iiint_V f(x)\,dz\,dy\,dx \end{array}
  • 顯示:\begin{array}{cc}\mathrm{Bad} & \mathrm{Better} \\hline \\int\int_S f(x)\,dy\,dx & \iint_S f(x)\,dy\,dx \\int\int\int_V f(x)\,dz\,dy\,dx & \iiint_V f(x)\,dz\,dy\,dx\end{array}

$$無限次積分:\int \cdots \int$$

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}


感謝您花費時間閱讀這份指導手冊,本手冊內(nèi)容可能有疏漏之處,歡迎更改指正。更多語法請參見:Cmd Markdown 簡明語法手冊,Cmd Markdown 高階語法手冊。祝您記錄、閱讀、分享愉快!

Drafted & Translated by Eric P.2015-10-02

總結

以上是生活随笔為你收集整理的Markdown中插入公式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。