6

If I have the following in index.rst:

This Section
------------

.. toctree::
   :caption: This Section
   :maxdepth: 1

   this_section/intro
   this_section/body
   this_section/outro

Then "This Section" would show up twice in the generated HTML file: One as a <h1>, one as a <p class="caption">. How can I get rid of the latter, or make :caption: generate a <h1>? I can't simply remove :caption: because the sidebar (I'm using ReadTheDoc theme) relies on this option to correctly generate a TOC tree.

mzjn
  • 48,958
  • 13
  • 128
  • 248
xuhdev
  • 8,018
  • 2
  • 41
  • 69

2 Answers2

2

My workaround is to hide the original toctree and link again to contents...

This section
------------

* :doc:`intro <this_section/intro>`
* :doc:`body <this_section/body>`

.. toctree::
   :caption: This Section
   :hidden:

   this_section/intro
   this_section/body
   this_section/outro

biphasic
  • 61
  • 4
2

I ended up removing this with css by adding this to custom.css in the _static directory:

section#setup span.caption-text {
    display: none;
}

And having this in my conf.py:

html_static_path = ['_static']
html_css_files = ['custom.css']
Mad
  • 319
  • 3
  • 9