Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to code tables with multi-line cells

Tags:

latex

tabular

I am trying to write a short paper with LaTeX and need to add a table with 3 columns.

+-------------+-----------------+--------------------------------------+ | AAAAAAAAAA  | BBBBBBBBBBBBBBB | Betty Botter Bought a Bit of Butter  | |             |                 | but the Butter's Bitter              | +-------------+-----------------+--------------------------------------+ | CCCCCCCC    | DDDD            | Betty Botter Thought:                | |             |                 | If I Put This Bitter Butter in My    | |             |                 | Batter it Will Make My Batter Bitter | +-------------+-----------------+--------------------------------------+ 

Unfortunately I can't seem to find the correct idiom to do it.


I tried:

\begin{tabular}{lll}      AAAAAAAAAA  & BBBBBBBBBBBBBBB & Betty Botter Bought a Bit of Butter but      the Butter's Bitter  \\     CCCCCCCC  & DDDD & Betty Botter Thought: \newline If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter  \end{tabular} 

But LaTeX doesn't do any linebreaks or formatting within the cell. I assume I need to tell it to do so.. But how?

like image 431
lexu Avatar asked May 24 '10 08:05

lexu


People also ask

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.

How do you make a table with multiple lines on long text in CSS?

When the text in a single table cell exceeds a few words, a line break (<BR>) may improve the appearance and readability of the table. The line break code allows data to be split into multiple lines. Place the line break code <BR> within the text at the point(s) you want the line to break.

How do you write multiple lines in Markdown?

Paragraphs. To create paragraphs in Markdown, use one or more lines of consecutive text followed by one or more blank lines. Note: If you don't leave a blank line between blocks of text, they will be collapsed into a single paragraph.

How do I show multiple lines of text in HTML?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.


1 Answers

Use the p column descriptor:

Change

\begin{tabular}{lll}  

to

\begin{tabular}{llp{5cm}} 

To explicitly insert line-breaks:

CCCCCCCC  & DDDD & \parbox{5cm}{Betty Botter Thought: \\ If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter} 
like image 89
aioobe Avatar answered Sep 19 '22 00:09

aioobe