{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Custom CSS\n", "\n", "If you are not satisfied with the CSS styles\n", "provided by `nbsphinx`\n", "and by your Sphinx theme,\n", "don't worry,\n", "you can add your own styles easily." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## For All Pages\n", "\n", "Just create your own CSS file, e.g. `my-own-style.css`,\n", "and put it into the `_static/` sub-directory\n", "of your source directory.\n", "\n", "You'll also have to set the config values\n", "[html_static_path](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path)\n", "and\n", "[html_css_files](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files)\n", "in your `conf.py`, e.g. like this:\n", "\n", "```python\n", "html_static_path = ['_static']\n", "html_css_files = ['my-own-style.css']\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## For All RST files\n", "\n", "If you want your style to only apply to `*.rst` files\n", "(and not Jupyter notebooks or other source files),\n", "you can use\n", "[rst_prolog](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_prolog)\n", "with the\n", "[raw](https://docutils.sourceforge.io/docs/ref/rst/directives.html#raw-data-pass-through)\n", "directive in your `conf.py` like this:\n", "\n", "```python\n", "rst_prolog = \"\"\"\n", ".. raw:: html\n", "\n", " \n", "\"\"\"\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## For All Notebooks\n", "\n", "Similarly,\n", "if you want your style to only apply to notebooks,\n", "you can use [nbsphinx_prolog](prolog-and-epilog.ipynb)\n", "like this:\n", "\n", "```python\n", "nbsphinx_prolog = \"\"\"\n", ".. raw:: html\n", "\n", " \n", "\"\"\"\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## For a Single Notebook\n", "\n", "For styles that should affect only the current notebook,\n", "you can simply insert ` \n", "```\n", "\n", "\n", "\n", "This CSS example removes the input and output prompts\n", "from code cells,\n", "see the following cell:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "6 * 7" ] } ], "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 }