Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix column width in reStructuredText tables?

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

enter image description here

like image 438
Jake He Avatar asked Dec 18 '14 12:12

Jake He


People also ask

How do you fix column width in a table?

The width of the columns i.e. td in a table can be fixed very easily. This can be done by adding the width attribute in the <td> tag. If the width is not specified, the width of the column changes according to the change in the content. The specifications of width for the columns can be in pixels, or percentage.

How do you set column width in a table?

If you want to set the width of the table column, you can use some CSS. You need to use the width property. In the example below, we set the width of the the <table> element to 100%. Then, in the HTML part, we distribute the table width of 100% among <col> elements having span attributes.

How do you set the fixed width of a TD table?

Using width attribute: The <td> tag has width attribute to control the width of a particular column. By assigning a numeric value to this attribute between 0 to 100 in terms of percentage(or you can use pixel format). We can restrict the column width up to that much percentage of the table's total width.

How do I adjust columns in a Wordpress table?

To set the width of a column, give one of the <td> cells the desired width. For example <td width=”300″> would set the width of that column to 300px. You can also use a percentage here, in which case <td width=”30%” would set that column's width to 30% of the total table width.


1 Answers

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.

like image 138
liminkai Avatar answered Oct 09 '22 14:10

liminkai