latextabularmultirow

Latex: how to break the line in multirow inside the tabular


I cannot find out how to break the line inside the multirow in tabular. In my table, a cell should be two rows wide and should have a linebreak to keep the text overlapping the other cells'.

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}

Solution

  • 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}
    

    However, in your particular case, 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}