7. MyST Markdown cheatsheet¶
Credits: This page is copied from the Jupyterbook Myst Cheatsheet
7.1. Headers¶
Syntax | Example | Note |
---|---|---|
Level 1-6 headings, denoted by number of |
7.2. Target headers¶
Syntax | Example | Note |
---|---|---|
See below how to reference target headers. |
7.2.1. Referencing target headers¶
Targets can be referenced with the ref inline role which uses the section title by default:
You can specify the text of the target:
Another alternative is to use Markdown syntax:
7.3. Quote¶
Syntax | Example | Note |
---|---|---|
quoted text |
7.4. Thematic break¶
Syntax | Example | Note |
---|---|---|
Creates a horizontal line in the output |
7.6. Block break¶
Syntax | Example | Result |
---|---|---|
This is an example of a block break |
7.7. HTML block¶
Syntax | Example | Result |
---|---|---|
This is a paragraph |
7.8. Links¶
Syntax | Example | Result |
---|---|---|
PDF documentation | ||
7.9. Lists¶
7.9.1. Ordered list¶
Example | Result |
---|---|
| |
|
7.9.2. Unordered list¶
Example | Result |
---|---|
| |
|
7.10. Tables¶
Syntax | Example | Result | ||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
| ||||||||
|
7.10.1. Referencing tables¶
Note
In order to reference a table you must add a label to it.
To add a label to your table simply include a :name:
parameter followed by the label of your table.
In order to add a numbered reference, you
must also include a table title. See example above.
Syntax | Example | Result |
---|---|---|
Table 7.1 is an example. | ||
This table is an example. | ||
Tbl 7.1 is an example. |
7.11. Admonitions¶
Syntax | Example | Result |
---|---|---|
This is a title An example of an admonition with a title. | ||
or | Note Notes require no arguments, so content can start here. | |
Warning This is an example of a warning directive. | ||
Tip This is an example of a tip directive. | ||
Caution This is an example of a caution directive. | ||
Attention This is an example of an attention directive. | ||
Danger This is an example of a danger directive. | ||
Error This is an example of an error directive. | ||
Hint This is an example of a hint directive. | ||
Important This is an example of an important directive. |
7.12. Figures and images¶
Syntax | Example | Result |
---|---|---|
![]() Fig. 7.29 Here is my figure caption!¶ | ||
![]() |
See ../content/figures and ../file-types/markdown for more information.
7.12.1. Referencing figures¶
Syntax | Example | Result |
---|---|---|
Fig. 7.29 is a figure example. | ||
Figure 7.29 is an example. | ||
This figure is an example. |
7.13. Math¶
Syntax | Example | Result |
---|---|---|
Inline | This is an example of an inline equation z=√x2+y2. | |
Math blocks | This is an example of a math block
z=√x2+y2 | |
Math blocks with labels | This is an example of a math block with a label (7.1)¶z=√x2+y2 | |
Math directives | This is an example of a math directive with a label (7.2)¶z=√x2+y2 |
See ../content/math for more information.
7.14. Code¶
7.14.1. In-line code¶
Example:
Result:
Wrap in-line code blocks in backticks: boolean example = true;
.
7.14.3. Executable code¶
Warning
Make sure to include this front-matter YAML block at the beginning of your .ipynb
or .md
files.
Example:
Result:
See ../file-types/myst-notebooks for more information.
7.14.4. Gluing variables¶
Example:
Result:
Here is an example of how to glue text:
See glue/gluing for more information.
7.14.5. Gluing numbers¶
Example:
```{code-cell} ipython3
from myst_nb import glue
import numpy as np
import pandas as pd
ss = pd.Series(np.random.randn(4))
ns = pd.Series(np.random.randn(100))
glue("ss_mean", ss.mean())
glue("ns_mean", ns.mean(), display=False)
```
Here is an example of how to glue numbers: {glue:}`ss_mean` and {glue:}`ns_mean`.
Result:
Here is an example of how to glue numbers: and .
See glue/gluing for more information.
7.14.6. Gluing visualizations¶
Example:
```{code-cell} ipython3
from myst_nb import glue
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 200)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y, 'b-', linewidth=2)
glue("glued_fig", fig, display=False)
```
This is an inline glue example of a figure: {glue:}`glued_fig`.
This is an example of pasting a glued output as a block:
```{glue:} glued_fig
```
Result:
This is an inline glue example of a figure: . This is an example of pasting a glued output as a block:
See glue/gluing for more information.
7.15. Reference documents¶
Syntax | Example | Result |
---|---|---|
See ../content/citations for more information. | ||
See here for more information. |
7.16. Footnotes¶
Syntax | Example | Result |
---|---|---|
This is a footnote reference.1 |
See Footnotes for more information.
7.17. Citations¶
Note
Make sure you have a reference bibtex file. You can create one by:
running
touch bibliography-faircookbook.bib
Syntax | Example | Result |
---|---|---|
This example generates the following citation [GHRSS20]. |
To include a list of citations mentioned in the document, introduce the bibliography
directive
- GHRSS20
W. Gu, S. Hasan, P. Rocca-Serra, and V. P. Satagopam. Road to effective data curation for translational research. Drug Discov Today, Dec 2020.
- 1
This is the footnote definition.