How to use Sphinx, how can I remove the header displayed in the context table table?

Let's say my some.rst file looks like this:

 ============ My Title ============ 1. Section ================ 2. Section ================= 

After compilation, a table of contents will appear in the resulting some.html in the sidebar, which looks like:

My title

  • Section
  • Section

Is there an easy way to remove "My Headline" from the table of contents in some.html ?

+4
source share
4 answers

A simple way is to use an object type that is ignored by the TOC directive:

 .. rubric:: My Title 

This creates text that looks like a title but is excluded from the TOC. You can update your CSS file with any style you want for the .rubric class, even if you like the h1 style.

See β€œ β€œ Headings without a heading ”on theβ€œ Restructured Text ”page for definition of class classes in style.

+2
source

If you are trying to remove it from all of your documents, try setting the default template . Otherwise, you will need to modify the HTML constructor by creating a subclass.

+1
source

Very late to this party, I know. I had this problem, I needed to emulate h2 and failed to modify the stylesheet.

My solution ended up adding raw html to some.rst :

 :raw-html:`<h1>My Title</h1>` 1. Section ================ 2. Section ================= 
+1
source

I managed to solve this problem using the .. raw:: html method, as described above, with a slight change (which avoided the TOC auto-generation gap). as described above, if your file contains only headers .. raw:: html , it will break the automatically generated TOC Sphinx. however, if you use .. raw:: html and add --------------------- under it, it will not display on the left and will not interrupt the TOC. eg.

so I finally accidentally figured out how to get the headers so that they would not appear in the left TOC. if your file contains only headers .. raw:: html h2, it will destroy the auto-generated sphinx TOC (as stated in stackoverflow). however, if you use .. raw:: html and --------------------- under it, it will not appear in the left navigation bar and will not interrupt TOC: star2: e.g.

 .. raw:: html <h2>What Can I Do With KSQL?</h2> --------------------- 
0
source

All Articles