Markdown for Jupyter Notebook


Here below is a very small cheatsheet for some markdown for Jupyter Notebook. Are you working with Jupyter Notebook and do you need to document some of your Python code? Are you interested in knowing how to create headers, make text bold or create bulleted lists?

Here’s an article at Medium called Markdown for Jupyter notebooks cheatsheet by Inge Halilovic.

Headings

# title
## major headings
### subheadings
#### 4th level subheadings

Create Numbered Links to Document Sections

You want the user to be able to click on a link that jumps them to a section in your document. Perhaps you want to create something similar to a Table of Contents. How do you do that? Below is some markdown (not code).

1. [**First Part**](#1)
2. [**Another Section Here**](#2)

Later on in the document you will have a section that has a ‘1’ id in an anchor hyperlink.

<a id='1'></a>
# First Part

Hidden Text

You can create hidden portions of your markdown. The user simply need to click on some text that isn’t hidden to open up the hidden text. Here’s how.

<details>
  <summary><h5>CLICK TO SEE</h5></summary>

Why not try this or that?
</details>

Table of Contents

In your Jupyter Notebook you can create a table of contents. When the user clicks on an entry they jump to a section of the document. Suppose you have two sections, First Header and Second Header. Here is a screenshot of the table of contents. It’s markdown that has been Run..

Markdown for Jupyter Notebook

What does the markdown code look like? Double-click it to gain access to the “code behind”. Here is the code.

## Table of Contents:
* [First Bullet Header](#b1)
* [Second Bullet Header](#b2)

Below is a screenshot of what it really looks like in Jupyter Notebook.

Markdown for Jupyter Notebook

Down in your notebook there is a section with a header. Below is the code for that. The thing to notice is the id=b1. It must match the table of contents. Notice that the heading is ‘First Header” and that it does not match the entry in the table of contents “First Bullet Header”. It doesn’t have to. They can be different.

## First Header <a class="anchor" id="b1"></a>

Font Color

You can change the color of your heading fonts simply by using HTML code like the following. Notice the single hash for the heading.

# <font color='gold'>IMDB 2024 November 18</font>

If you want a gold colored horizontal line (rule), try the following code in your markdown.

<hr style="background-color:gold;height:2px">

Leave a comment

Your email address will not be published. Required fields are marked *