Search code examples
pythonjupyter-notebookmarkdown

Is it possible to make a nested ordered list in a table of contents in Jupyter Notebook using markdown?


Is it possible to make a nested ordered list in a table of contents in Jupyter Notebook using markdown? I am converting python into .ipynb using this.

My python code:

# 1. hello
#    1.1 hello
#    1.2 hello
#        1.2.1 hello
# 1. hello
#    1. hello
#       1. hello

Here is my markdown cell:

1. hello<br>
   1.1 hello<br>
   1.2 hello<br>
       1.2.1 hello<br>
1. hello<br>
   1. hello<br>
      1. hello

When run it produces this:

enter image description here

How can I have the same effect of the second list but with numbers?


Solution

  • Apparently Markdown does not support this type of list. Here is a possible workaround (based on this post):

    Note that list items must be escaped with \ with the exception of the nested values. This seems to be required in the notebook but not in Stack Overflow.

    * 1\. hello
       * 1.1. hello
       * 1.2. hello
           * 1.2.1. hello
    * 2\. hello
       * 1\. hello
          * 1.1. hello
    

    Which produces this:

    • 1. hello
      • 1.1. hello
      • 1.2. hello
        • 1.2.1. hello
    • 2. hello
      • 1. hello
        • 1.1. hello