33

How do I make the long multirow cell wrap its text? Ideally I'd like to be able to specify a width for the entire column. The text should also be centered both vertically and horizontally.

\begin{tabular}{|c|c|c|}
    \hline
    \multirow{2}{*}{looooooong cell} & cell1 & cell2 \\ \cline{2-3}
     & cell3 & cell4 \\ \hline
\end{tabular}

enter image description here

EDIT: Just found a solution for a single cell (answered below). But I'm still wondering if there's any way to do it for an entire column. I'd rather not have to do this for each individual cell.

tskuzzy
  • 641

3 Answers3

43

\multirow would linewrap if you used the length of the box instead of * in

\multirow{3}{*}.

So,

\multirow{2}{2cm}{\centering looooooong cell}}
Yoga
  • 531
21

Actually just found a solution

\multirow{2}{*}{\parbox{2cm}{\centering looooooong cell}}

works perfectly.

Fran
  • 80,769
tskuzzy
  • 641
7

To expand your answer: Use a paragraph box as in Text wrap in tables (multirow package loaded). I've made the font larger for example purposes and added another row so you can see it's centered in both directions.

\documentclass[crop]{standalone}
\usepackage{multirow}

\begin{document}

\Huge
\begin{tabular}{|c|c|c|}
  \hline
  \multirow{3}{*}{\parbox{4cm}{looooooong cell}} & cell1 & cell2 \\ \cline{2-3}
   & cell3 & cell4 \\ \cline{2-3}
   & cell5 & cell6 \\ \hline
\end{tabular}

\end{document}

enter image description here

sappjw
  • 1,013