Search code examples
jupyter-notebookmarkdownjupyter

Nested numbered list do not break line in Jupyter Notebook Markdown


I'm trying to create a nested numbered list within a Jupyter Notebook Markdown cell for use as a table of contents which links to titles in the document. However the items in the list which should be nested/indented just appear on the same line when the cell has been executed.

I have tried using four spaces before the numbers I want indenting (which is what I've seen people suggesting). This didn't work so I also tried 1-3 spaces and using a tab but none seem to work. Thought it may be an issue with the numbering itself and the use of fullstops (i.e. "1." and "1.1" , and not "1.1." etc), but this doesn't fix the issue either.

The indent does work if i use an asterisk in place of 1.1, 1.2 etc., but this is not the format I want.

Markdown code example:

1. [Intro](#intro)
    1.1 [Part A](#pA)
    1.2 [Part B](#pB)
    1.3 [Part C](#pC)
2. [Main](#main)

This code outputs:

1. Intro 1.1 Part A 1.2 Part B 1.3 Part C
2. Main

Desired output:

1. Intro 
    1.1 Part A 
    1.2 Part B 
    1.3 Part C
2. Main

Solution

  • You need to add one of the following:

    • two white spaces at the end of each line, or
    • a <br> tag at the end of each line.

    for instance:

    1. [Intro](#intro)<br>
        1.1 [Part A](#pA)<br>
        1.2 [Part B](#pB)<br>
        1.3 [Part C](#pC)<br>
    2. [Main](#main)<br>