0

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 ?

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 code follows: How do i get a table with this layout?

1
  • 1
    you need to specify a width not * for multirow so it uses p column formatting Feb 29, 2016 at 11:28

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .