MyST-NB#

标题(Headers)#

Syntax

Example

# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6
# MyST Cheat Sheet

引用(Quote)#

Example

Result

> this is a quote

引用文本

列表(Lists)#

有序列表(Ordered list)#

Example

Result

1. First item
2. Second item
    1. First sub-item
  1. First item

  2. Second item

    1. First sub-item

1. First item
2. Second item
    * First sub-item
  1. First item

  2. Second item

    • First subitem

无序列表(Unordered list)#

Example

Result

* First item
* Second item
  * First subitem
  • First item

  • Second item

    • First subitem

* First item
  1. First subitem
  2. Second subitem
  • First item

    1. First subitem

    2. Second subitem

表格(Tables)#

备注

通过给表格添加标题,能够让表格自动编号,如下表 1 和 表 2。

Example

Result

|    Training   |   Validation   |
| :------------ | -------------: |
|        0      |        5       |
|     13720     |      2744      |

Training

Validation

0

5

13720

2744

```{list-table} My table title
:header-rows: 1
:name: example-table

* - Training
  - Validation
* - 0
  - 5
* - 13720
  - 2744
```
表 1 My table title#

Training

Validation

0

5

13720

2744

```{list-table} This table title
:header-rows: 1

* - Training
  - Validation
* - 0
  - 5
* - 13720
  - 2744
```
表 2 This table title#

Training

Validation

0

5

13720

2744

图片(Figures and images)#

备注

图片(Image)中不允许出现标题(Caption),但图像(Figure)可以

Example

Result

```{figure} ../_static/images/C-3PO_droid.png
:height: 150px
:name: figure-example

Here is my figure caption!
```
../_images/C-3PO_droid.png

图 22 Here is my figure caption!#

```{image} ../_static/images/C-3PO_droid.png
:height: 150px
:name: image-example
```
../_images/C-3PO_droid.png

公式(Math)#

Example

Result

This is an example of an
inline equation $z=\sqrt{x^2+y^2}$.

This is an example of an inline equation \(z=\sqrt{x^2+y^2}\).

This is an example of a
math block

$$
z=\sqrt{x^2+y^2}
$$

This is an example of a math block

\[ z=\sqrt{x^2+y^2} \]
This is an example of a
math block with a label

$$
z=\sqrt{x^2+y^2}
$$ (mylabel)

This is an example of a math block with a label

(4)#\[ z=\sqrt{x^2+y^2} \]
This is an example of a
math directive with a
label
```{math}
:label: eq-label

z=\sqrt{x^2+y^2}
```

This is an example of a math directive with a label

(5)#\[z=\sqrt{x^2+y^2}\]

代码(Code)#

行内代码(In-line code)#

Example

Result

In-line code blocks: `boolean example = true;`.

In-line code blocks: boolean example = true;.

代码高亮(Syntax highlighting)#

Example

Result

```{code-block} python
:emphasize-lines: 2

note = "Python syntax highlighting"
print(node)
```
note = "Python syntax highlighting"
print(node)

HTML 代码(HTML block)#

Example

Result

<p> This is a paragraph </p>

This is a paragraph

注解(Admonitions)#

Example

Result

```{admonition} This is a title
An example of an admonition with a title.
```

This is a title

An example of an admonition with a title.

```{note} Notes require **no** arguments,
so content can start here.
```

备注

Notes require no arguments, so content can start here.

```{warning} This is an example
of a warning directive.
```

警告

This is an example of a warning directive.

```{tip} This is an example
of a tip directive.
```

小技巧

This is an example of a tip directive.

```{caution} This is an example
of a caution directive.
```

小心

This is an example of a caution directive.

```{attention} This is an example
of an attention directive.
```

注意

This is an example of an attention directive.

```{danger} This is an example
of a danger directive.
```

危险

This is an example of a danger directive.

```{error} This is an example
of an error directive.
```

错误

This is an example of an error directive.

```{hint} This is an example
of a hint directive.
```

提示

This is an example of a hint directive.

```{important} This is an example
of an important directive.
```

重要

This is an example of an important directive.

脚注(Footnotes)#

1Example for footnote definition.

Example

Result

添加引用:This is a footnote reference.[^myref]

添加引用:This is a footnote reference.1Example for footnote definition.

添加注释:[^myref]: Example for footnote definition.

