7

I am trying to color a multirow in my table, but withou success until now:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{colortbl}
\usepackage{multicol}
\begin{document}
\begin{table}
\begin{tabular}{|l|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{Type} \\
\hline
  & A  &    B & C & D \\
    \hline
    X & 53,2\%  &   51,6\%  &  \multirow{2}{*}{\cellcolor[gray]{.9}49\%} & \multirow{2}{*}{\cellcolor[gray]{0.9}49\% }\\
    Y  & 53,8\%  &  52,2\%  &  & \\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

What should I do, so that the last two multirow-cells are completely grey-colored?

8
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{colortbl}
\usepackage{multicol}
\begin{document}
\begin{table}
\begin{tabular}{|l|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{Type} \\
\hline
  & A  &    B & C & D \\
    \hline
    X & 53,2\%  &   51,6\%  & \cellcolor[gray]{0.9}  & \cellcolor[gray]{0.9}\\
    Y  & 53,8\%  &  52,2\%  & \multirow{-2}{*}{\cellcolor[gray]{.9}49\%} & \multirow{-2}{*}{\cellcolor[gray]{0.9}49\% }\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

First color the upper cells by issuing \cellcolor[gray]{0.9} and then use \multirow n the second row. Note -2 in \multirow{-2}{*}{...}. This will make multi row to grow upwards.

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.