How to expand and collapse the table of content

1k Views Asked by At

I am trying to document some of my python codes. I am using the sphinx_rtd_theme. I have added a simple table of content by doing:

Welcome to my documentation!
===========================================

.. toctree::
   :maxdepth: 5
   :caption: Introduction:


   chapter1
   chapter2

.. toctree::
   :maxdepth: 5
   :caption: Equations:


   chapter3
   chapter4

After running make html command, here is how it looks:

enter image description here

Now I want to collapse the CHAPTER 1 and CHAPTER 2 under INTRODUCTION in a way that if I click on the plus sign next to the INTRODUCTION, the CHAPTER 1 and CHAPTER 2 appears. I want to do the same thing for the CHAPTER 3 and CHAPTER 4 to be collapsed and expanded under the EQUATIONS. I tried many things. I added this line:

html_theme_options = {'collapse_navigation':True} 

to the config.py file but I was not able to get it done. What is the solution to add this capability to the html file?

0

There are 0 best solutions below