⚠️The latest release refactored our HTML, so double-check your custom CSS rules!⚠️

Special content blocks#

There are a few content blocks that are unique to this theme.

Quotations and epigraphs#

Here is what quotations and epigraphs look like in sphinx-book-theme:

Default markdown quotes

> Here's my quote, it's pretty neat.
> I wonder how many lines I can create with
> a single stream-of-consciousness quote.
> I could try to add a list of ideas to talk about.
> I suppose I could just keep going on forever,
> but I'll stop here.

Here’s my quote, it’s pretty neat. I wonder how many lines I can create with a single stream-of-consciousness quote. I could try to add a list of ideas to talk about. I suppose I could just keep going on forever, but I’ll stop here.

Sometimes you’d like to draw more attention to a quote. To do so, use the {epigraph} directive. Below is an epigraph, click the button to the right of it to show the code that was used to generate it:

A basic epigraph

```{epigraph}
Here's my quote, it's pretty neat.
I wonder how many lines I can create with
a single stream-of-consciousness quote.
I could try to add a list of ideas to talk about.
I suppose I could just keep going on forever,
but I'll stop here.
```

Here’s my quote, it’s pretty neat. I wonder how many lines I can create with a single stream-of-consciousness quote. I could try to add a list of ideas to talk about. I suppose I could just keep going on forever, but I’ll stop here.

You can also add an attribution to epigraphs by adding a blank line, followed by a line that starts with --. This will be rendered like so:

Epigraphs with attribution

```{epigraph}
Here's my quote, it's pretty neat.
I wonder how many lines I can create with
a single stream-of-consciousness quote.
I could try to add a list of ideas to talk about.
I suppose I could just keep going on forever,
but I'll stop here.

-- Jo the Jovyan, *[the jupyter book docs](https://jupyterbook.org)*
```

Here’s my quote, it’s pretty neat. I wonder how many lines I can create with a single stream-of-consciousness quote. I could try to add a list of ideas to talk about. I suppose I could just keep going on forever, but I’ll stop here.

—Jo the Jovyan, the jupyter book docs

Sidenotes and marginnotes#

This theme has support for Tufte-style margin / side notes, with a UX similar to pandoc-sidenote.

Sidenotes are numbered, and behave like footnotes, except they live in the margin and don’t force the reader to jump their eye to the bottom of the page. For example, here is a sidenote1Here’s my sidenote text!. On narrow screens, sidenotes are hidden until a user clicks the number. If you’re on a mobile device, try clicking the sidenote number above.

Marginnotes are not numbered, but behave the same way as sidenotes. On mobile devices you’ll see a symbol that will show the marginnote when clicked This is a margin note. Notice there isn’t a number preceding the note.. For example, there’s a marginnote in the previous sentence, and you should see a symbol show to display it on mobile screens.

See also

Sidenotes and marginnotes are inline content - you cannot use block-level content inside of these notes. If you’d like to use block-level content in the margins, see Block margin content with the {margin} directive.

Activate sidenotes and marginnotes#

The theme activates sidenotes and marginnotes by over-riding footnote syntax to instead exist in the margin.

To convert your footnotes to instead be sidenotes/marginnotes, use this configuration:

html_theme_options = {
  ...
  "use_sidenotes": True,
  ...
}

This will turn your footnotes into sidenotes or marginnotes.

Create a sidenote#

The following sentence defines a sidenote and its respective content:

3And here’s my sidenote content.

Result

Here’s my sentence and a sidenote3And here’s my sidenote content..

Source

Here's my sentence and a sidenote[^sn1].

[^sn1]: And here's my sidenote content.

Create a marginnote#

Marginnotes are defined by adding {-} at the beginning of the content block. The following syntax defines a marginnote:

And here’s my marginnote content.

Result

Here’s my sentence and a marginnote And here’s my marginnote content..

Source

Here's my sentence and a marginnote[^mn1].

[^mn1]: {-} And here's my marginnote content.

Block margin content with the {margin} directive#

The {margin} directive allows you to create block-level margin content with an optional title. It is a wrapper around the Sphinx {sidebar} directive, and largely does its magic via CSS classes (see below).

See also

If you’d like in-line margin content with numbered references, see Sidenotes and marginnotes.

Here’s how you can use the {margin} directive:

Result

Source

```{margin} **Here is my margin content**
It is pretty cool!
```

Figure captions in the margin#

You can configure figures to use the margin for captions. Here is a figure with a caption to the right.

Source

```{figure} ../images/cool.jpg
---
width: 60%
figclass: margin-caption
alt: My figure text
name: myfig5
---
And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-).
```

Result

My figure text

Fig. 1 And here is my figure caption, if you look to the left, you can see that COOL is in big red letters. But you probably already noticed that, really I am just taking up space to see how the margin caption looks like when it is really long :-).#

We can reference the figure with this reference. Or a numbered reference like Fig. 1.

CSS classes for custom margin content#

You may also directly add CSS classes to elements on your page in order to make them behave like margin content. To do so, add the margin CSS class to any element on the page. Many Sphinx directives allow you to directly add classes. For example, here’s the syntax to add a margin class to a {note} directive:

Result

Note

This note will be in the margin!

Source

:::{note}
:class: margin
This note will be in the margin!
:::

This works for most elements on the page, but in general this works best for “parent containers” that are the top-most element of a bundle of content. For example, you can also put the whole figure in the margin if you like. Here is a figure with a caption below. We’ll add a note below to create some vertical space to see better.

Result

My figure text

Fig. 2 And here is my figure caption#

Source

```{figure} ../images/cool.jpg
---
figclass: margin
alt: My figure text
name: myfig4
---
And here is my figure caption
```

We can reference the figure with And here is my figure caption. Or a numbered reference like Fig. 2.

Content examples in the margin#

Margin content can include all kinds of things, such as code blocks:


`````{example} Admonitions and images in the margin
:no-container:
:reverse:

````{margin} **Notes in margins**
```{note}
Wow, a note with an image in a margin!
![](../images/cool.jpg)
```
````

Full-width content#

Full-width content extends into the right margin, making it stand out against the rest of your book’s content. To add full-width content to your page, add the class full-width to any of the elements in your documentation. For example, you can add a full-width tag to a note element like this:

Source

```{note}
:class: full-width
This content will be full-width
```

Result

Note

This content will be full-width

A note for ipynb users

If you are using a Jupyter Notebook as inputs to your documentation using the MyST-NB extension, you can trigger this behavior with a code cell by adding a full-width tag to the cell.