Edy Bourne
Edy Bourne

Reputation: 6187

How to go up a level once a sub-section has been added to the document?

I have a Restructured Text document which several hierarchical sections, such as:

Main title
##########

Text under the main title.

Sub-section
===========

Text under the sub-section.

This works great, I get the correct HTML formatting when I compile it using Sphinx.

My question is: how can I go up a hierarchy level so I can add more text after a few sub-sections?

For example:

Main title
##########

Text under the main title.

Sub-section
===========

Text under the sub-section.

In my CSS, sub-section is indented.
I want this paragraph to be rendered as part of the Main title section,
not the sub-section.

I'm basically looking for a way to go up a level in the hierarchy.

Is this possible?

Thanks!

Upvotes: 0

Views: 344

Answers (1)

David Goodger
David Goodger

Reputation: 96

It's not possible to go "up" the hierarchy without starting a new section at the level you desire. Document section structure doesn't work that way. Changes in section level must be preceded by corresponding section titles. Using indentation to signal a section-like structure should only be used in a limited local scope.

What you're describing isn't a subsection, it's a topic. Docutils has a directive for that:

.. topic:: title

   Topic text.

   May include multiple body elements (paragraphs, lists, etc.).

There is also a "sidebar" directive for a similar structure, but typically for a parallel topic that's off to the side. The "rubric" directive may also be of interest.

See http://docutils.sourceforge.net/docs/ref/rst/directives.html for details.

Upvotes: 2

Related Questions