How can I implement automatic multilevel list numbering in sphinx restructedtext?

78 views Asked by At

How can I implement automatic multilevel list numbering in sphinx reStructuredText?

Let's say there is a to-do list somewhere in the document: (here the numbering is manual)

1. Do something #1

    1.1 Do something #2

        1.1.1 Do something #3

Moreover, there is a requirement that it be a single document for subsequent PDF printing, and there may also be some text between the headers.

I tried to implement it through toctree, but I get only headers from a third-party file, and in the form of links to individual documentation pages.

I tried using content - but due to the binding to the header levels, it is not possible to get the normal numbering of the local section.

1

There are 1 answers

0
G. Milde On

The standard rST syntax for auto-numbered lists

#. Do something #1

   #. Do something #2

      #. Do something #3

#. Do somtething #4

(with correct indentation and empty lines around nested lists) will produce an auto-numbered multi-level list.

The numbers displayed in the output depend on the output format, writer and style.

With HTML, custom CSS counters may be used to get "compound enumerators" as in the manual example.

Docutils' rst2latex comes with a compound-enumerators setting that creates the numbering as in the example out-of-the-box.