here’s how we use MyST admonitions; there are other ways, but these are stable and show up the same in both jlab and jbook, so...
just be wary to not insert a (sub)title inside an admonition, as it would not make it to the table of contents !
no title and no class¶
in its the simplest form, with no class nor shortcut: this is suboptimal
````{admonition}
with no title nor class
````
renders like this
with a title and no class¶
````{admonition} a title and no class
this is the same as with the `note` class
````
gives you this
a title and a class¶
there are a few predefined classes (see table below)
````{admonition} with a title and a class
:class: tip
the color and icon are inherited from the chosen class
````
which renders as
the menagerie of classes¶
there are some predefined types of admonition that are - see them also below
name | color | icon |
---|---|---|
tip | green | pen |
hint | green | bulb |
seealso | green | right arrow |
note | blue | circled i |
important | blue | lightning |
attention | yellow | megaphone |
caution | yellow | circled exclamation mark |
warning | yellow | triangled exclamation mark |
danger | red | circled exclamation mark |
error | red | circled x |
collapsible contents with the dropdown
class¶
just add the dropdown
class to create a collapsible contents
````{admonition} this is a collapsible section
:class: attention dropdown
the whole text goes here....
````
this is a collapsible section
Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
```python
we can add fenced code anywhere inside the admonition
# and that's why the 4 backticks, btw
import numpy as np
import pandas as pd
df = pd.read_csv("titanic.csv")
```
using raw HTML¶
for the record only, it should also be possible to do create collapsible using plain HTML with a <details>
tag
the visible part
and the rest of the message is just mentioned directly in the <details> tag
however do not use this as apparently this requires extra configuration...
start open¶
- add the
:open:
decoration in the admonition directive - jlab: to double-check, might work
- jb2: yes
this should be collapsible but should start open
and some text inside, and changed, to make sure
custom style¶
right in admonition¶
we have defined a CSS class custom
in _static/style.css
and let’s try to use it
in a div inside admonition¶
same but now we wrap the admo content within a div MyST tag