基础语法

表格

添加表格:

要添加表,使用三个或多个连字符(---)创建每列的标题,并使用管道(|)分隔每列。可以选择在表的任一端添加管道。

1
2
3
4
| Syntax      | Description |
| --- --- --- | --- --- --- |
| Header | Title |
| Paragraph | Text |

效果:

SyntaxDescription
HeaderTitle
ParagraphText

对齐:

可以通过在标题行中的连字符的左侧,右侧或两侧添加冒号(:),将列中的文本对齐到左侧,右侧或中心。

1
2
3
4
| Syntax    | Description |   Test Text |
| :-------- | :---------: | ----------: |
| Header | Title | Here's this |
| Paragraph | Text | And more |

效果:

SyntaxDescriptionTest Text
HeaderTitleHere’s this
ParagraphTextAnd more

格式化表格中的文字:

可以在表格中设置文本格式。例如,可以添加链接,代码(仅反引号(`)中的单词或短语,而不是代码块)和强调。注:不能添加标题,块引用,列表,水平规则,图像或HTML标签。

在表中转义管道字符:

可以使用表格的HTML字符代码(|)在表中显示竖线(|)字符。

围栏代码块

代码块:

通过将行缩进四个空格或一个制表符来创建代码块,在代码块之前和之后的行上使用三个反引号(```)或三个波浪号(~~~)。

效果:

1
2
3
4
5
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}

标题编号

Markdown:

1
### My Great Heading {#custom-id}

HTML:

1
<h3 id="custom-id">My Great Heading</h3>

