Project notebooks can be very long, which makes navigation tricky. It's also important to check spelling in projects, but there is no spell check in the default Jupyter Notebook setup. Extensions to the rescue! The Table of Contents (2) extension will add a table of contents based on notebook Markdown headings as a sidebar to your notebook. The spellchecker extension will highlight unrecognized words in Markdown cells. It will not check spelling in code cells, so make sure you still check the spelling in your code comments carefully.

Note that installing these extensions will apply to all notebooks you open - not just your DataCamp project notebook. Let's get started!

Install spellchecker and Table of Contents (2) extensions

Before you begin installing extensions, you will need to install JupyterLab if you have not already. Open your terminal and run the following. You may need to replace pip with pip3 depending on the version of Python you have installed.

pip install jupyter_contrib_nbextensions
pip install jupyter_nbextensions_configurator
jupyter contrib nbextension install --user
jupyter nbextension enable toc2/main
jupyter nbextension enable spellchecker/main

Double check that Jupyter has the extensions installed

Open a new notebook from your terminal using the jupyter notebook command. It should open a window like this one. Click on "Nbextensions" at the top of the screen.

You should now be on a page that looks like the below screenshot. Untick "disable configuration for nbextensions without explicit compatibility" at the very top, and make sure that Table of Contents (2) and spellchecker are checked. You can also add more extensions here if you like!

Customize your extensions

When you select an extension, it will be highlighted in dark blue. Scrolling down the page, you'll find options for configuring each extension.

For working with projects, we find it helpful to check the following options on Table of Contents (2), leaving everything else unchecked:

  • "Skip h1 headings from numbering, so that they can serve as a notebook title. See the README for details, caveats and alternatives"

  • "Display toc window/sidebar at startup"

  • "Display Table of Contents as a sidebar (otherwise as a floating window)"

  • "Mark toc item of header in viewport when scrolling"

  • "Widen the display area to fit the browser window (may be useful with sidebar option)"

  • "Display Table of Contents as a navigation menu"

  • "Move notebook's title and menu on the left instead of being centered -- This provides a better look when the toc/sidebar is present"

The above configuration will give you a Table of Contents in your project notebook that looks like this.

The spellchecker extension default options work well without any changes.

Of course, you should configure your Jupyter extensions however works best for you!

Did this answer your question?