3

I have a text inside multirow that for some reason is not readable.

\begingroup
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}}
\renewcommand*{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}%
        {| >{\hsize=1.0\hsize}K|
         >{\hsize=1.00\hsize}X|
         >{\hsize=1.00\hsize}X|
         >{\hsize=1.00\hsize}X|
         >{\hsize=1.00\hsize}X|
        }

\hline
\rowcolor{gray!50}\textbf{Code 1} & \textbf{Code 2} & \textbf{code3} &      \textbf{code 4} & \textbf{code5}\\
\hline
\endfirsthead
\hline
\endhead 

\multirow{4}{*}{\parbox{1.5cm}{Long text to break aaaaaa}}   
& xyzxyzxyz
& xyzxyzxyz    
& xyzxyzxyz  
& xyzxyzxyz
\\
\cline{2-5}
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz  
& xyzxyzxyz 
\\
\cline{2-5}
 & xyzxyzxyz
 & xyzxyzxyz  
 & xyzxyzxyz  
 & xyzxyzxyz 
 \\
\cline{2-5}

 & xyzxyzxyz 
 & xyzxyzxyz 
 & xyzxyzxyz  
 & xyzxyzxyz  
\\
\hline 
\end{tabularx}

\endgroup

I should see the multirow with the text "Long text to break aaaaaa" but I see something like in this screen:

enter image description here

The definition of columntype K is:

  \newcolumntype{K}{>{\RaggedRight\arraybackslash \columncolor{blue!10}}m{3cm}}

How can I make the text readable?

  • What's the purpose of the >{\hsize=1.0\hsize} directives? – Mico Feb 14 '17 at 14:56
5

Just put the \multirow command in the 4th row, with a negative value for the number of rows. As @Mico pointed, >{\hsize=1.0\hsize} is useless, as it is the default for X columns. This specification is used if you want to have unequal width X columns.

\documentclass{article}

\usepackage{ltablex, multirow, ragged2e}
\usepackage[table]{xcolor} \newcolumntype{K}{>{\RaggedRight\arraybackslash \columncolor{blue!10}}m{3cm}}

\begin{document}

\begingroup
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}}
\renewcommand*{\arraystretch}{1.5}
\keepXColumns
\begin{tabularx}{\textwidth}%
{|K|*{4}{X|}}
\hline
\rowcolor{gray!50}\textbf{Code 1} & \textbf{Code 2} & \textbf{code3} & \textbf{code 4} & \textbf{code5}\\
\hline
\endfirsthead
\hline
\endhead
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
\\
\cline{2-5}
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
\\
\cline{2-5}
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
\\
\cline{2-5}
\multirow{-4}{*}{\parbox{1.5cm}{Long text to break aaaaaa}}
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
& xyzxyzxyz
\\
\hline
\end{tabularx}

\endgroup
\end{document} 

enter image description here

| improve this answer | |
3

Quoting from pp. 7f. of the user guide of the multirow package:

If you use \multirow with the colortbl package you have to take precautions if you want to color the column that has the \multirow in it. The colortbl package works by coloring each cell separately. So if you use \multirow with a positive <nrows> value, colortbl will first color the top cell, then \multirow will typeset <nrows> cells starting with this cell, and later colortbl will color the other cells, effectively hiding the text in that area. This can be solved by putting the \multirow in the last row with a negative <nrows> value.

Applied to your code, this means that instead of placing

\multirow{4}{*}{\parbox{1.5cm}{Long text to break aaaaaa}}

in the first row, you should place

\multirow{-4}{*}{\parbox{1.5cm}{Long text to break aaaaaa}}

in the last row.

| improve this answer | |
3

Almost the same answer as of Bernard (he bit mi for five minutes which I spend for looking for K column type definition and guess, why you use elements of long table in one simple table).

\documentclass[12pt]{article}
\usepackage{multirow, tabularx}
\usepackage[table]{xcolor}
\usepackage{ragged2e}
\newcolumntype{K}{>{\RaggedRight\cellcolor{blue!10}}m{3cm}}

\begin{document}
\begingroup
\renewcommand\tabularxcolumn[1]{ >{\arraybackslash}m{#1}}
\renewcommand*{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{|K|X|X|X|X|}
    \hline
\rowcolor{gray!50}
\textbf{Code 1} & \textbf{Code 2} & \textbf{code3} & \textbf{code 4} & \textbf{code5}\\
    \hline
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz     \\
\cline{2-5}
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz     \\
\cline{2-5}
     & xyzxyzxyz
     & xyzxyzxyz
     & xyzxyzxyz
     & xyzxyzxyz    \\
\cline{2-5}
\multirow{-4}{=}{Long text to break aaaaaa}
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz
    & xyzxyzxyz     \\
\hline
\end{tabularx}
\endgroup
\end{document}

enter image description here

| improve this answer | |

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.