链接到标题ID (#headid)

通过创建带有数字符号(#)和自定义标题ID的[标准链接](/basic-syntax/links.html),可以链接到文件中具有自定义ID的标题。

MarkdownHTML效果
[Heading IDs](#heading-ids)<a href="#heading-ids">Heading IDs</a>Heading IDs

表格

创建定义列表,在第一行上键入术语。在下一行,键入一个冒号,后跟一个空格和定义。

Markdown

1
2
3
4
5
6
First Term
: This is the definition of the first term.

Second Term
: This is one definition of the second term.
: This is another definition of the second term.

HTML

1
2
3
4
5
6
7
<dl>
<dt>First Term</dt>
<dd>This is the definition of the first term.</dd>
<dt>Second Term</dt>
<dd>This is one definition of the second term. </dd>
<dd>This is another definition of the second term.</dd>
</dl>

效果:
First Term
: This is the definition of the first term.

Second Term
: This is one definition of the second term.
: This is another definition of the second term.

删除线

删除单词,在单词前后使用两个波浪号~~。

1
~~世界是平坦的。~~ 我们现在知道世界是圆的。

效果:
世界是平坦的。 我们现在知道世界是圆的。

任务列表

任务列表可以创建带有复选框的项目列表。在支持任务列表的Markdown应用程序中,复选框将显示在内容旁边。要创建任务列表,在任务列表项之前添加破折号-和方括号[ ],并在[ ]前面加上空格。要选择一个复选框,在方括号[x]之间添加 x 。

1
2
3
- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media

效果:

  • [x] Write the press release
  • [ ] Update the website
  • [ ] Contact the media

公式符号

上下标

算式Markdown
$a_i,a_{pre}$a_i,a_{pre}
$a^i,a^{[n+m]}$a^i, a^{[n+m]}$\ $

括号

算式Markdown
(, )(, )
[, ][, ]
⟨,⟩\lang, \rang 或 \langle, \rangle
∣,∣\lvert, \rvert
∥,∥\lVert, \rVert
{,}\lbrace, \rbrace 或 \{,\} $\ $

增大括号:

算式Markdown
(x)(x)
$\big( x \big)$\big( x \big)
$\Big( x \Big)$\Big( x \Big)
$\bigg( x \bigg)$\bigg( x \bigg)
$\Bigg(x\Bigg)$\Bigg( x \Bigg)

其他的大括号类似增大括号的方法

算式Markdown
$\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)$\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)
$\Bigg[\bigg[\Big[\big[[x]\big]\Big]\bigg]\Bigg]$\Bigg[\bigg[\Big[\big[[x]\big]\Big]\bigg]\Bigg]
$\Bigg \langle \bigg \langle \Big \langle\big\langle\langle x \rangle \big \rangle\Big\rangle\bigg\rangle\Bigg\rangle$\Bigg \langle \bigg \langle \Big \langle\big\langle\langle x \rangle \big \rangle\Big\rangle\bigg\rangle\Bigg\rangle
$\Bigg\lvert\bigg\lvert\Big\lvert\big\lvert\lvert x \rvert\big\rvert\Big\rvert\bigg\rvert\Bigg\rvert$\Bigg\lvert\bigg\lvert\Big\lvert\big\lvert\lvert x \rvert\big\rvert\Big\rvert\bigg\rvert\Bigg\rvert
$\Bigg\lVert\bigg\lVert\Big\lVert\big\lVert\lVert x \rVert\big\rVert\Big\rVert\bigg\rVert\Bigg\rVert$\Bigg\lVert\bigg\lVert\Big\lVert\big\lVert\lVert x \rVert\big\rVert\Big\rVert\bigg\rVert\Bigg\rVert

分数/开方/累加/累乘

算式Markdown
$\frac{a}{b}$frac${a}{b}$
$\sqrt{a + b}$sqrt${a + b}$
$\sum_{i = 0}^{n}\frac{1}{i^2}$\sum_{i = 0}^{n}\frac{1}{i^2}
$\prod_{i = 0}^{n}\frac{1}{x^2}$\prod_{i = 0}^{n}\frac{1}{x^2}

三角函数

算式Markdown
$\sin$\sin
$\cos$\cos
$\tan$\tan
$\cot$\cot
$\sec$\sec
$\csc$\csc
$\bot$\bot
$\angle$\angle
$40^\circ$40^\circ

对数函数

算式Markdown
$\ln{a + b}$\ln${a + b}$
$\log_{a}^{b}$\log_{a}^${b}$
$\lg{a + b}$\lg${a + b}$

二元运算符

算式Markdown描述
$\pm$\pm正负号
$\mp$\mp负正号
$\times$\times乘号
$\div$\div除号
$\ast$\ast星号
$\star$\star
$\mid$\mid竖线
$\nmid$\nmid
$\circ$\circ圈
$\bigcirc$\bigcirc
$\bullet$\bullet
$\cdot$\cdot点
$\wr$\wr
$\diamond$\diamond
$\Diamond$\Diamond
$\triangle$\triangle
$\bigtriangleup$\bigtriangleup
$\bigtriangledown$\bigtriangledown
$\triangleleft$\triangleleft
$\triangleright$\triangleright
$\lhd$\lhd
$\rhd$\rhd
$\unlhd$\unlhd
$\unrhd$\unrhd
$\odot$\odot
$\bigodot$\bigodot点积
$\oslash$\oslash
$\ominus$\ominus
$\otimes$\otimes
$\bigotimes$\bigotimes克罗内克积
$\oplus$\oplus
$\bigoplus$\bigoplus异或
$\dagger$\dagger
$\ddagger$\ddagger
$\amalg$\amalg…

关系符号

算式Markdown描述
$\leq$\leq小于等于
$\geq$\leq大于等于
$\equiv$\equiv全等于
$\models$\models
$\prec$\prec
$\succ$\succ
$\sim$\sim
$\perp$\perp
$\preceq$\preceq
$\succeq$\succeq
$\simeq$\simeq
$\mid$\mid
$\ll$\ll
$\gg$\gg
$\asymp$\asymp
$\parallel$\parallel
$\approx$\approx
$\cong$\cong
$\neq$\neq不等于
$\doteq$\doteq
$\propto$\propto
$\bowtie$\bowtie
$\Join$\Join
$\smile$\smile
$\frown$\frown
$\vdash$\vdash
$\dashv$\dashv…

极限/向量

算式Markdown
$\lim$\lim
$\rightarrow$\rightarrow
$\infty$\infty
$\lim_{n\rightarrow+\infty}n$\lim_{n\rightarrow+\infty}n
$\vec{a}$\vec{a}

箭头

算式Markdown
$\uparrow$\uparrow
$\downarrow$\downarrow
$\updownarrow$\updownarrow
$\Uparrow$\Uparrow
$\Downarrow$\Downarrow
$\Updownarrow$\Updownarrow
$\rightarrow$\rightarrow
$\leftarrow$\leftarrow
$\leftrightarrow$\leftrightarrow
$\Rightarrow$\Rightarrow
$\Leftarrow$\Leftarrow
$\Leftrightarrow$\Leftrightarrow
$\longrightarrow$\longrightarrow
$\longleftarrow$\longleftarrow
$\longleftrightarrow$\longleftrightarrow
$\Longrightarrow$\Longrightarrow
$\Longleftarrow$\Longleftarrow
$\Longleftrightarrow$\Longleftrightarrow
$\mapsto$\mapsto
$\longmapsto$\longmapsto
$\hookleftarrow$\hookleftarrow
$\hookrightarrow$\hookrightarrow
$\rightharpoonup$\rightharpoonup
$\leftharpoondown$\leftharpoondown
$\rightleftharpoons$\rightleftharpoons
$\leftharpoonup$\leftharpoonup
$\rightharpoondown$\rightharpoondown
$\leadsto$\leadsto
$\nearrow$\nearrow
$\searrow$\searrow
$\swarrow$\swarrow
$\nwarrow$\nwarrow

集合

算式Markdown描述
$\emptyset$\emptyset空集
$\in$\in属于
$\ni$\ni
$\notin$\notin不属于
$\subset$\subset子集
$\supset$\supset
$\not\subset$\not\subset非子集
$\subseteq$\subseteq真子集
$\supseteq$\supseteq
$\cup$\cup并集
$\bigcup$\bigcup并集
$\cap$\cap交集
$\bigcap$\bigcap交集
$\uplus$\uplus多重集
$\biguplus$\biguplus多重集
$\sqsubset$\sqsubset
$\sqsupset$\sqsupset
$\sqcap$\sqcap
$\sqsubseteq$\sqsubseteq
$\sqsupseteq$\sqsupseteq
$\vee$\vee
$\wedge$\wedge
$\setminus$\setminus集合中的减法

微积分

算式Markdown描述
$\prime$\prime
$\int$\int积分
$\iint$\iint双重积分
$\iiint$\iiint三重积分
$\oint$\oint曲线积分
$\nabla$\nabla梯度
$\int_0^2 x^2 dx$\int_0^2 x^2 dx其他的积分符号类似

逻辑运算

算式Markdown描述
$\because$\because因为
$\therefore$\therefore所以
$\forall$\forall任意
$\exists$\exists存在
$\vee$\vee逻辑与
$\wedge$\wedge逻辑或
$\bigvee$\bigvee逻辑与
$\bigwedge$\bigwedge逻辑或

上下标符号

算式Markdown
$\bar{a}$\bar${a}$
$\acute\a$\acute
$\breve{a}$\breve${a}$
$\grave{a}$\grave${a}$
$\dot{a}$\dot${a}$
$\ddot{a}$\ddot${a}$
$\hat{a}$\hat${a}$
$\check{a}$\check${a}$
$\breve{a}$\breve${a}$
$\tilde{a}$\tilde${a}$
$\vec{a}$\vec${a}$
$\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}$\overbrace${a + b + c + d}$
$\underline{a + b + c + d}$\underline${a + b + c + d}$
$\overbrace{a + \underbrace{b + c}_{1.0} + d}^{2.0}$\overbrace{a + \underbrace{b + c}_{1.0} + d}^${2.0}$

