How to right align section numbers using the rst2pdf stylesheet

299 views Asked by At

I am using rst2pdf for converting an rst document. In the table of contents, I have the following

left aligned numbering.

But I want the right aligned numbering, like the following

right aligned numbering.

I am using the rst2pdf stylesheet for tableofcontents initialization. I didn't know how to adjust this alignment using the stylesheet or even at the rst format level. The current configuration I set is:

.. contents:: Table of Contents
   .. sectnum::
   :depth: 2

I want the solution either at rst-level or at rst2pdf-level.

1

There are 1 answers

1
Lorna Mitchell On

From the default stylesheet, I think this will pick up the item-list style, which is defined as:

    item-list:
      parent: bodytext
      commands: []
             [VALIGN, [ 0, 0 ], [ -1, -1 ], TOP ]
             [RIGHTPADDING, [ 0, 0 ], [ 1, -1 ], 0 ]
      colWidths: [20pt,null]

These commands: [] are actually table styles ... check the docs for tables and that may help with how to align each column, try setting the ALIGN value, something like this (sorry I don't have an example handy)

[ALIGN, [ 0, 0 ], [ -1, -1 ], RIGHT ]