Table of Contents and Voila

Is there a way to have a ToC when generating a Voilá interactive notebook?
I tried using toc2 template but does not seem to work.

Have you considered switching to JupyterLab at least for this? If click here to launch a session, you’ll see you get the notebook in JupyterLab (version 3) with the Table of contents as an option (third one down) on the far left side, vertical toolbar. Give the notebook a Run All Cells first to see the ipywidgets render correctly. Voila works. You can click on the Voila symbol on the toolbar directly above the notebook (the small green circle with a yellow band in the southwest quadrant) and it will open Voila dashboard viewing mode in a panel on the side.

I do note that the Table of Contents only works with the notebook portion though. You don’t move around the Dashboard using it.
In both the classic notebook and the JupyterLab interface in dashboard viewing mode, the section headers don’t get links, the way they do in the notebook view, and so there’s nothing to anchor navigating around to different parts of the dashboard.

Aside for others, who may find this: the information being linked by the OP over at Stackoverflow is outdated in regards to JupyterLab. You don’t need an extension if you are working with a current version of JupyterLab. The table of contents feature is now built-in.

1 Like

Thanks for the reply. What I was really trying to do is generate an HTML with the ToC on the side (like it’s shown in the JupyterLab notebook part), then share the html with the world. Hence why I was trying Table of Contents (2) — jupyter_contrib_nbextensions 0.5.0 documentation

I can create a html file (had to downgrade Nbconvert because I had this exact same issue python - How to solve error with downloading Jupyter Notebook as HTML with toc? - Stack Overflow) by doing jupyter nbconvert FILE.ipynb --to html --template toc2

But when serving the notebook with voila (voila --template=toc2) it gives me AttributeError: module ‘nbconvert.exporters.templateexporter’ has no attribute ‘DEV_MODE’

1 Like