views:

24

answers:

1

Hi all, I cannot find out how to break the line inside the multirow in tabular. I need to make some table where I have one cell which is two row high, and I have long text in it, but it does not break the line and text is overlapping another cell on the left side.

Any suggestions?

Sample of code:

\begin{center}
    \begin{tabular}{|p{1cm}|p{2.5cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
    \hline
    \multirow{2}{*}{Long text to break} % HERE IS A PROBLEM
        & Thing  & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3}    
    \\ \cline{2-6}
        & sth 1 & sth 1 & sth 2 & sth 1  & sth 2 \\ \hline
\hline
\end{tabular}
\end{center}
+1  A: 

My suggestion would simply be to loosen the restrictions of the other columns, because there is too much space wasted there. With each p{}, that forces the other columns to be a certain width, so there is not enough room for the first column.

The following code looked presentable to me when I compiled it:

\begin{center}
\begin{tabular}{|l|l|l|l|l|l|}
    \hline
    \multirow{2}{*}{Long text to break}
    & Thing  & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3} \\
    \cline{2-6}
    & sth 1 & sth 1 & sth 2 & sth 1  & sth 2 \\
    \hline
    \hline
\end{tabular}
\end{center}

EDIT: If your cell text is really long, then you could try to minipage it:

\begin{center}
\begin{tabular}{|l|l|l|l|l|l|}
    \hline
    \multirow{2}{*}{\begin{minipage}{0.5in}Long text to break\end{minipage}}
    & Thing  & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3} \\
    \cline{2-6}
    & sth 1 & sth 1 & sth 2 & sth 1  & sth 2 \\ 
    \hline
    \hline
\end{tabular}
\end{center}
Steve
I cannot just use "l" parameter in tabular command, because the cell was to width, but the "\begin{minipage}{2cm}Long text to break\end{minipage}" helped me out, thank you.
kogut