Below is a set of frequently used markdown commands for Jupyter Book 2 made with MyST. A good practice is to download the source file by clicking the download icon at the top right of this page and inspect the code.
Book structure¶
We can distinguish between two structures: that of the book’s content (a collection of different documents), and the (internal) structure of the chapters which consists of content structured in sections and subsections.
Table of Contents¶
In the myst.yml
file, you can specify the structure of the book as shown in Program 1.
Here you can indicate which files belong to the book and in what order.
You can also create dropdown menus in your ToC by including children
When not specifying a ToC, all files are automatically included in alphabetical order.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
- file: index.md # the landing page - file: content/1_intro.md - file: content/2_jup_nb.ipynb - file: content/3_cheat_sheet.md - file: content/lessons/your_turn.md # dropdown menu children: - file: content/lessons/0_headstart.md - file: content/lessons/1_firstedit.md - file: content/lessons/2_nextstep.md children: - file: content/lessons/2a_plugins.md - file: content/lessons/3_interactive.ipynb # - file: content/lessons/4_styling.md - file: content/lessons/5_GHworkflow.md - file: content/lessons/6_pdfoutput.md - file: content/advanced_start.md - file: content/software.md
Program 1:The Table of Contents (ToC) for this book.
If you have specified a ToC and create a new file, you’ll need to add it to the myst.yml
file to include it in the book.
Headings¶
To make sections within a page, use a number of #
symbols at the beginning of a line.
The more #
s increases the level of the heading.
# Heading level 1
## Heading level 2
### Heading level 3
Typically, a page only has a single level 1 heading, the page’s title and higher level headings are used for sections and subsections.
Basic Formatting¶
Markdown is a markup language where text formatting is done with small pieces of code (just like HTML). This is a table with some frequently used formatting options.
Element | Syntax | Example |
---|---|---|
Bold | **bold text** | Bold |
Italic | *italics* | Italics |
Emphasis | ***emphasis*** | emphasis |
Inline Formula | $F = m \cdot a$ | |
Footnote | - A footnote reference[^myref] [^myref]: This is an auto-numbered footnote definition. | - A footnote reference[1] |
You can create a new line by either a hard enter and a blank line, a \
at the end of the line and enter, or two spaces at the end of the line.
New Lines¶
Generally, in markdown, a single hard enter does not create a new line. You need to use one of the options below.
A new line with double space.
A new line with a \
.
A new line with a hard enter and blank line.
No new line with just a hard enter and text on the next line. Like this
Markdown syntax
A new line with double space.
A new line with a `\`.\
A new line with a hard enter and blank line.
No new line with just a hard enter and text on the next line.
Like this
Mathematics and equations¶
For STEM subjects, mathematical equations and symbol are essential. You can include equations in JupyterBooks using the LaTeX syntax for mathematics.
Labelled equations using double dollars, such as (1), can be referenced.
Markdown syntax
$$ F_{\mathrm{res}} = m \cdot a$$ (eq:Newton)
But you can also write inline equations with single dollars.
Markdown syntax
$s=v_{\mathrm{avg}}t$
Some examples of the notation
Name | Syntax | Output |
---|---|---|
Greek script | \Delta \lambda | |
root | \sqrt{4} | |
superscript/power | x^{2a} | |
fraction | \frac{2}{3} | |
subscript | x_{\mathrm{avg}} | |
multiply | a \cdot b | |
derivative | \frac{\Delta f}{\Delta t} | |
integral | \int_a^b f(x) \mathrm{d}x | |
sine | \sin(x) |
You can read about more of the LaTeX mathematics syntax in the LaTeX wikibook
Lists¶
Ordered lists¶
Ordered lists can be made with automatically numbered items.
item 1
item 2.
item 3.
Markdown syntax
1. item 1
1. item 2.
1. item 3.
Or you can manually number the items
item 1
item 2.
item 3.
Markdown syntax
1. item 1
2. item 2.
3. item 3.
Unordered lists¶
Unordered lists use -
or *
for each item.
a
b
c
Markdown syntax
- a
- b
- c
Checklists¶
You can also create checklists. The checks are interactive, you can tick or untick them.
Create a markdown cheat sheet
Publish online
Let others test
Markdown syntax
- [x] Create a markdown cheat sheet
- [x] Publish online
- [ ] Let others test
Tables¶
Tables are created with the separator |
Header 1 | Header 2 | Header 3 |
---|---|---|
text 1 | text 2 | text 3 |
text 4 | text 5 | text 6 |
Markdown syntax
|Header 1|Header 2|Header 3|
|---|---|---|
|text 1|text 2|text 3|
|text 4|text 5|text 6|
Or via …
Table 1:Overview of sanctions for certain behavior
Behavior
|
---|
Not (timely or with a valid reason) deregistered
|
Markdown syntax
```{list-table} Overview of sanctions for certain behavior
:header-rows: 1
:name: tl_sanctions
* - Behavior
- Sanction for 1st time
- Sanction for 2nd time
* - Not (timely or with a valid reason) deregistered
- A penalty
- exclusion
```
Method 2 has the advantage of allowing references to Table 1
Blocks¶
Tabs¶
Text in tab 1
Text in tab 2
Markdown syntax
::::{tab-set}
:::{tab-item} Tab 1
Text in tab 1
:::
:::{tab-item} Tab 2
Text in tab 2
:::
::::
Cards¶
header
With some text
Markdown syntax
```{card} Title
:header: header
:footer: footer
With some text
```
Grids¶
Cards can be arranged side by side, with the number of cards shown adapting to different screen sizes from small to large.
And cool text
Without cool text
Markdown syntax
:::{grid} 1 1 2 2
```{card} With a nice header
And cool text
```
```{card} Also with a nice header
Without cool text
```
:::
Admonitions¶
You can add special blocks that are highlighted in the text. See, for example, the warning below.
This is a warning without icon
Here is a warning
Markdown syntax
```{warning} This is a warning without icon
:class: dropdown
:open: true
:icon: false
Here is a warning
```
There are different variants such as:
tip
admonition
warning
note
objective
Using plugins you can add your own custom admonitions:
Exercises¶
A special case is the exercises which can be labelled and can come with a solution that is linked to the exercise:
Solution to Exercise 1
6
Markdown syntax
```{exercise} Exercise 1
:label: ex_opdr_1
Calculate $4+2$
```
```{solution} ex_opdr_1
:class: dropdown
6
```
Figures¶
A site/book naturally needs figures. There are roughly two ways to add a figure:
Quick figure, without formatting options

Better way with more control:

Figure 1:With a nice caption
Markdown syntax
```{figure} https://github.com/rowanc1/pics/blob/main/sunset.png
:label: fig_sunset
:width: 70%
:align: center
With a nice caption
```
Here we used figures hosted online, but you can also add figures to a folder (e.g., called figures
), and then use a relative path (e.g. ../figures/sunset.png
).
YouTube¶
To embed YouTube videos on the site, you need the embed YT link. The code is then:
A super fun video from the project Show the Physics
Markdown syntax
```{iframe} https://www.youtube.com/embed/YDBr1Lof_mI?si=thWYK9MFi5QJv-tW
:width: 80%
:align: center
A super fun video from the project [Show the Physics](https://interactivetextbooks.tudelft.nl/showthephysics)
```
References & Links¶
You can included links like this. With the markdown syntax: [text](link)
.
Below a few examples of links and references to labeled items.
This is a hyperlink
This is a reference to equation (1)
This is a reference to a table like Table 1
This is a reference to a figure like Figure 1
Markdown syntax
* This is a [hyperlink](https://nos.nl)
* This is a reference to equation {eq}`eq:Newton`
* This is a reference to a table like {numref}`Table {number} <tl_sanctions>`
* This is a reference to a figure like {numref}`Figure {number} <fig_sunset>`
Cite¶
It also possible by including the DOI:
Pols (2021) (syntax:
[](https://doi.org/10.1088/1361-6552/abf208)
)Pols, 2021 (syntax:
[@doi:10.1088/1361-6552/abf208]
)
and even to specific pages of a book
Feynman et al., 1965, p. 750. (syntax:
[@feynman1965feynman, p. 750]
)Feynman et al. (1965, p. 750) (syntax:
@feynman1965feynman [p. 750]
)
Note that for the latter references, we made use of the reference.bib
file which is located at root
.
This is an auto-numbered footnote definition.
- Pols, F. (2021). What’s inside the pink box? A nature of science activity for teachers and students. Physics Education, 56(4), 045004. 10.1088/1361-6552/abf208
- Feynman, R. P., Leighton, R. B., Sands, M., & Hafner, E. M. (1965). The feynman lectures on physics; vol. i. American Journal of Physics, 33(9), 750–752.