[Tex/LaTex] How to add a newline in a table cell

line-breakingtables

How can I put a new line (line break) within a table cell? I'm at a loss how to do this. I'm not using lyx or anything special, just MacTex and texmaker.

Best Answer

The cell needs to be of a paragraph style: either via a p{<len>} column specification, or using a \parbox.

enter image description here

\documentclass{article}
\begin{document}

\begin{tabular}{ll}
  Some text & Some more text \\
  \parbox[t]{3in}{Here is some lengthy text \par with a break\strut} &
  Some more text \\
  Some text & Some more text
\end{tabular}

\bigskip

\begin{tabular}{p{3in}l}
  Some text & Some more text \\
  Here is some lengthy text \par with a break\strut &
  Some more text \\
  Some text & Some more text
\end{tabular}

\end{document}

Using \\ alone would not help, since this is redefined inside a tabular to define a new line. Of course, depending on the context, it may also be possible to use

\begin{tabular}{ll}
  Some text & Some more text \\
  Here is some lengthy text & Some more text \\
  with a break \\
  Some text & Some more text
\end{tabular}

which resembles a newline in one of the cells.

Related Question