希腊字母

大写Markdown小写Markdown
$A$\Alpha$\alpha$\alpha
$B$$\beta$\beta
$\Gamma$\Gamma$\gamma$\gamma
$\Delta$\Delta$\delta$\delta
$E$\Epsilon$\epsilon$\epsilon
$\varepsilon$\varepsilon
$Z$\Zeta$\zeta$\zeta
$H$\Eta$\eta$\eta
$\Theta$\Theta$\theta$\theta
$I$\Iota$\iota$\iota
$K$\Kappa$\kappa$
$\Lambda$\Lambda$\lambda$\lambda
$M$\Mu$\mu$\mu
$N$\Nu$\nu$\nu
$\Xi$\Xi$\xi$\xi
$O$\Omicron$\omicron$\omicron
$\Pi$\Pi$\pi$\pi
$R$\Rho$\rho$\rho
$\Sigma$\Sigma$\sigma$\sigma
$T$\Tau$\tau$\tau
$\Upsilon$\Upsilon$\upsilon$\upsilon
$\Phi$\Phi$\phi$\phi
$\varphi$\varphi
$X\Chi$\chi$\chi
$\Psi$\Psi$\psi$\psi
$\Omega$\Omega$\omega$\omega

省略号

算式Markdown描述
$\dots$\dots一般用于有下标的序列
$\ldots$\ldots
$\cdots$\cdots纵向位置比\dots稍高
$\vdots$\vdots竖向
$\ddots$\ddots…

