This page was generated from doc/subdir/gallery.ipynb. Interactive online version: Binder badge.

Creating Thumbnail Galleries

Inspired by Sphinx-Gallery, you can create thumbnail galleries from a list of Jupyter notebooks (or other Sphinx source files).

nbsphinx does not provide any gallery styles, but you can easily use the styles from Sphinx-Gallery by installing it:

python3 -m pip install sphinx-gallery --user

… and loading the styles in your conf.py with:

extensions = [
    'nbsphinx',
    'sphinx_gallery.load_style',
    # more extensions, if needed ...
]

You’ll need Sphinx-Gallery version 0.6 or higher.

However, you can also create your own CSS styles if you prefer (then you don’t need to install Sphinx-Gallery). You can load your CSS files with html_css_files.

You can create Thumbnail Galleries in reST Files and you can create galleries by adding the "nbsphinx-gallery" cell tag or metadata to notebooks, which is used just like the “nbsphinx-toctree” cell tag/metadata.

For possible options, see the toctree notebook.

Note

In LaTeX output this behaves just like toctree, i.e. no thumbnail gallery is shown, but the linked files are included in the document.

Like with toctree you should avoid adding content after a gallery (except other toctrees and galleries) because this content would appear in the LaTeX output after the content of all included source files, which is probably not what you want.

The following cell has the "nbsphinx-gallery" tag, which creates a thumbnail gallery. The first section title in that cell (if available) is used as "caption" (unless it’s given in the metadata).

The notebooks in the following gallery describe different ways how to select which images are used as thumbnails.

This is a thumbnail gallery: