3

I have several documents that are independant from each others:

index.rst
foo.rst
bar.rst
conf.py
Makefile

I would like to access foo.rst from index.rst, but I would like the two subdocuments to start their numbering at 1.

In index.rst I have:

.. toctree::
   :maxdepth: 2
   :numbered:

   foo
   bar

But, bar will take the number 2. and with this bar.rst I will get 2.1 Tomatoes.

=====
Title
=====

Tomatoes
========

Cucumbers
=========

and I would like this rendering:

1. Tomatoes
2. Cucumbers

How is that possible?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
nowox
  • 25,978
  • 39
  • 143
  • 293
  • But what about the "Title" section? It looks like you want to ignore it. – mzjn Feb 12 '18 at 12:16
  • 1
    Yeah, exactly. When you start an article, the title of this article isn't named `1.`. Only the first section of this document is named. Here, the first section is `Tomatoes`. – nowox Feb 12 '18 at 12:27
  • I don't understand. The first section in bar.rst is `Title`. – mzjn Feb 12 '18 at 12:41
  • In my case `Title` is the title of the document. If I remove it, the document will be named `Tomatoes`. – nowox Feb 12 '18 at 12:42
  • The only way to reset section numbering (that I can think of) is to use a second `toctree`. – mzjn Feb 17 '18 at 12:45

1 Answers1

1

You cannot have it both ways. See Sphinx documentation for Section numbering under the toctree directive for the explanation:

Section numbering

If you want to have section numbers even in HTML output, give the toplevel toctree a numbered option. For example:

.. toctree::
  :numbered:

  foo
  bar

Numbering then starts at the heading of foo. Sub-toctrees are automatically numbered (don’t give the numbered flag to those).

Community
  • 1
  • 1
Steve Piercy
  • 13,693
  • 1
  • 44
  • 57