Reputation: 282865
I found this question, but I don't want explicit <br>
s in my cell; I just want it to line-wrap where necessary.
e.g.,
================ ============
a short sentence second cell
a much longer bottom right
sentence
================ ============
I want "a much longer sentence" to all fit in one cell. I'd need to use very long lines of text unless I can find a way to wrap it. Is this possible?
I'm using ~NoTex~ w/ PDF output if relevant.
Upvotes: 9
Views: 12328
Reputation: 872
The list-table syntax may be suited here:
.. list-table::
* - a short sentence
- second cell
* - A "much" longer
sentence.
A table cell may also contain more than one paragraph.
- bottom right
Upvotes: 1
Reputation: 355
I wrote a python utility to format fixed-width plaintext table with multiline cells: https://github.com/kkew3/tabulate. Hope it helps.
Upvotes: 0
Reputation: 61
A workaround for this problem is to use a replace directive:
================ ============
a short sentence second cell
|long_sentence| bottom right
================ ============
.. |long_sentence| replace:: a much longer sentence
Upvotes: 6
Reputation: 169
There is a clean way. The issue is by default the columns are set to no-wrap, so that's why you get the scroll. To fix that you have to override the css with the following:
/* override table no-wrap */
.wy-table-responsive table td, .wy-table-responsive table th {
white-space: normal;
}
Upvotes: 14
Reputation: 1021
The example ddbeck presented may work because the sentence is to short. In the case of the lenght of the sentence dont fit in the screen, the sentence will not continue in a new line. Instead, the table will create a horizontal scrollbar. There is no clean way for solving this problem. You can implicit use pipe to implicitly change line like you saw here.
If you want alternatives to write your tables in restructuredtext, more pratical ways, you can check it in Sphinx/Rest Memo.
Upvotes: 3
Reputation: 3945
The simple table style does not support wrapping blocks. Use the grid style instead, like this:
+------------------+--------------+
| a short sentence | second cell |
+------------------+--------------+
| a much longer | bottom right |
| sentence | |
+------------------+--------------+
These tables are more tedious to work with, but they're more flexible. See the full documentation for details.
Upvotes: 7