1

I have an RST document like this:

Introduction
------------

Some intro text.


Next Level Stuff
----------------

1. The first list item
2. The second list item
3. The third list item

I'm trying either a :numbered: toctree or .. sectnum:: to number the sections of my document, and have the numbered list inherit the section number. I'm trying to get a result like this:

1. Introduction
2. Next Level Stuff
   2.1 The first list item
   2.2 The second list item
   2.3 The thirst list item

Is this structure supported in RST?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
ajwood
  • 18,227
  • 15
  • 61
  • 104
  • Not that I know of. `toctree` uses heading levels or [sections](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections) to render nested enumerated sections. There's also a [warning not to use `sectnum`](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#directives), but it lacks an explanation. – Steve Piercy Jan 23 '20 at 02:20
  • `sectnum` hasn't been treating me well so far.. I don't want the document title to be part of the section numbering.. I've found oodles of posts and people wanting the same, but nothing conclusive :/ – ajwood Jan 23 '20 at 03:04
  • I would convert the numbered list to subsections, and use `toctree` in my `index.rst` to get the desired nesting, but maybe I don't understand what you want to achieve. – Steve Piercy Jan 23 '20 at 09:44
  • I'm experimenting to see if I can convert a set of office documents from Word .doc to a sphinx project. One requirements of these docs is that enumerated list elements (and/or table rows) have a unique ID that can be used to reference them. So a section '**4.** Responsibilities' may have a few list elements under it: **4.1**: The Key User(s) do a, b, and c...; **4.2**: The System Developer(s) do x, y, and z.. And a section '**9.** General Operation' may have a table where one column is 'ID': **9.1**, **9.2** etc.. Think there's any chance of a convenient way to do that numbering? – ajwood Jan 23 '20 at 13:30
  • 1
    You could try a custom style applied to those items. See [Using CSS counters](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters). But that's only presentation in HTML. If you need hard-coded numbering, I have no idea. – Steve Piercy Jan 23 '20 at 14:15
  • I may want to render LaTeX as well.. if Sphinx/rst doesn't support this natively, can you imagine it being possible to get be writing and extension somehow? Maybe a text preprocessor in Sphinx, or extending the markup language? – ajwood Jan 24 '20 at 13:02
  • 1
    Anything is possible with enough time or money. ;) – Steve Piercy Jan 24 '20 at 22:08

0 Answers0