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
|
|
超链接(Links)#
Example |
Result |
---|---|
[Jupyter Book](https://jupyterbook.org)
|
|
[restructuredtext](./restructuredtext)
|
|
<https://jupyterbook.org>
|
列表(Lists)#
有序列表(Ordered list)#
Example |
Result |
---|---|
1. First item
2. Second item
1. First sub-item
|
|
1. First item
2. Second item
* First sub-item
|
|
无序列表(Unordered list)#
Example |
Result |
---|---|
* First item
* Second item
* First subitem
|
|
* First item
1. First subitem
2. Second subitem
|
|
表格(Tables)#
Note
通过给表格添加标题,能够让表格自动编号,如下Table 1 和 表 2。
Example |
Result |
||||||
---|---|---|---|---|---|---|---|
| Training | Validation |
| :------------ | -------------: |
| 0 | 5 |
| 13720 | 2744 |
|
|
||||||
```{list-table} My table title
:header-rows: 1
:name: example-table
* - Training
- Validation
* - 0
- 5
* - 13720
- 2744
```
|
|
||||||
```{list-table} This table title
:header-rows: 1
* - Training
- Validation
* - 0
- 5
* - 13720
- 2744
```
|
|
图片(Figures)#
Example |
Result |
---|---|
```{figure} ../_static/images/C-3PO_droid.png
:height: 150px
:name: figure-example
Here is my figure caption!
```
|
![]() Fig. 21 Here is my figure caption!# |
公式(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: |
代码高亮(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.
```
|
Note Notes require no arguments, so content can start here. |
```{warning} This is an example
of a warning directive.
```
|
Warning This is an example of a warning directive. |
```{tip} This is an example
of a tip directive.
```
|
Tip This is an example of a tip directive. |
```{caution} This is an example
of a caution directive.
```
|
Caution This is an example of a caution directive. |
```{attention} This is an example
of an attention directive.
```
|
Attention This is an example of an attention directive. |
```{danger} This is an example
of a danger directive.
```
|
Danger This is an example of a danger directive. |
```{error} This is an example
of an error directive.
```
|
Error This is an example of an error directive. |
```{hint} This is an example
of a hint directive.
```
|
Hint This is an example of a hint directive. |
```{important} This is an example
of an important directive.
```
|
Important This is an example of an important directive. |
脚注(Footnotes)#
Example |
Result |
---|---|
添加引用:This is a footnote reference.[^myref]
|
1Example for footnote definition.添加引用: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)#
参考 Sphinx Design。
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 语法#
参考 Sphinx Design。
Example |
Result |
---|---|
:::{dropdown} Here's my title
My note
:::
|
Here’s my titleMy note |
:::{admonition} Here's my title
:class: dropdown, warning
My note
:::
|
Here’s my title My note |
Tabs 语法#
参考 Sphinx Design。
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`
|
(target_header)=
## 标题(Headers)
|
|
{ref}`自定义显示文本 <target_header>`
|
(target_header)=
## 标题(Headers)
|
|
[Markdown 风格的引用](target_header)
|
(target_header)=
## 标题(Headers)
|
引用表格(Tables)#
Note
为了引用表格,你需要给表格添加 name
属性。
引用图像(Figures)#
Note
使用 numref
引用图像(Figures)将带有标号,使用 ref
则不带标号。
引用公式(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)#
Note
确保你已经新建了 references.bib
文件,点击查看文件
撰写格式。
Example |
Result |
---|---|
Generates a citation {cite}`perez2011python`.
|
Generates a citation [PGH11]. |
你可以用下面的 bibliography
指令添加参考文献目录。
```{bibliography}
:filter: docname in docnames
```