rST Tables¶
Sphinx makes it easy to create tables with the use of the list-table
directive. The directive uses a modified rST list syntax. Each list-item is a row that contains a sub-list of the columns of the table.
The directive takes the :width:
, :widths:
, :align:
and :header-rows:
variables:
:width:
Determines the table’s width in the content
:widths:
Determines the width of the individual columns in the table.
Important
The number of values used must be the same as the number of columns, and they must add up to 100
:align:
Determines the table’s alignment.
Caution
The
:align: left
and:align: right
values will flow the text around the table if there’s enough space and you will have to use therst-class
directive again to separate contents that are allowed to float and not.
:header-rows:
Determines the amount of rows in the table that function as headers.
Note
Tables can have any content, just be sure to double-check the indentations.
.. list-table::
:width: 100 %
:widths: 25 25 25 25
:header-rows: 1
* - Header 1
- Header 2
- Header 3
- Header 4
* - Content
- Content
- Content
- Content
* - Content
- Content
- Content
- Content
Header 1 |
Header 2 |
Header 3 |
Header 4 |
---|---|---|---|
Content |
Content |
Content |
Content |
Content |
Content |
Content |
Content |
You can also draw your tables, as the most complex customisations can be achieved via drawn Grid Tables. You can check the Sphinx documentation in full for: