# Table with multiple lines in some cells

What is the easiest way to have 2 lines in some of the cells in a table?

The only way I can think right now is to actually have 2 separate rows (without the line in the middle) and use \multirow on all other cells in this row. Any easier ideas?

-
 Can you clarify your question? Maybe post a small complete document with a table that shows what you want. If you use the p column type, you can have paragraphs within a table cell. Will that solve the problem? – Alan Munn Jan 9 '12 at 20:29

You could nest a tabular within another tabular:

\documentclass{article}
\begin{document}
\begin{tabular}{cccc}
One & Two & Three & Four \\
Een & Twee & Drie & Vier \\
One & Two & \begin{tabular}{@{}c@{}}Three \\ Drie\end{tabular} & Four
\end{tabular}
\end{document}


The use of @{}..@{} voids the additional space (horizontal tab separation) inserted by the nested tabular.

Also, the above example inserts the nested tabular vertically centered with respect to the row. If you want it top or bottom aligned, use the optional parameter to tabular: \begin{tabular}[t].. or \begin{tabular}[b]....

Note that this approach also works within math mode for an array.

-

The easiest way is to use \shortstack but it is not very flexible.

\documentclass{article}

\begin{document}
\begin{tabular}{ccc}
one & two & three \\
one & two & \shortstack{aa \\ bb}\\
\end{tabular}
\end{document}


Another idea is to use \parbox[t]{5cm}{aa\\bb} because it provides options to align the lines.

-

here are some cell definitions that i've used to good effect in situations where the content of table cells was essentially text:

\newcommand{\lcell}[2][1.2in]{%
$\vcenter{\hsize#1\baselineskip11pt\vspace*{3pt}\raggedright#2\strut\par}$}
\newcommand{\slcell}[2][1.2in]{%
$\vcenter{\hsize#1\baselineskip9.5pt\vspace*{3pt}\raggedright#2\strut\par}$}
\newcommand{\ccell}[2][.42in]{%
$\vcenter{\hsize#1\baselineskip11pt\vspace*{3pt}\centering#2\strut\par}$}


the job(s) involved had \usepackage{array} to get the augmented facilities.

of course, the dimensions were specific to the job, and would need to be changed depending on the circumstances; and fine tuning was definitely needed in the actual jobs involved. type was assumed to be 10pt for \lcell and \ccell or 8pt for \slcell; i also \setlength{\extrarowheight}{1pt} to keep the tops of cell content from crashing into lines above, and the \strut assures consistent clearance below.

line breaks in cells were usually manual (though they needn't be), with \break, and if a continuation line should be indented in a left-aligned cell, an \hspace* would be needed. the \par at the end ensures that the specified baseline is observed.

to me, multi-line text content of cells looks much better with "normal" text baseline settings than it does with the usual table row separation.

for table headings, vertical centering of multiple lines doesn't look so good; they look better aligned at the bottom. here's the definition i used for that:

\newcommand{\thead}[2][.75in]{%
\vbox{\hsize#1\baselineskip11pt\centering\vspace*{3pt}#2\par}}


some of these headings ran to four or more lines (complicated headings above narrow columns of numbers). the results were actually quite respectable.

-

Why not \newline?

\begin{tabular}{p{15mm}p{15mm}}
\hline
foo & bar \newline rlz \\
...
...

-
Welcome to TeX.sx! – texenthusiast Mar 18 at 1:15
It would be good to emphasise this requires a p type column – Andrew Swann Mar 18 at 7:30