23

I am using the Jupyter extension in Visual Studio Code to maintain a notebook on python programming and I want to add a table of contents inside it. I want to add the TOC as the notebook is becoming very big and is becoming difficult to navigate.

I write a heading in markdown files using # to structure them properly. I have also seen how to do it on Jupyter Notebook both by using hyperlinks and built-in feature.

Is the feature not available in case of Jupyter extension in VS?

screenshot for the problem

Scarabee
  • 5,437
  • 5
  • 29
  • 55
Avishek Roy
  • 341
  • 1
  • 2
  • 5
  • Which extension have you installed? And have you installed the Python extension? Could you provide a picture of the extension you have installed? – Steven-MSFT Jun 15 '21 at 02:31
  • hey Steven, I am using the official microsoft jupyter extenstions. Check out this link https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter – Avishek Roy Jun 15 '21 at 05:41

2 Answers2

42

I'm a developer on this extension. VS Code has an existing "outline" feature for code editing. This feature is being reused in notebooks for holding ToC navigation. On your left side panel it's "> Outline" below your open files. It should populate with markdown headings and be able to navigate to them. Like so: enter image description here

Ian Huff
  • 2,699
  • 1
  • 17
  • 17
  • 2
    Hey Ian thanks a ton!!! This solves 50% of my problem, is there any way I could use the outline feature to create a markdown of my own to add to the notebook so that when I upload it to github it could be used by others too. Thanks – Avishek Roy Jun 16 '21 at 15:47
  • Sorry I might not totally understand the request here. So the outline feature just reflects the markdown headings that it detects in the ipynb file. So the best way to have an outline that works both in VS Code and in Jupyter notebooks (if others are using the same notebook) is just to author your layout in markdown cells in the document. Were you looking for a way to add this structure directly from the outline window? – Ian Huff Jun 16 '21 at 16:52
  • 2
    Yes I was looking to create the same feature in the 'outline' as a markdown cell. So if someone were to open the notebook they would be able to navigate though the markdown cells. I presume that this is not possible in VS code. Jupyter Notebook has this feature - [Check this out](https://www.youtube.com/watch?v=YREIn1uTYO0) – Avishek Roy Jun 17 '21 at 09:53
  • I think the best step to request that would be on our github repo. You could log a feature request outlining how you would like it to work there: https://github.com/microsoft/vscode-jupyter/issues – Ian Huff Jun 17 '21 at 20:42
  • 1
    Yep I will surely do that! – Avishek Roy Jun 18 '21 at 07:56
  • 1
    @IanHuff I am getting an error ```The active editor cannot provide outline ``` Any idea – sushmit Jul 23 '21 at 02:25
  • No, not sure on that. Do you have your context (typing cursor) the notebook document? – Ian Huff Aug 16 '21 at 01:18
  • 1
    I am getting a goofy "Outline" shown above, but not my Jupyter Notebook Table of Contents (TOC) with numbered headings. It is corrupted with the "Mv" characters (like in the image above). It does not render the autonumbered headings that I entered using JupyterLab or JupyterClassic with the TOC2 Extension. VSCode must FAITHFULLY render these numbers formatted elsewhere, not hide or replace them! Auto-numbered Section Headers must persist and display correct in the VSCode renderer. This is a BUG, not a missing feature!!! Please fix this BUG. – Rich Lysakowski PhD Nov 29 '21 at 07:45
  • Hi I have same issue of The active editor cannot provide outline, any solution now? Thanks – roudan Jun 14 '22 at 14:31
  • 1
    I use this feature, and I see a little "bug" : all markdown cells are in outline, including "normal text", whereas it could be better that only headings (with #) are shown. – John Smith Oct 14 '22 at 16:27
  • see also this https://stackoverflow.com/questions/71032944/vscode-notebooks-is-it-possible-to-show-only-markdown-headers-in-outline – Vincenzooo Dec 27 '22 at 01:03
  • Can you also outline inside the cell, like what it does to a '.py' script? – jerron Aug 19 '23 at 07:49
4

I had the same feature needs and the built-in "outline" feature functionality wasn't enough for me. Did not found the solution and made Jupyter TOC extension for Visual Studio Code which generates table of contents as separate markdown cell (optionally with numbering and/or anchor links between ToC and headers of the document, with ajustable levels of headers to collect to ToC).

Maybe it would be helpful.

xelad0m
  • 41
  • 1