Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline in markdown table?

Tags:

markdown

I have the following cells in a markdown table:

 |Something|Something else that's rather long|Something else| 

I'd like to be able to insert a break in the middle line, so the column isn't so large. How can I do that in Markdown? Do I need to use HTML tables instead?

like image 479
mikemaccana Avatar asked Jul 28 '12 11:07

mikemaccana


People also ask

How do I add a new line in markdown table?

davidsneighbour: A newline in Markdown is created by “2 spaces at the end of the line and a single newline”.

How do you insert a line break in markdown?

To create a line break or new line ( <br> ), end a line with two or more spaces, and then type return. This is the first line.

How do I put multiple lines in a markdown cell in a table?

In summary, if you need to have a table cell span multiple lines when writing Markdown, use the HTML <br> tag, as shown.


2 Answers

Use an HTML line break (<br />) to force a line break within a table cell:

|Something|Something else<br />that's rather long|Something else| 
like image 52
jwal Avatar answered Sep 19 '22 19:09

jwal


When you're exporting to HTML, using <br> works. However, if you're using pandoc to export to LaTeX/PDF as well, you should 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 31
mb21 Avatar answered Sep 21 '22 19:09

mb21