How to fix column width in reStructuredText tables

2019-04-26 21:33发布

问题:

I am using Sphinx to create this table:

+---------------+---------------------+---------------------------+-------------------------------------+---------------------+
| Stakeholder   | Major Value         | Attitudes                 | Constraints                         | Major Interests     |
+===============+=====================+===========================+=====================================+=====================+
| Manager       | Reduce data entry.  | Strong commitment through | Cost, time and the required skill to| Google apps         |
|               | Improve ft          | release 4.                | develop this application.           | integration.        |
|               | productivity.       |                           |                                     |                     |
+---------------+---------------------+---------------------------+-------------------------------------+---------------------+
| Ft            | More efficient use  | Strong enthusiasm         | Training required to use       CRM. | Google apps         |
|               | of time. Less       |                           |                                     | integration.        |
|               | repetitive work.    |                           |                                     |                     |
|               |                     |                           |                                     |                     |
+---------------+---------------------+---------------------------+-------------------------------------+---------------------+

I want the column width to be fixed at a narrow size so this table can be displayed in one page. But Sphinx makes the ceil text into one long line. So the column width is the size of the ceil text. See the attached image.

Is there a way to fix the column width or make the ceil text displayed as the source table?

Thanks

回答1:

If your issue is with latex output, the tabularcolumns directive gives you the necessary flexibility.

Here is an example for forcing the width of the first 2 columns:

.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|L|

For more information, see the reference documentation.