How to right-align columns content in reStructuredText simple tables?

Sadly I don’t think rst offers that ability… the table styling options are rather limited. That said, if you’re rendering to HTML, you could add a custom stylesheet with a css rule such as:

table.right-align-right-col td:last-child {
    text-align: right
}

and then add the directive:

.. rst-class:: right-align-right-col

right above your table in the rst file. It’s clunky, but it should work.


update 2013-2-6: I’ve since needed to accomplish this myself, and came up with a more permanent solution. The cloud_sptheme.ext.table_styling Sphinx extension adds directives for doing column alignment, per-column css classes, and number of other table styling tricks. Despite being packaged as part of the “cloud” Sphinx theme, it should work with any Sphinx theme.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)