Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReStructuredText numbered headers

Is there a way in rst to have automatic header numbering ? That is something like:

#. Some Section
===============
...
#. Some Subsection
------------------
...
#. Another Subsection
---------------------
...
#. Another Section
==================
...

that would be rendered as:

1. Some Section

...

1.1 Some Subsection

...

1.2 Another Subsection

...

2. Another Section

...

like image 663
gsakkis Avatar asked Mar 02 '10 09:03

gsakkis


People also ask

What is RST Sphinx?

RST stands for ReStructured Text. It is the standard markup language used for documenting python packages. Sphinx is the Python package that generates an html website from RST files, and it is what we are using to generate this site.

How do I add a new line to an RST file?

To get a new line immediately following a few long lines I have to a) start a new (empty) line and b) THEN (on the next line) follow it with | <my new line> .


1 Answers

According to the docutils manual, you can use the sectnum directive: http://docutils.sourceforge.net/0.7/docs/ref/rst/directives.html#automatic-section-numbering

So you can add something like this in the very first line(s):

.. sectnum::

HTH

like image 100
Zsolt Botykai Avatar answered Sep 20 '22 14:09

Zsolt Botykai