Markdown for Jupyter notebooks cheatsheet

Ke Gui
5 min readJun 6, 2020

TL;DR:

  1. for numbered new lines
  2. * for bullets point

Here’s how to format Markdown cells in Jupyter notebooks:

HeadingsUse the number sign (#) followed by a blank space for notebook titles and section headings:

  • # for titles
  • ## for major headings
  • ### for subheadings
  • #### for 4th level subheadings

EmphasisUse the following code to emphasize text:

  • Bold text: __string__ or **string**
  • Italic text: _string_ or *string*

Mathematical symbolsSurround mathematical symbols with a dollar sign ($), for example:$ mathematical symbols $

Monospace fontSurround text with a grave accent (`) also called a back single quotation mark, for example:

`string`

You can use the monospace font for file paths, file names, message text that users see, or text that users enter.

Line breaksSometimes markdown doesn’t make line breaks when you want them. To force a linebreak, use the following code: <br>IndentingUse the greater than sign (>) followed by a space, for example:

> Text that will be indented when the Markdown is rendered.

Any subsequent text is indented until the next carriage return.

BulletsTo create a circular bullet point, use one of the following methods. Each bullet point must be on its own line.

  • A hyphen (-) followed by one or two spaces, for example: - Bulleted item
  • A space, a hyphen (-) and a space, for example: - Bulleted item
  • An asterisk (*) followed by one or two spaces, for example: * Bulleted item

To create a sub bullet, press Tab before entering the bullet point using one of the methods described above. For example:

- Main bullet point
- Sub bullet point

Numbered listsTo create a numbered list, enter 1. followed by a space, for example:

1. Numbered item
1. Numbered item

For simplicity, you use 1. before each entry. The list will be numbered correctly when you run the cell.

To create a substep, press Tab before entering the numbered item, for example:

1. Numbered item
1. Substep

Colored note boxesUse one of the following <div> tags to display text in a colored box.

RestrictionNot all Markdown code displays correctly within <div> tags, so review your colored boxes carefully.

For example, to make a word bold, surround it with the HTML code for bold (<b>text</b> instead of the Markdown code.

The color of the box is determined by the alert type that you specify:

  • Blue boxes (alert-info)
  • <div class="alert alert-block alert-info"> <b>Tip:</b> Use blue boxes (alert-info) for tips and notes. If it’s a note, you don’t have to include the word “Note”. </div>
  • Yellow boxes (alert-warning)
  • <div class="alert alert-block alert-warning"> <b>Example:</b> Use yellow boxes for examples that are not inside code cells, or use for mathematical formulas if needed. </div>
  • Green boxes (alert-success)
  • <div class="alert alert-block alert-success"> <b>Up to you:</b> Use green boxes sparingly, and only for some specific purpose that the other boxes can't cover. For example, if you have a lot of related content to link to, maybe you decide to use green boxes for related links from each section of a notebook. </div>
  • Red boxes (alert-danger)
  • <div class="alert alert-block alert-danger"> <b>Just don't:</b> In general, avoid the red boxes. These should only be used for actions that might cause data loss or another major issue. </div>

GraphicsYou can attach image files directly to a notebook in Markdown cells by dragging and dropping it into the cell.

To add images to other types of cells, you must use a graphic that is hosted on the web and use the following code to insert the graphic:

<img src="url.gif" alt="Alt text that describes the graphic" title="Title text" />

RestrictionYou cannot add captions to graphics.

Geometric shapesUse &# followed by the decimal or hex reference number for the shape, for example:

&#reference_number

For a list of reference numbers, see UTF-8 Geometric shapes.

Horizontal linesOn a new line, enter three asterisks:

***

Internal linksTo link to a section within your notebook, use the following code:

[Section title](#section-title)

For the text inside the parentheses, replace any spaces and special characters with a hyphen. For example, if your section is called Analyzing customer purchasing habits, you’d enter:

[Analyzing customer purchasing habits](#analyzing-customer-purchasing-habits)

Alternatively, you can add an ID above the section:

<a id="section_ID"></a>

ImportantEach ID in the notebook must be unique.

To link to a section that has an ID, use the following code:

[Section title](#section_ID)

ImportantTest all internal links to ensure that they work.

External linksTo link to an external site, use the following code:

__[link text](http://url)__

Surround the link with two underscores (_) on each side

ImportantTest all links to ensure that they work.

--

--

Ke Gui

An ordinary guy who wants to be the reason someone believes in the goodness of people. He is living at Brisbane, Australia, with a lovely backyard.