Sphinx section number for headings of more than third level: .. sectnum ::

I use Sphinx to create PDF files from the first files. Sphinx automatically generates section numbers up to level 3 headings, as well as a table of contents up to that level. However, I want the headings at all levels to be numbered and contained in the table of contents. For this I am trying to use .. sectnum::( http://docutils.sourceforge.net/docs/ref/rst/directives.html#table-of-contents ). The result is not quite what I expected:

1) The number 1 is added before all section numbers in the table of contents and in the text. That is, instead of 1 it is 1.1, instead of 2 it is 1.2.

2) Both in the table of contents and in the text up to the heading of the third level, the section numbers seem to be repeated, i.e. before the wrong (before 1. is added in front) is the section number (correct).

Here is my first file example:


.. sectnum::




level 1: the first party
========================

level 1 desc: this document is about xyz

level 2
-------

level 2 desc

level 3
~~~~~~~~

level 3 content

level 4
^^^^^^^^

level 4 content

level 5
''''''''

level 5 content jflkasjfslkajf
asdfsafs

level 1: the second part
========================

fjsdafjskalfjslkafjksaljflksaj
fasdhfkjsahfjkhdsf

level 2
-------

level 2 desc

level 3
~~~~~~~~

level 3 content

level 4
^^^^^^^^

level 4 content

level 5
''''''''

level 5 content jflkasjfslkajf
asdfsafs

Here is the result of the table of contents:

(I took a snapshot of my pdf file to show the result, but I just found out that I can’t post images, because I need 10 reps for this, I’m publishing something for the first time)

1 1.1 level 1: the first party
  1.1   1.1.1 level 2

2 1.2 level 1: the second part
  2.1   1.2.1 level 2

Here is the result of the text:

                     1.1 LEVEL 1: THE FIRST PARTY

level 1 desc: this document is about xyz

1.1 1.1.1 level 2

level 2 desc

1.1.1 1.1.1.1 level 3

level 3 content

1.1.1.1.1 level 4

level 4 content

1.1.1.1.1.1 level 5

level 5 content jflkasjfslkajf asdfsafs

As you can see, 1. is added to the section number and a repeated part of the headings is up to level 3.

I really appreciate if anyone can help me with this.

+5
source share
2 answers

Sphinx, , , , .rst ; .. toctree::. , . , , .rst, , , - .

, , Sphinx sectnum. :numbered: .. toctree::. (http://sphinx-doc.org/rest.html)

+2

, HTML, .

, HTML.

enter image description here


,

.. sectnum::

.. toctree::
   :numbered:

, , .

  • , : sectnum
  • ( sub toctree), : toctree:: :number:

>

0

All Articles