Markdown语法

(本文参考Markdown Tutorial)

1. 加粗与斜体

  • 斜体:在文本两侧加上一个星号或一个下划线,例如:
1
_unknown_或*unkown*

效果如下:unknown

  • 加粗:在文本两侧加上两个星号或两个下划线, 例如:
1
__unknown__或**unknown** 

效果如下:unknown

  • 注:斜体和加粗可以一起用,例如:
1
**_of course_**

效果如下:of course

2.标题(Headers)

在前面加#号, 一共有六级标题。一级标题为在前面加一个#号(# 一级标题),二级标题为在前面加两个#号(## 二级标题)。

1
2
3
4
5
6
7
# Header one
## Header two
### Header three
#### Header four
##### Header five
###### Header six
plain text
注:#号与文本之间有一个空格。

效果如下:

img

3.链接

  • inline link

语法如下:

1
[Visit GitHub!](www.github.com)

Visit GitHub!

再比如:

1
[You're **really, really** going to see this.](www.dailykitten.com)

You're really, really going to see this.

  • reference link

语法如下:

1
2
3
4
5
6
7
Do you want to [see something fun][a fun place]?  

Well, I have [a website for you][another fun place]!

[a fun place]: www.zombo.com

[another fun place]: www.stumbleupon.com

效果如下:
Do you want to see something fun?

Well, I have a website for you!

一般可将链接地址写在Markdown文件的最后。使用refrence的好处是如果有许多链接都是指向一个地方,那么需要更改的时候只需要修改一次就行了。

另外如果直接粘贴链接,有可能只是显示为文本没有显示为超链接,例如 https://daringfireball.net/projects/markdown 。可以在链接前后加上<>,例如:<https://daringfireball.net/projects/markdown/>,效果:https://daringfireball.net/projects/markdown/

4.图片

  • inline link

插入图片和插入链接类似,语法如下:

1
![A pretty tiger](https://upload.wikimedia.org/wikipedia/commons/5/56/Tiger.50.jpg)
A pretty tiger

注: 1. [ ]中的内容可以空着,当网络不好,图片无法显示时(或某些其它原因)会显示[ ]中的文字 2. !和[ ]之间不要加空格

  • reference link

语法如下:

1
2
3
4
5
6
7
![Black cat][Black]

![Orange cat][Orange]

[Black]: https://upload.wikimedia.org/wikipedia/commons/a/a3/81_INF_DIV_SSI.jpg

[Orange]:http://icons.iconarchive.com/icons/google/noto-emoji-animals-nature/256/22221-cat-icon.png
Black cat
Orange cat

另一种方法,使用html的写法:

1
<img src="http://icons.iconarchive.com/icons/google/noto-emoji-animals-nature/256/22221-cat-icon.png" alt="cat" />

cat

还可以更改图片大小:

1
<img src="xxx" alt="xxx" width="60%" height="60%"/>

5.Blockquotes

当想引用一段话并让读者注意到时,可以采用如下方法:在文本前加上">"

例如:

1
2
3
4
> "In a few moments he was barefoot, his stockings folded in his pockets and his
canvas shoes dangling by their knotted laces over his shoulders and, picking a
pointed salt-eaten stick out of the jetsam among the rocks, he clambered down
the slope of the breakwater."

效果如下:

"In a few moments he was barefoot, his stockings folded in his pockets and his canvas shoes dangling by their knotted laces over his shoulders and, picking a pointed salt-eaten stick out of the jetsam among the rocks, he clambered down the slope of the breakwater."

当引用多段话时,可以在每一部分前加上">",例如:

1
2
3
4
5
6
7
8
> His words seemed to have struck some deep chord in his own nature. Had he spoken
of himself, of himself as he was or wished to be? Stephen watched his face for some
moments in silence. A cold sadness was there. He had spoken of himself, of his own
loneliness which he feared.
>
> —Of whom are you speaking? Stephen asked at length.
>
> Cranly did not answer.

效果如下:

His words seemed to have struck some deep chord in his own nature. Had he spoken of himself, of himself as he was or wished to be? Stephen watched his face for some moments in silence. A cold sadness was there. He had spoken of himself, of his own loneliness which he feared.

—Of whom are you speaking? Stephen asked at length.

Cranly did not answer.

Note: even blank lines must contain the caret character. This ensures that the entire blockquote is grouped together.

6.列表(Lists)

* unordered list

在前面加星号:

1
2
3
4
* Milk  
* Eggs
* Salmon
* Butter

效果如下: * Milk * Eggs * Salmon * Butter

* odered list

在前面加数字

1
2
3
4
1. Crack three eggs over a bowl
2. Pour a gallon of milk into the bowl
3. Rub the salmon vigorously with butter
4. Drop the salmon into the egg-milk bowl

效果如下:

  1. Crack three eggs over a bowl
  2. Pour a gallon of milk into the bowl
  3. Rub the salmon vigorously with butter
  4. Drop the salmon into the egg-milk bowl
* nest one list within another
1
2
3
4
5
6
7
8
9
* Tintin
* A reporter
* Has poofy orange hair
* Friends with the world's most awesome dog
* Haddock
* A sea captain
* Has a fantastic beard
* Loves whiskey
* Possibly also scotch?
  • Tintin
  • A reporter
  • Has poofy orange hair
  • Friends with the world's most awesome dog
  • Haddock
  • A sea captain
  • Has a fantastic beard
  • Loves whiskey
    • Possibly also scotch?

建议最多建三层,否则文章结构会变得太混乱

7.段落

  • hard break
1
2
3
4
5
Do I contradict myself?

Very well then I contradict myself,

(I am large, I contain multitudes.)

想换行时,空一行。效果如下:

Do I contradict myself?

Very well then I contradict myself,

(I am large, I contain multitudes.)

  • soft break
1
2
3
Do I contradict myself?··
Very well then I contradict myself,··
(I am large, I contain multitudes.)

想换行时,打两个空格。上面每个点 ( · ) 代表一个空格。效果如下:

Do I contradict myself?
Very well then I contradict myself,
(I am large, I contain multitudes.)

8. LaTeX 数学表达式

在Markdown文档中,可以使用LaTex符号创建数学表达式。例如:

1
2
3
$$
y = \frac{a}{b+c}
$$

\[ y = \frac{a}{b+c} \]

(hexo中公式显示问题:在文章的Front-matter中加上:mathjax: true)

8.1 LaTeX 中 argmin, argmax 下标使用方法
1
2
3
$$
\mathop{\arg \min}_x f(x)
$$

\[ \mathop{\arg\min}_x f(x) \]

或:

1
2
3
$$
\mathop{\arg \min_x} f(x)
$$

\[ \mathop{\arg \min_x} f(x) \]

8.2 公式对齐
1
2
3
4
5
6
$$
\begin{aligned}
\nabla_\theta \log P(\tau|\theta)&=\nabla \log\rho_0(s_0)+\sum_{t=0}^T (\nabla_\theta\log P(s_{t+1}|s_t,a_t)+\nabla_\theta\log\pi_\theta(a_t|s_t))\\
&=\nabla_\theta\log\pi_\theta(a_t|s_t)
\end{aligned}
$$

\[\begin{aligned} \nabla_\theta \log P(\tau|\theta)&=\nabla \log\rho_0(s_0)+\sum_{t=0}^T (\nabla_\theta\log P(s_{t+1}|s_t,a_t)+\nabla_\theta\log\pi_\theta(a_t|s_t))\\ &=\nabla_\theta\log\pi_\theta(a_t|s_t) \end{aligned}\]

9.代码块

使用```将代码包围起来,如下所示:

img

效果:

1
2
3
4
import cv2 

# read images
img1 = cv2.imread('eiffel_2.jpeg')

如果想标注文件名:

img

效果:

keypoints_shape.py
1
2
3
4
import cv2 

# read images
img1 = cv2.imread('eiffel_2.jpeg')

10. Typora中,字体颜色

1
2
<span style='color:red'>This is red</span>
<span style="background:yellow">高亮黄色</span>

This is red

高亮黄色

11.表格宽度调整

参考 https://blog.csdn.net/maxsky/article/details/54666998

在原表格前添加 CSS 代码,类似如下(在Typora中启用源代码模式):

1
2
3
4
5
6
7
8
9
10
11
12
<style>
table th:first-of-type {
width: 220px;
}
table th:nth-of-type(2) {
width: 70px;
}
</style>

<!-- 下方是表格的 Markdown 语法 -->
名称|值|备注
---|---|---

这里需要一点 CSS 知识,选择器的问题,首先 <th> 存在于 <table> 中;其次 th:first-of-type 的意思是每个 <th> 为其父级的第一个元素,这里指的就是围绕着【名称】的 <th>。同理第二、三个使用 th:nth-of-type(2)th:nth-of-type(3) 就可以了,以此类推。上述的 th:first-of-type 等价于 th:nth-of-type(1)