Hi Luc,
As an example, this is a page of a project I am working on:
This page talks about a certain class in broad terms, then dives into details on some sub-topics in pages that follow. In the ToC I want those sub-topics one hierarchical level below the introductory section. I want both the intro and the sub-topics on their own pages.
Currently I do this by a hack: not having headings in the intro-page. I now use ::rubrics in the intro page, and a hidden ToC at the end of the intro page. That gives me the ToC structure I want, at the cost of being unable to use any headings on the intro page. The use of ::rubric's is a way to avoid that.
I could also do this -- every line a separate rst page. I think this is what you suggest:
* ToC superpage
* Overview section B with headings and all.
* Detailed section B1
* Detailed section B2
However, this is not what I want. The sections B, B1, and B2 are at the same hierarchical level here (I want B1 and B2 below B in the ToC); and a ToC superpage will be generated that I really don't want, either in HTML or in in PDF.
> It's more intuitive for the reader when every page is *either* a node of the ToC *or* a content page with sections.
I don't agree in general. There are many fine educational books and manuals that do what I try to achieve. Let's agree to disagree on this and discuss if/how it could be done.
I would like to ask the inverse question; suppose you have a page with both headings and a ToC. I don't see any case where the useful thing would be to add the ToC at the level determined by the level where the ::toctree happens to sit in the first page. Suppose the text preceding the ::toctree happens to end at subheading-level 3, the ToC entries will be inserted one level below that, which is undesirable in any situation I can think of.
Having googled for this issue a quite a bit prior to asking here, I have seen that I am not the only one who was surprised by this. Only when I started experimenting with a small project to figure out what was going on, I started understanding what Sphinx is doing.
You end up with webpages recommending not to mix headings and ::toctree directives on the same page at all (eg
https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/WritingReST/MenuHierarchy.html), without going into detail on the
why, or if it is even sensible to have to recommend such a policy. If in-page headings and toctrees don't mix, then I feel it would be better to emit an error and refuse to render, than to have the current behaviour where the toctree items are inserted one level below whatever happens to be the heading level where the toctree resides.
Best, Sidney