例:

1
2
3
$$ 
x_1, x_2, \dots, x_n \quad \quad 1, 2, \cdots, n \quad \quad \vdots \quad\quad \ddots
$$

$$
x_1, x_2, \dots, x_n \quad \quad 1, 2, \cdots, n \quad \quad \vdots \quad\quad \ddots
$$

分支

$$
y=
\begin{cases}
-x,\quad x\leq 0\
x, \quad x>0
\end{cases}
\tag{1}
$$

1
2
3
4
5
6
7
8
$$
y=
\begin{cases}
-x,\quad x\leq 0\\
x, \quad x>0
\end{cases}
\tag{1}
$$

其他环境

下面这些标签环境在很多markdown中不能解析

环境名称描述
align最基本的对齐环境
multline非对齐环境
gather无对齐的连续方程

矩阵

不带括号:
$$
\begin{matrix}
1 & 2 & 3\
4 & 5 & 6 \
7 & 8 & 9
\end{matrix}
\tag{1}
$$

1
2
3
4
5
6
7
8
$$
\begin{matrix}
1 & 2 & 3\\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
\tag{1}
$$

带括号

$$\left(
\begin{matrix}
1 & 2 & 3\
4 & 5 & 6 \
7 & 8 & 9
\end{matrix}
\right)
\tag{2}
$$

1
2
3
4
5
6
7
8
9
$$\left(
\begin{matrix}
1 & 2 & 3\\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
\right)
\tag{2}
$$

中括号

$$\left[
\begin{matrix}
1 & 2 & 3\
4 & 5 & 6 \
7 & 8 & 9
\end{matrix}
\right]
\tag{3}
$$

1
2
3
4
5
6
7
8
9
$$\left[
\begin{matrix}
1 & 2 & 3\\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
\right]
\tag{3}
$$

大括号

$$\left{
\begin{matrix}
1 & 2 & 3\
4 & 5 & 6 \
7 & 8 & 9
\end{matrix}
\right}
\tag{4}
$$

1
2
3
4
5
6
7
8
9
$$\left\{
\begin{matrix}
1 & 2 & 3\\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
\right\}
\tag{4}
$$

带省略号

$$
\left[
\begin{matrix}
a & b & \cdots & a\
b & b & \cdots & b\
\vdots & \vdots & \ddots & \vdots\
c & c & \cdots & c
\end{matrix}
\right]
\tag{5}
$$

1
2
3
4
5
6
7
8
9
10
11
$$
\left[
\begin{matrix}
a & b & \cdots & a\\
b & b & \cdots & b\\
\vdots & \vdots & \ddots & \vdots\\
c & c & \cdots & c
\end{matrix}
\right]
\tag{5}
$$

带横线/竖线分割的矩阵

$$
\left[
\begin{array}{c|cc}
1 & 2 & 3 \
4 & 5 & 6 \
7 & 8 & 9
\end{array}
\right]
\tag{6}
$$

1
2
3
4
5
6
7
8
9
10
$$
\left[
\begin{array}{c|cc}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{array}
\right]
\tag{6}
$$

横线用 \hline 分割
$$
\left[
\begin{array}{ccc}
1 & 2 & 3 \ \hline
4 & 5 & 6 \
7 & 8 & 9
\end{array}
\right]
\tag{7}
$$

1
2
3
4
5
6
7
8
9
10
$$
\left[
\begin{array}{ccc}
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\
7 & 8 & 9
\end{array}
\right]
\tag{7}
$$