1

I want to be able to generate table of content inside a table. E.g. it should have borders and look like this:

.. tabularcolumns:: |p{10.5cm}|p{1.1cm}|p{1.4cm}|p{1.1cm}|
+----------------------------------------------------+-------+---------+-----+
|                                                    | hw1   |  hw2    | hw3 |
+====================================================+=======+=========+=====+
| heading 1                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+
| heading 2                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+
| heading 3                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+

I want to auto-generate the table from something like:

.. toctree::
   :maxdepth: 2

file 1
file 2

The output is both html and pdf.

Can this be done? Or do I have to use the docutils parser or similar?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Daniel Näslund
  • 2,300
  • 3
  • 22
  • 27

1 Answers1

2

You can edit the basic.css to give your toc a border:

Step 1: From your Sphinx build directory cp _build/html/_static/basic.css _static/

Step 2: Add the following line to basic.css

div.toctree-wrapper {
    border-collapse: collapse;
}

div.toctree-wrapper li {
    padding: 1px 8px 1px 5px;
    border:1px solid black; 
}

Step 3: Edit one of your rst files so that build kicks in when you execute make html

.. And you should see borders around your table of contents ... Like This enter image description here

Subbdue
  • 825
  • 1
  • 7
  • 12