Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap text in LaTeX tables?

I am creating a report in LaTeX which involves a few tables. I'm stuck on that as my cell data in the table is exceeding the width of the page. Can I somehow wrap the text so that it falls into the next line in the same cell of the table?

Is it somehow related to the table's width? But as it's overshooting the page's width, will it make a difference?

like image 337
Arnkrishn Avatar asked Apr 26 '09 14:04

Arnkrishn


People also ask

How do you wrap text in a table in LaTeX?

To change the text AB into A \r B in a table cell, put this into the cell position: \makecell{A \\ B} . Before doing that, you also need to include package makecell . Show activity on this post. The new tabularray makes wrapping text in cells easier then ever before.

How do you wrap text in a table?

Select the table and either right-click and choose “Table Properties” or pick “Properties” in the floating toolbar. Go to the Table tab in the pop-up window. In the Text Wrapping section at the bottom, select Around and click “OK.”


1 Answers

Use p{width} for your column specifiers instead of l/r/c.

\begin{tabular}{|p{1cm}|p{3cm}|}   This text will be wrapped & Some more text \\ \end{tabular} 

EDIT: (based on the comments)

\begin{table}[ht]     \centering     \begin{tabular}{p{0.35\linewidth} | p{0.6\linewidth}}       Column 1  & Column2 \\ \hline       This text will be wrapped & Some more text \\       Some text here & This text maybe wrapped here if its tooooo long \\     \end{tabular}     \caption{Caption}     \label{tab:my_label} \end{table} 

we get:

enter image description here

like image 167
moinudin Avatar answered Nov 02 '22 05:11

moinudin