Markdown格式
Markdown格式文件编写
达到「心中无尘,码字入神」的境界需要这个,于是这篇文章应运而生!
----------前言
元素 | Markdown 语法 |
---|---|
标题(Heading) | # H1## H2### H3 |
粗体(Bold) | **bold text** |
斜体(Italic) | *italicized text* |
引用块(Blockquote) | > blockquote |
有序列表(Ordered List) | 1. First item 2. Second item
3. Third item |
无序列表(Unordered List) | - First item- Second item- Third item |
代码(Code) | code |
分隔线(Horizontal Rule) | --- |
链接(Link) | [title](https://www.example.com) |
图片(Image) |  |
标题:
要创建标题,请在单词或短语前面添加井号 (#
)
。#
的数量代表了标题的级别。例如,添加三个 #
表示创建一个三级标题 (<h3>
)
(例如:### My Header
)。
# Heading level 1
## Heading level 2
### Heading level 3
效果如下
段落
不要用空格(spaces)或制表符( tabs)缩进段落。 1
2\<h1> Markdown段落
这也是一种一级标题的表达方式
粗体
要加粗文本,请在单词或短语的前后各添加两个星号(asterisks)或下划线(underscores)。如需加粗一个单词或短语的中间部分用以表示强调的话,请在要加粗部分的两侧各添加两个星号(asterisks)。
I just love bold text. 为下面:
I just love **bold text**
.
Markdown语法 | HTML | 预览效果 |
---|---|---|
I just love **bold text**. |
I just love <strong>bold text</strong>. |
I just love bold text. |
I just love __bold text__. |
I just love <strong>bold text</strong>. |
I just love bold text. |
Love**is**bold |
Love<strong>is</strong>bold |
Loveisbold |
建议都用*号来写
斜体
要用斜体显示文本,请在单词或短语前后添加一个星号(asterisk)或下划线(underscore)。要斜体突出单词的中间部分,请在字母前后各添加一个星号,中间不要带空格。
Markdown语法 | HTML | 预览效果 |
---|---|---|
Italicized text is the *cat's meow*. |
Italicized text is the <em>cat's meow</em>. |
Italicized text is the cat’s meow. |
Italicized text is the _cat's meow_. |
Italicized text is the <em>cat's meow</em>. |
Italicized text is the cat’s meow. |
A*cat*meow |
A<em>cat</em>meow |
Acatmeow |
建议用*号
粗体(Bold)和斜体(Italic)
要同时用粗体和斜体突出显示文本,请在单词或短语的前后各添加三个星号或下划线。要加粗并用斜体显示单词或短语的中间部分,请在要突出显示的部分前后各添加三个星号,中间不要带空格。
建议三个*号,一步到位
引用
要创建块引用,请在段落前添加一个 >
符号。
1 | > Dorothy followed her through many of the beautiful rooms in her castle. |
渲染效果如下所示:
Dorothy followed her through many of the beautiful rooms in her castle.
嵌套块引用
块引用可以嵌套。在要嵌套的段落前添加一个 >>
符号。
1 | > Dorothy followed her through many of the beautiful rooms in her castle. |
渲染效果如下:
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
带有其它元素的块引用
块引用可以包含其他 Markdown 格式的元素。并非所有元素都可以使用,你需要进行实验以查看哪些元素有效。
1 | > #### The quarterly results look great! |
渲染效果如下:
The quarterly results look great!
- Revenue was off the chart.
- Profits were higher than ever.
Everything is going according to plan.
列表
可以将多个条目组织成有序或无序列表
要创建有序列表,请在每个列表项前添加数字并紧跟一个英文句点。数字不必按数学顺序排列,但是列表应当以数字 1 起始。
Markdown语法 | HTML |
---|---|
1. First item2. Second item3. Third item4. Fourth item |
<ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> |
1. First item1. Second item1. Third item1. Fourth item |
<ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> |
1. First item8. Second item3. Third item5. Fourth item |
<ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> |
1. First item2. Second item3. Third item 1. Indented item 2. Indented item4. Fourth item |
<ol><li>First item</li><li>Second item</li><li>Third item<ol><li>Indented item</li><li>Indented item</li></ol></li><li>Fourth item</li></ol> |
要创建无序列表,请在每个列表项前面添加破折号 (-)、星号 (*) 或加号 (+) 。缩进一个或多个列表项可创建嵌套列表。
Markdown语法 | HTML |
---|---|
- First item- Second item- Third item- Fourth item |
<ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> |
* First item* Second item* Third item* Fourth item |
<ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> |
+ First item+ Second item+ Third item+ Fourth item |
<ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> |
- First item- Second item- Third item - Indented item - Indented item- Fourth item |
<ul><li>First item</li><li>Second item</li><li>Third item<ul><li>Indented item</li><li>Indented item</li></ul></li><li>Fourth item</li></ul> |
要在保留列表连续性的同时在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符,如下例所示:
段落
1 | * This is the first list item. |
渲染效果如下:
This is the first list item.
Here's the second list item.
I need to add another paragraph below the second list item.
And here's the third list item.
#引用块
1 | * This is the first list item. |
渲染效果如下:
This is the first list item.
Here's the second list item.
A blockquote would look great below the second list item.
And here's the third list item.
代码块
要将单词或短语表示为代码,请将其包裹在反引号中。
Markdown语法 | HTML | 预览效果 |
---|---|---|
At the command prompt, type `nano`. |
At the command prompt, type <code>nano</code>. |
At the command prompt, type nano |
代码块
只需要打```加上空格即可
1 |
1 | 分割线的创建,这样打之后加个空格换行就出来了 |
分隔线(Horizontal Rule)用法最佳实践
为了兼容性,请在分隔线的前后均添加空白行。
✅ Do this | ❌ Don't do this |
---|---|
Try to put a blank line before...---...and after a horizontal rule. |
Without blank lines, this would be a heading.---Don't do this! |
Without blank lines
this would be a heading.
链接语法
1 | 这是一个链接 [Markdown语法](https://markdown.com.cn)。 |
这个一个链接 最小生成树
使用尖括号可以很方便地把URL或者email地址变成可点击的链接。
1 | <https://markdown.com.cn> |
带格式化的链接
强调 链接, 在链接语法前后增加星号。 要将链接表示为代码,请在方括号中添加反引号。
1 | I love supporting the **[EFF](https://eff.org)**. |
渲染效果如下:
I love supporting the EFF. This is the Markdown Guide. See the
section on code
图片
插入图片Markdown语法代码:
。
要添加图像,请使用感叹号 (!
),
然后在方括号增加替代文本,图片链接放在圆括号里,括号里的链接后可以增加一个可选的图片标题文本。
要显示原本用于格式化 Markdown 文档的字符,请在字符前面添加反斜杠字符 。
1 | \* Without the backslash, this would be a bullet in an unordered list. |
渲染效果如下:
* Without the backslash, this would be a bullet in an unordered list
表格
Markdown 表格
要添加表,请使用三个或多个连字符(---
)创建每列的标题,并使用管道(|
)分隔每列。您可以选择在表的任一端添加管道。
1 | | Syntax | Description | |
呈现的输出如下所示:
Syntax | Description |
---|---|
Header | Title |
Paragraph | Text |
对齐
您可以通过在标题行中的连字符的左侧,右侧或两侧添加冒号(:
),将列中的文本对齐到左侧,右侧或中心。
1 | | Syntax | Description | Test Text | |
呈现的输出如下所示:
Syntax | Description | Test Text |
---|---|---|
Header | Title | Here’s this |
Paragraph | Text | And more |
脚注
1 | Here's a simple footnote,[^1] and here's a longer one.[^bignote] |
结果如下:
Here's a simple footnote,1 and here's a longer one.2
删除线
您可以通过在单词中心放置一条水平线来删除单词。结果看起来像这样。此功能使您可以指示某些单词是一个错误,要从文档中删除。若要删除单词,请在单词前后使用两个波浪号~~
。
1 | ~~世界是平坦的。~~ 我们现在知道世界是圆的。 |
呈现的输出如下所示:
世界是平坦的。 我们现在知道世界是圆的。
任务列表使您可以创建带有复选框的项目列表。在支持任务列表的Markdown应用程序中,复选框将显示在内容旁边。要创建任务列表,请在任务列表项之前添加破折号-
和方括号[ ]
,并在[ ]
前面加上空格。要选择一个复选框,请在方括号[x]
之间添加
x 。
1 | - [x] Write the press release |
使用表情符号简码
一些Markdown应用程序允许您通过键入表情符号短代码来插入表情符号。这些以冒号开头和结尾,并包含表情符号的名称。
1 | 去露营了! :tent: 很快回来。 |
呈现的输出如下所示:
去露营了! :tent: 很快回来。
真好笑! :joy:
快捷键收集:
斜体
- 将要加粗的文字左右分别用一个
*
包起来 - 快捷键:
ctrl
+I
- 将要加粗的文字左右分别用一个
加粗
- 将要倾斜的文字左右分别用
**
包起来 - 快捷键:
ctrl
+B
- 将要倾斜的文字左右分别用
下划线
- 将要加下划线的文字用
<u>``</u>
包起来 - 快捷键:ctrl+U
- 将要加下划线的文字用
删除线
- 将要加删除线的文字用
~``~
包起来 - 快捷键:shift+alt+5
- 将要加删除线的文字用
公式块
方法一:左上角点击“段落”,再点击“公式块”
方法二:在文中输入$$,再按下回车
常用符号的代码
- 上下标,正负无穷
- 加减乘,分式,根号,省略号
- 三角函数
- 矢量,累加累乘,极限
- 希腊字母
p.s:若想在markdown中写出\(而不发生转义,应当在每个\)符号前加,比如$
算式 markdown **sin * **cos * **tan * **cot * **sec * **csc * **⊥ * **∠ * **40∘ 40^*
简单矩阵
1 | $$ |
\[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \tag{1} \]
大括号矩阵
1 | $$ |
\[ \left\{ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right\} \tag{2} \]
中括号:
1 | $$ |
\[ \left[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right] \tag{3} \]
小括号:
1 | $$ |
\[ \left( \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right) \tag{4} \]
包含希腊字母与省略号
行省略号\cdots
,列省略号\vdots
,斜向省略号(左上至右下)\ddots
。
1 | $$ |
\[ \left\{ \begin{matrix} 1 & 2 & \cdots & 5 \\ 6 & 7 & \cdots & 10 \\ \vdots & \vdots & \ddots & \vdots \\ \alpha & \alpha+1 & \cdots & \alpha+4 \end{matrix} \right\} \]
行列式
1 | $$ |
\[ \begin{vmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{vmatrix} \tag{7} \]
1 | X=\left| |
\[ X=\left| \begin{matrix} x_{11} & x_{12} & \cdots & x_{1d}\\ x_{21} & x_{22} & \cdots & x_{2d}\\ \vdots & \vdots & \ddots & \vdots \\ x_{11} & x_{12} & \cdots & x_{1d}\\ \end{matrix} \right| \tag{2-3} \]
表格
1.简易表格
1 | $$ |
\[ \begin{array}{|c|c|c|} \hline 2&9&4\\ \hline 7&5&3\\ \hline 6&1&8\\ \hline \end{array} \]
开头结尾: \begin{array}
,
\end{array}
定义式:例:{|c|c|c|}
,其中c
l
r
分别代表居中、左对齐及右对齐。
分割线:①竖直分割线:在定义式中插入
|
, (||
表示两条竖直分割线)。
②水平分割线:在下一行输入前插入
\hline
,以下图真值表为例。
其他:每行元素间均须要插入 &
,每行元素以
\\
结尾。
2.真值表
1 | $$ |
\[ \begin{array}{cc|c} A&B&F\\ \hline 0&0&0\\ 0&1&1\\ 1&0&1\\ 1&1&1\\ \end{array} \tag{8} \]
多行等式对齐
1 | $$ |
\[ \begin{aligned} a &= b + c \\ &= d + e + f \end{aligned} \]
方程组、条件表达式
1 | $$ |
\[ \begin{cases} 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases} \]
1 | $$ |
\[ f(n) = \begin{cases} n/2, & \text{如果 }n\text{ 是奇数} \\ 3n+1, & \text{如果 }n\text{ 是偶数} \end{cases} \]
1 | A_{ij} = |
$$ A_{ij} =
\[\begin{cases} 1, \text{if} \, \ e_{ij} \in E \\ 0, \text{if} \, \ e_{ij} \notin E \end{cases}\]$$
1 | L(t) = |
\[ L(t) = \left \{ \begin{aligned} & 5 t^2 \, & |t| \le 0.1 \\ & |t| - 0.05 \, & \text{else} \end{aligned} \right. \]
求和表达式
1 | 求和 \sum_{n=1}^{100} {a_n} |
\[ \sum_{n=1}^{100} {a_n} \]
累乘法
1 | 累乘 \prod_{n=1}^{199} {x_n} |
\[ \prod_{n=1}^{199} {x_n} \]
定积分
1 | 定积分 \int_{1}^{2}xdx |
\[ \int_{1}^{2}xdx \]
极限
1 | \lim_{n\rightarrow + \infty} {(a+b)} |
\[ 极限 \lim_{n\rightarrow + \infty} {(a+b)} \]
表达式下括号
1 | \underbrace{1, 1, \cdots, 1}_{n} |
\[ \underbrace{1, 1, \cdots, 1}_{n} \]
省略号
名称 | 形状 | 代码 |
---|---|---|
单个点 | \cdot |
|
横向多个点 | \cdots |
|
竖向多个点 | \vdots |
|
斜向多个点 | \ddots |
1 | 长箭头 |
\[ \longrightarrow \]
1 | 波浪线 |
\[ \sim \]
1 | 正方形,三角形 |
\[ \square \\ \triangle \]
1 | hat的用法 |
\[ abc \hat d ef \\ ab \hat{cdef} \]
1 | \triangleq |
\[ \triangleq \]
1 | 迷你数学公式:\tiny f = a + b |
\[ 迷你数学公式:\tiny f = a + b 小数学公式:\small f = a + b 大数学公式:\large f = a + b \]
算式 | markdown | 描述 |
---|---|---|
± | 正负号 | |
∓ | 负正号 | |
× | 乘号 | |
÷ | 除号 | |
∗ | 星号 | |
⋆ | ||
∣ | 竖线 | |
∤ | ||
∘ | 圈 | |
∙ | ||
⋅ | 点 | |
≀ | ||
⋄ | ||
◊ | ||
△ | ||
△ | ||
▽ | ||
◃ | ||
▹ | ||
⊲ | ||
⊳ | ||
⊴ | ||
⊵ | ||
∘ | ||
◯ | ||
⊙ | ||
⨀ | 点积 | |
⊘ | ||
⊖ | ||
⊗ | ||
⨂ | 克罗内克积 | |
⊕ | ||
⨁ | 异或 | |
† | ||
‡ | ||
⨿ |
增大括号的方法:
算式 | markdown |
---|---|
(x) | (x) |
(x) | ( x ) |
(x) | ( x ) |
(x) | ( x ) |
(x) | ( x ) |
关系符号
算式 | markdown | 描述 |
---|---|---|
≤ | 小于等于 | |
≥ | 大于等于 | |
≡ | 同余 | |
(mod n) | n | 同余 |
mod | 取模 | |
⊨ | ||
≺ | ||
≻ | ||
∼ | ||
⊥ | ||
⪯ | ||
⪰ | ||
≃ | ||
∣ | ||
≪ | ||
≫ | ||
≍ | ||
∥ | ||
≈ | ||
≅ | ||
≠ | 不等于 | |
≐ | ||
∝ | ||
⋈ | ||
⋈ | ||
⌣⌣ | ||
⌢⌢ | ||
⊢ | ||
⊣ |
集合
算式 | markdown | 描述 |
---|---|---|
∅ | 空集 | |
∈ | 属于 | |
∋ | ||
∉ | 不属于 | |
⊂ | 子集 | |
⊃ | ||
⊄ | 非子集 | |
⊆ | 真子集 | |
⊇ | ||
∪ | 并集 | |
⋃ | 并集 | |
∩ | 交集 | |
⋂ | 交集 | |
⊎ | 多重集 | |
⨄ | 多重集 | |
⊏ | ||
⊐ | ||
⊓ | ||
⊑ | ||
⊒ | ||
∨ | ||
∧ | ||
∖ | 集合中的减法 |
逻辑运算
算式 | markdown | 描述 |
---|---|---|
∵ | 因为 | |
∴ | 所以 | |
∀ | 任意 | |
∃ | 存在 | |
∨ | 逻辑与 | |
∧ | 逻辑或 | |
⋁ | 逻辑与 | |
⋀ | 逻辑或 |
上下标符号
算式 | markdown |
---|---|
\(\bar{a}\) | |
\(\acute{a}\) | |
\(\breve{a}\) | |
\(\grave{a}\) | |
\(\dot{a}\) | |
\(\ddot{a}\) | |
\(\hat{a}\) | |
\(\check{a}\) | |
\(\vec{a}\) |
\(\overline{a+b+c+d}\) | |
---|---|
\(\underline{a+b+c+d}\) |
大写 | markdown | 小写 | markdown |
---|---|---|---|
A | α | ||
B | β | ||
Γ | γ | ||
Δ | δ | ||
E | ϵ | ||
ε | |||
Z | ζ | ||
H | η | ||
Θ | θ | ||
I | ι | ||
K | κ | ||
Λ | λ | ||
M | μ | ||
N | ν | ||
Ξ | ξ | ||
O | ο | ||
Π | π | ||
R | ρ | ||
Σ | σ | ||
T | τ | ||
Υ | υ | ||
Φ | ϕ | ||
φ | |||
X | χ | ||
Ψ | ψ | ||
Ω | ω |
其他符号
算式 | markdown |
---|---|
ℵ | |
ℏ | |
ı | |
ȷ | |
ℓ | |
℘ | |
ℜ | |
ℑ | |
℧ | |
∇ | |
√ | |
⊤ | |
⊥ | |
¬ | |
♭ | |
♮ | |
♯ | |
\ | |
∂ | |
□ | |
♣ | |
♢ | |
♡ | |
♠ |
空格
算式 | markdown | 描述 |
---|---|---|
123123 | 123!123 | 空格距离:-3/18 em |
123 123 | 123,123 | 空格距离:3/18 em |
123 123 | 123:123 | 空格距离:4/18 em |
123 123 | 123;123 | 空格距离:5/18 em |
123 123 | 123 | 空格距离:1 em |
123 123 | 123 | 空格距离:2 em |
箭头
算式 | markdown |
---|---|
↑ | |
↓ | |
↕ | |
⇑ | |
⇓ | |
⇕ | |
→ | |
← | |
↔︎ | |
⇒ | |
⇐ | |
⇔ | |
⟶ | |
⟵ | |
⟷ | |
⟹ | |
⟸ | |
⟺ | |
↦ | |
⟼ | |
↩︎ | |
↪ | |
⇀ | |
↽ | |
⇌ | |
↼ | |
⇁ | |
⇝ | |
↗ | |
↘ | |
↙ | |
↖ |
微积分
算式 | markdown | 描述 |
---|---|---|
′′ | 求导 | |
∫ | 积分 | |
∬ | 双重积分 | |
∭ | 三重积分 | |
∮ | 曲线积分 | |
∇ | 梯度 | |
\(\int_0^2 x^2 \mathrm{d} x\) | _0^2 x^2 x | 其他的积分符号类似 |
微分中的符号d 请使用 \mathrm{d} |
极限
算式 | markdown |
---|---|
lim | |
→ | |
∞ | |
limn→+∞ | _{n+}n |
让公式加大加粗:
\large\pmb
加粗:
\pmb{字母}