TechWriter at work blog logo

TechWriter at work blog

Living and writing documentation at Documatt, small team of programmers that write documentation too.


“list-table” widths do not match the number of columns in table#

Symptoms#

Sphinx build failed with the error similar to:

WARNING: "list-table" widths do not match the number of columns in table (3).

Reasons#

Table created with list-table directive, can have optional option :widths: that adjust columns’ widths. Above warning means :widths: is invalid because it define widths for different number of columns than the table has. The number of columns in the table is in parenthesis.

Example#

The following is 2 rows x 3 columns table. Unfortunately, :widths: option contains only widths for 2 columns.

.. list-table::
   :widths: 50, 50

   * - row 1, column 1
     - row 1, column 2
     - row 1, column 3
   * - row 2, column 1
     - row 2, column 2
     - row 2, column 3

Solution#

For example, we want the equal width columns. Width must be specified as integer. In this case, we use width of 33.

.. list-table::
   :widths: 33, 33, 33

   * - row 1, column 1
     - row 1, column 2
     - row 1, column 3
   * - row 2, column 1
     - row 2, column 2
     - row 2, column 3