Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subsections in reStructuredText

I'm trying to write a document in reStructuredText, but am currently facing a problem.

I want the document to have a title, this is going to be centered, then immediately after that I want a subsection.

I tried doing the following

##############
Title
##############

+++++++++
Subtitle
+++++++++
content

But when I convert this to PDF, it makes both the title and subtitle centered.

like image 456
Mahmoud Hanafy Avatar asked Mar 06 '12 23:03

Mahmoud Hanafy


1 Answers

From the reStructuredText quick start guide titles and sub-titles are specified as follows (emphasis mine):

To indicate the document title in reStructuredText, use a unique adornment style at the beginning of the document. To indicate the document subtitle, use another unique adornment style immediately after the document title.

So in the reST example in the question, Subtitle is being formatted as a sub title and not a section heading since the adornment style used around Subtitle is not used anywhere else in the document. In the following, this adornment is used around two section headings, so is not unique and not treated as a subtitle:

##############
Document Title
##############

+++++++++++++++
Section 1 Title
+++++++++++++++

Section 1 content...

+++++++++++++++
Section 2 Title
+++++++++++++++

Section 2 content...

Have a play with http://www.tele3.cz/jbar/rest/rest.html This allows you to quickly try out some simple reStructuredText and test things like sub-titles vs. section titles.

Edit: Alternatively you could put some text between your title and section heading (like an abstract, for example).

P.s. I tend you use adornments above and below a heading to indicate a document title and sub-title and a single adornment below a heading to indicate a (sub-)section title. This makes it easy to see what I intended to be my title/sub-title. For example:

==============
Document title
==============
-----------------
Document subtitle
-----------------

Section
=======

Sub-section
-----------
etc.
like image 197
Chris Avatar answered Oct 07 '22 00:10

Chris