toc.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. .. _toc:
  2. Table Of Contents
  3. ====================
  4. The table of contents extension is built-in JupyterLab since version 3.0. This makes it easy to see and navigate the structure of a document.
  5. Anyone using earlier JupyterLab version should install a `dedicated extension <https://github.com/jupyterlab/jupyterlab-toc>`__.
  6. A table of contents is auto-generated in the :ref:`left sidebar
  7. <left-sidebar>` when you have a notebook, markdown, latex or python files opened. The entries are clickable, and scroll the document to the heading in question.
  8. In the sidebar panel, you can number headings, collapse sections, and navigate into the file.
  9. Here is an animation showing the table of content use, with a notebook from the `Python Data Science Handbook <https://github.com/jakevdp/PythonDataScienceHandbook>`_ :
  10. .. image:: ./images/toc/toc.gif
  11. The table of contents tool will automatically generate a table of contents for your notebook by taking all the headings from your markdown cells.
  12. Because the Notebook does not utilize formal page breaks or numbers, each listed section will be hyperlinked to the actual section within your document.
  13. Automatic section numbering will go through your Notebook and number your sections and subsection as designated by your headings. This means that if you've moved one or more big sections around several times, you won't have to go through your document and renumber it, as well as all its subsections, yourself.
  14. ------------------------------------------------------------------------------------------------------------
  15. Automatic section numbering can be skipped for first-level headings (``h1``) by setting the ``numberingH1``
  16. setting to ``false``. To perform that go to settings and click on Advanced Settings Editor and then go to Table of Contents section
  17. and in User Preferences add ``numberingH1:false`` and save the settings. Here is an animation showing its use
  18. .. image:: ./images/toc/numberingH1.gif
  19. ------------------------------------------------------------------------------------------------------------
  20. Context menus are added to those table of contents headings having notebook sections
  21. containing runnable code cells, and clicking the *Run Cell(s)* option will make the cells run in notebook.
  22. Here is an animation showing its use
  23. .. image:: ./images/toc/runcell.gif
  24. ------------------------------------------------------------------------------------------------------------
  25. There will be a synchronization between table of contents and notebook if the ``syncCollapseState`` attribute
  26. is set to ``true`` in the settings. If a heading is collapsed in the table of contents the notebook will also gets collapsed and
  27. similarly expanding cells in notebook will expand the table of contents. To perform that go to settings and click on Advanced Settings
  28. Editor and then go to Table of Contents section and in User Preferences add ``syncCollapseState:true`` and save the settings. Here is an animation showing its use
  29. .. image:: ./images/toc/syncCollapseState.gif
  30. ------------------------------------------------------------------------------------------------------------
  31. The headings in the cell outputs get numbered by default in the table of contents and the notebook.
  32. This can be tuned by changing the settings ``includeOutput`` to ``false``. To perform that go to settings and click on Advanced Settings
  33. Editor and then go to Table of Contents section and in User Preferences add ``includeOutput:false`` and save the settings. Here is an animation showing its use
  34. .. image:: ./images/toc/includeOutput.gif
  35. .. _Settings:
  36. Settings
  37. --------
  38. The extension behavior can be modified via settings which can be set in JupyterLab's advanced settings editor.
  39. * **collapsibleNotebooks**: enable the ability to collapse sections of notebooks from the table of contents
  40. * **numberingH1** : numbers the first-level headings (``h1``) if set to ``true``
  41. * **syncCollapseState** : synchronization of collapsing behaviour between the table of contents and notebook
  42. * **includeOutput** : includes the numbering for Outputs in both notebook and table of contents.