{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "This notebook is part of the `nbsphinx` documentation: https://nbsphinx.readthedocs.io/." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating Thumbnail Galleries\n", "\n", "Inspired by [Sphinx-Gallery](https://sphinx-gallery.github.io/),\n", "you can create thumbnail galleries from a list of Jupyter notebooks\n", "(or other Sphinx source files).\n", "\n", "`nbsphinx` does *not* provide any gallery styles,\n", "but you can easily use the styles from Sphinx-Gallery\n", "by installing it:\n", "\n", " python3 -m pip install sphinx-gallery\n", "\n", "... and loading the styles in your `conf.py` with:\n", "\n", "```python\n", "extensions = [\n", " 'nbsphinx',\n", " 'sphinx_gallery.load_style',\n", " # more extensions, if needed ...\n", "]\n", "```\n", "\n", "You'll need Sphinx-Gallery version 0.6 or higher.\n", "\n", "However, you can also create your own CSS styles if you prefer\n", "(then you don't need to install Sphinx-Gallery).\n", "You can load your CSS files with\n", "[html_css_files](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files).\n", "\n", "You can create\n", "[Thumbnail Galleries in reST Files](../a-normal-rst-file.rst#thumbnail-galleries)\n", "and you can create galleries by adding the `\"nbsphinx-gallery\"`\n", "cell tag or metadata to notebooks,\n", "which is used just like the\n", "[\"nbsphinx-toctree\"](toctree.ipynb) cell tag/metadata.\n", "\n", "For possible options, see the [toctree](toctree.ipynb) notebook.\n", "\n", "
\n", "\n", "Note\n", "\n", "In LaTeX output this behaves just like ``toctree``,\n", "i.e. no thumbnail gallery is shown,\n", "but the linked files are included in the document.\n", "\n", "Like with ``toctree`` you should avoid adding content\n", "after a gallery (except other toctrees and galleries)\n", "because this content would appear in the LaTeX output\n", "*after* the content of all included source files,\n", "which is probably not what you want.\n", "\n", "
\n", "\n", "The following cell has the `\"nbsphinx-gallery\"` tag,\n", "which creates a thumbnail gallery.\n", "The *first* section title in that cell (if available)\n", "is used as `\"caption\"` (unless it's given in the metadata).\n", "\n", "The notebooks in the following gallery describe different ways\n", "how to select which images are used as thumbnails." ] }, { "cell_type": "markdown", "metadata": { "tags": [ "nbsphinx-gallery" ] }, "source": [ "This section title will be used as ``:caption:``:\n", "\n", "## This is a thumbnail gallery:\n", "\n", "This line will be ignored.\n", "\n", "* [Using a Cell Tag to Select a Thumbnail](../gallery/cell-tag.ipynb)\n", "* [Using Cell Metadata to Select a Thumbnail](../gallery/cell-metadata.ipynb)\n", "* [Choosing from Multiple Outputs](../gallery/multiple-outputs.ipynb)\n", "* [No Thumbnail Available](../gallery/no-thumbnail.ipynb)\n", "* [Specifying a Thumbnail File](../gallery/thumbnail-from-conf-py.ipynb)\n", "\n", "## This section title will be ignored\n", "\n", "... because only the first title in this cell is used." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" } }, "nbformat": 4, "nbformat_minor": 4 }