注释(Comment)#

Example

Result

a line
% a comment
another line

a line

another line

分隔线(Thematic break)#

Example

Note

This is the end of some text.

---

## New Header

创建水平分隔线

分隔块(Block break)#

Example

Result

This is an example of
+++ {"meta": "data"}
a block break

This is an example of

a block break

面包板(Pannels)#

Example

Result

:::{card} Card Title
Header
^^^
Card content
+++
Footer
:::

Header

Card Title

Card content

:::{card} Clickable Card (external)
:link: https://example.com

The entire card can be clicked to navigate to <https://example.com>.
:::
Clickable Card (external)

The entire card can be clicked to navigate to https://example.com.

Mermaid 语法#

Example

Result

:::{mermaid}
sequenceDiagram
    participant Alice
    participant Bob
    Alice->John: Hello John, how are you?
    loop Healthcheck
          John->John: Fight against hypochondria
    end
    Note right of John: Rational thoughts <br/>prevail...
    John-->Alice: Great!
    John->Bob: How about you?
    Bob-->John: Jolly good!
:::
sequenceDiagram participant Alice participant Bob Alice->John: Hello John, how are you? loop Healthcheck John->John: Fight against hypochondria end Note right of John: Rational thoughts <br/>prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good!

Toggle 语法#

Example

Result

:::{dropdown} Here's my title

My note
:::
Here’s my title

My note

:::{admonition} Here's my title
:class: dropdown, warning

My note
:::

Tabs 语法#

Example

Result

::::{tab-set}
:::{tab-item} Apples
Apples are green, or sometimes red.
:::
:::{tab-item} Pears
Pears are green.
:::
:::{tab-item} Oranges
Oranges are orange.
:::
::::

Apples are green, or sometimes red.

Pears are green.

Oranges are orange.

::::{tab-set}
:::{tab-item} Google
:sync: google
(1) Google is big company.
:::
:::{tab-item} Microsoft
:sync: microsoft
(1) Microsoft is one of my favorite companies.
:::
::::

(1) Google is big company.

(1) Microsoft is one of my favorite companies.

::::{tab-set}
:::{tab-item} Google
:sync: google
(2) Google is big company.
:::
:::{tab-item} Microsoft
:sync: microsoft
(2) Microsoft is one of my favorite companies.
:::
::::

(2) Google is big company.

(2) Microsoft is one of my favorite companies.

交叉引用(Cross reference)#

引用标题(Headers)#

Syntax

Example

Note

{ref}`target_header`

标题(Headers)

(target_header)=
## 标题(Headers)
{ref}`自定义显示文本 <target_header>`

自定义显示文本

(target_header)=
## 标题(Headers)
[Markdown 风格的引用](target_header)

Markdown 风格的引用

(target_header)=
## 标题(Headers)

引用表格(Tables)#

备注

为了引用表格,你需要给表格添加 name 属性。

Example

Result

{numref}`example-table` is an example.

表 1 is an example.

This {ref}`table <example-table>` is an example.

This table is an example.

{numref}`Tbl %s <example-table>` is an example.

Tbl 1 is an example.

引用图像(Figures)#

备注

使用 numref 引用图像(Figures)将带有标号,使用 ref 则不带标号。

Example

Result

{numref}`figure-example` is a figure example.

图 22 is a figure example.

{numref}`Figure %s <figure-example>` is an example.

Figure 22 is an example.

This {ref}`figure <figure-example>` is an example.

This figure is an example.

引用图片(Images)#

备注

图片(Images)无法使用 numref 引用,默认都不带标号。

Example

Result

This {ref}`image <image-example>`
is an example.

This image is an example.

引用公式(Math directives)#

Example

Result

Check out equation {eq}`eq-label`.

Check out equation (5).

引用文件(Documents)#

Example

Result

See {doc}`restructuredtext`
for more information.

See reStructuredText for more information.

See {doc}`here <restructuredtext>`
for more information.

See here for more information.

参考文献(Citations)#

备注

确保你已经新建了 references.bib 文件,点击查看文件撰写格式。

Example

Result

Generates a citation {cite}`perez2011python`.

Generates a citation [PGH11].

你可以用下面的 bibliography 指令添加参考文献目录。

```{bibliography}
:filter: docname in docnames
```