To create a table of content (TOC) in a signal notebook and a TOC for multiple notebooks
It is very important to create a table of contents (TOC) in the Jupyter Notebook, which help us organize the contents, and provide us links to its sections or chapters and allow us to access them easily.
1. TOC Structure
A TOC is normally either an ordered list or unordered list, which is comprised by the title of the chapters or/and sections and their IDs. The structures look something as follows:
2.1 Ordered-list structure
1. [Title 1](#ID1)
1.1.[Subtitle 1.1](#ID1.1)
1.2.[Subtitle 1.2](#ID1.2)
2. [Title 2](#ID2)
2.1.[Subtitle 2.1](#ID2.1)
2.2.[Subtitle 2.2](#ID2.2)
3. [Title 3](#ID3)
4. [Title 4](#ID4)
The output looks as follows:
2.2 Unordered-list structure
- [Title 1](#ID1)
- [Subtitle 1.1](#ID1.1)
- [Subtitle 1.2](#ID1.2)
- [Title 2](#ID2)
- [Subtitle 2.1](#ID2.1)
- [Subtitle 2.2](#ID2.2)
- [Title 3](#ID3)
- [Title 1](#ID4)
The output looks as follows:
2. TOC of a Single Notebook
A TOC inside a single notebook is very helpful for us to organize the sections and to access them by links.
2.1. TOC Structure of One Notebook
To create TOC, we can use the following structure:
## Table of Contents
[title of the section](#title-of-the-section)
There is no space between harsh(#)
, words and hyphens(-) in the round brackets, or it causes link fails to the sections.
2.2. TOC Example 1
Suppose we have this post in a Jupyter notebook, and now we create a TOC for some sections, for example.
## Table of Content
1. [TOC Structure](#1.-TOC-Structure)
2. [TOC of One Notebook](#2.-TOC-of-One-Notebook)
2.1 [TOC Layout of One Notebook](#2.1.-TOC-Structure-of-One-Notebook)
2.2 [TOC Example 1](#2.2.-TOC-Example-1)
3. [TOC of Multi Notebooks](#3.-TOC-of-Multi-Notebooks)
3.1. [TOC Structure of Multi Notebooks](#3.1.-TOC-Structure-of-Multi-Notebooks)
3.2. [TOC Example 2](#3.2.-TOC-Example-2)
The rendered output looks as follows:
When you click a section header of the TOC, it will skip to that section. If it fails to link the section, you should
- first, please double-check if there is any space between harsh(#), words and hyphens(-) in the round brackets.
- If it still does not work, then go to the section titles to check if there is any extra space between the session numbers and the words, for example, between 2.1 and TOC Structure of One Notebook, where there should be only a single space.
3. TOC of Multi Notebooks
Creating a TOC Jupyter notebook for multiple notebooks is very convenient to manage and access the notebooks.
3.1. TOC Structure of Multi Notebooks
## Table of Contents
[Title of the Chapter](the path of a notebook)
3.2. TOC Example 2
Suppose we have multiple notebooks in the working directory. In this example, I have some lesson files created with the Jupyter notebook in the working directory.
## Table of Contents
### [Lesson 21: Basic Plotting with Matplotlib in Jupyter Notebook](./21.basic_plot.ipynb)
### [Lesson 22: Interactive Plots in Jupyter Notebook](./22.interactive_plot.ipynb)
### [Lesson 23: Interactive Widgets for Plots in Jupyter Notebook](./23.interactive_plot_widget.ipynb)
The result looks as follows:
When you click a lesson title in the TOC, it will open the Jupyter notebook of that lesson.
4. Video Tutorial
If you are interested in a video tutorial, please watch the tutorial on YouTube.
5. Online course
If you are interested in learning Jupyter notebook in details, you are welcome to enroll one of my course Practical Jupyter Notebook from Beginner to Expert.