Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple lines of text in single cell of simple table?

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.

like image 823
mpen Avatar asked May 15 '13 16:05

mpen


4 Answers

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;
}
like image 94
Matt Cannon Avatar answered Sep 19 '22 13:09

Matt Cannon


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.

like image 41
ddbeck Avatar answered Sep 21 '22 13:09

ddbeck


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
like image 44
Olivier Avatar answered Sep 20 '22 13:09

Olivier


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.

like image 42
joaonrb Avatar answered Sep 22 '22 13:09

joaonrb