0

Hi what is the best way to make the red text fit the width of the merged cells/rows and automatically break the line instead of causing overflow to the next cell and cells content confusion ?

PS: i never used package tabularx.

enter image description here

Code:

\documentclass[a4paper]{report}
\usepackage{multirow}
\usepackage{array}
\usepackage{color}
\begin{document}
\begin{table}[h]
\begin{center}
\renewcommand{\arraystretch}{3}
\begin{tabular}{|p{2,5cm}|p{2,5cm}|p{3cm}|p{2cm}|p{2cm}|}
\hline
\multirow{2}*{\textcolor{red}{this is a long text long}} & \multirow{2}*{here is a text} & \multirow{2}*{\textcolor{red}{this is a long text long}} & \multicolumn{2}{c|}{text}\\
    \cline{4-5}
  &   &   & \textcolor{green}{it works here text} & here is a text\\
    \hline
\multirow{3}*{text} & \multirow{3}*{\textcolor{red}{this is a long text long long}} &  \textcolor{green}{split like this long text } & \multirow{3}*{text} & \multirow{3}*{text}\\

  &   &   text & \\
  &   &   text & \\
\hline
\end{tabular}
\end{center}
\end{table}
\end{document}

the following of this: How do i get a table with this layout?

  • 1
    you need to specify a width not * for multirow so it uses p column formatting – David Carlisle Feb 29 '16 at 11:28
0

As David Carlisle said in his comment, instead * you need to declare width of column, for example for multirow in the first column:

\multirow{2}{2.5cm}{this is a long text long}

With this corection you will obtain:

enter image description here

The last vertical line is missed because you has in the last two rows only 3 ampersands instead four. By the way, LaTeX use decimal point, not comma.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.