Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a hard line break in a multiline table using markdown

The markdown docs claim:

A backslash followed by a newline is also a hard line break. Note: in multiline and grid table cells, this is the only way to create a hard line break, since trailing spaces in the cells are ignored.

I have an 2 column table where I could make this work for the last column in the row:

-------------------------------------------------
                           35                    
-------------------------- ----------------------
**0-6 mon**                1                    \
                           0.5                  \
                           0                    \
                           0                    \
                           0                     
                           
-------------------------------------------------

However, when I try to do it for two columns in a row, it fails. If I do it like this, it makes a table, but only puts hard breaks on the last column:

------------------------------------------------------------------------
                            35                     35-45                
-------------------------- ---------------------- ----------------------
**0-6 mon**                1                                           \
                           0.5                                         \
                           0                                           \
                           0                                           \
                           0                      3                    \
                                                  13                   \
                                                  0                    \
                                                  0.02                 \
                                                  0                     

------------------------------------------------------------------------

If I do it like this, it doesn't consider it a valid table:

------------------------------------------------------------------------
                            35                     35-45                
-------------------------- ---------------------- ----------------------
**0-6 mon**                1                    \
                           0.5                  \
                           0                    \
                           0                    \
                           0                      3                    \
                                                  13                   \
                                                  0                    \
                                                  0.02                 \
                                                  0                     

------------------------------------------------------------------------

Has anyone ever got this to work?

The answer appears to be: you can not do this with a "multiline" table, only with a grid table. The question marked as a potential duplicate was asking about how to do this in HTML, my question is how to do this so it will work for any output format.

like image 848
Greg Dougherty Avatar asked Oct 20 '25 08:10

Greg Dougherty


1 Answers

In Pandoc you can use grid tables:

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+
like image 109
mb21 Avatar answered Oct 22 '25 03:10

mb21



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!