How to wrap text in LaTeX tables?

Arnkrishn picture Arnkrishn · Apr 26, 2009 · Viewed 579.5k times · Source

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?

Answer

moinudin picture moinudin · Apr 26, 2009

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