0

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.

James Z
  • 12,209
  • 10
  • 24
  • 44
saichand
  • 1,165
  • 1
  • 10
  • 25
  • The [`toctree` directive](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-toctree) has only the `:numbered:` option with no styling option. You will need to apply styles, if possible, in the stylesheet. – Steve Piercy Aug 18 '20 at 11:10
  • @StevePiercy, Do you know how to make the right alignment for contents in stylesheet? I could not find the right option for the contents/tableofcontents classes. – saichand Aug 18 '20 at 11:41
  • No, I don't know anything about *TeX stylesheets. I would suggest searching the *TeX documentation first, then the SO community https://tex.stackexchange.com/ – Steve Piercy Aug 18 '20 at 22:43
  • @StevePiercy, The stylesheet I'm using here is with respect to the reStructuredText(rst) file format. This supports only a subset of Tex formatting options. So, I wanted to know if the section-number right-alignment is possible with rst files. However, I looked for any inputs from Latex forum. Couldn't find solution from my search. All, Kindly help me find a solution for this problem. – saichand Aug 25 '20 at 13:09

1 Answers1

0

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 ]
Lorna Mitchell
  • 1,819
  • 13
  • 22
  • I was using the sectnum directive. having the ALIGN attr in item-list is not helping me to right-align the section numbers in the toc. The item-list class works for the jotting points, but doesn't work for the table of contents. – saichand Aug 25 '20 at 12:54