Skip to content

Allow to specify toctree pages as direct-children of parent page #8287

Open
@choldgraf

Description

@choldgraf

Currently, all pages listed in a toctree directive will be listed as children of the last header level under which the toctree is placed. For example:

My title
========

My header
---------

.. toctree::

   page1

Will turn into:

1. My title
1.1 My header
1.1.1 page1 title

However, I find that many users use the index page similar to an "introduction" to the chapter, and put headers on that page. They really wish for the toctree to be treated as siblings of the index page top-level headers, rather than as children of the latest header. E.g. they want the above example to render instead as:

1. My title
1.1 My header
1.2 page1 title

I can get close to what they want with the following:

My title
========

.. toctree::

   page1

My header
---------

however, this results in an incorrect ordering of the sections (which becomes a problem with latex builds etc).

I wonder if this pattern is possible right now and I am missing something? Otherwise, I'm curious what folks think about adding a keyword argument for toctree like level: 2 that would tell Sphinx what level it should use for the toctree titles.

I'm not sure if I'm explaining this well or not, happy to try and clarify if it helps!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions