[Tex/LaTex] Color and rules in tables with multirow

colormultirowtables

I have a problem with colors and lines in tables.
I have this code:

\usepackage{multirow}
\usepackage{colortbl}
        \begin{tabular}{ll|c|c|c|c|c|c|}  \cline{3-8} \cline{3-8}
         & & \multicolumn{3}{c|}{\cellcolor{gray!25} Cramér von Mises} & \multicolumn{3}{c|}{\cellcolor{gray!25} Anderson-Darling} \\  \cline{3-8} \cline{3-8}
         & & \cellcolor{gray!25}$\alpha=$0.1 & \cellcolor{gray!25}$\alpha=$0.05  & \cellcolor{gray!25}$\alpha=$0.01 & \cellcolor{gray!25}$\alpha=$0.1 & \cellcolor{gray!25}$\alpha=$0.05 & \cellcolor{gray!25}$\alpha=$0.01 \\ \hline
        \multicolumn{1}{|c}{} & \cellcolor{gray!25}n=25 & 0.106 & 0.063 & 0.015 & 0.107 & 0.052 & 0.012 \\ 
        \multicolumn{1}{|c}{} & \cellcolor{gray!25}n=50 & 0.107 & 0.043 & 0.010 & 0.103 & 0.054 & 0.010 \\ 
        \multicolumn{1}{|c}{\multirow{3}{0.3cm}[7mm]{\begin{sideways}$\qquad$ $Exp(1)$ \end{sideways}}}&\cellcolor{gray!25} n=100 & 0.104 & 0.065 & 0.017 & 0.110 & 0.055 & 0.015 \\ \hline
        \multicolumn{1}{|c}{} & \cellcolor{gray!25}n=25 & 0.113 & 0.055 & 0.014 & 0.097 & 0.058 & 0.016 \\ 
         \multicolumn{1}{|c}{} & \cellcolor{gray!25}n=50 & 0.109 & 0.058 & 0.014 & 0.098 & 0.056 & 0.018 \\ 
         \multicolumn{1}{|c}{ \multirow{3}{0.3cm}[7mm]{\begin{sideways}$\qquad$ $Exp(2)$ \end{sideways}}} & \cellcolor{gray!25}n=100 & 0.110 & 0.048 & 0.011 & 0.108 & 0.044 & 0.009  \\ \hline
          \end{tabular}

I need to color the multirow cell and the only thing I could arise was to color the lower part of it.

My other problem is when I coloured the cells, I cant see properly the rules of the table.

I hope someone can help me.

Thanks!!!!

Best Answer

Always supply a complete, but minimal document. Yours is missing \documentclass as well as \begin and \end document. It is also missing the loading of xcolor (for the color names like gray!25) and rotating (for the sideways environment). To color the whole multirow you need to color all three cells of it. Also, your use of \multirow is incorrect. If you want to put the text into the cells above it, the number should be negative. If you do that, you don't need the optional adjustments of [7mm] nor the \qquads. I've done a few other things I think make the result better: Taking Exp out of math mode, putting the numbers after \alpha= into math mode, removing some errant spaces, and removing most of the vertical lines:

\documentclass{article}
\usepackage{multirow,xcolor,colortbl,rotating}
\begin{document}
\noindent\begin{tabular}{ll|cccccc|}  \cline{3-8} \cline{3-8}
   &&\multicolumn{3}{c} {\cellcolor{gray!25} Cram\'er von Mises}&
     \multicolumn{3}{c|}{\cellcolor{gray!25} Anderson-Darling}\\
  \cline{3-8} \cline{3-8}
   &&\cellcolor{gray!25}$\alpha=0.1 $ &\cellcolor{gray!25}$\alpha=0.05$&
     \cellcolor{gray!25}$\alpha=0.01$ &\cellcolor{gray!25}$\alpha=0.1 $&
     \cellcolor{gray!25}$\alpha=0.05$ &\cellcolor{gray!25}$\alpha=0.01$\\
  \hline
  \multicolumn{1}{|c}{\cellcolor{gray!25}} & \cellcolor{gray!25}n=25 & 0.106 & 
    0.063 & 0.015 & 0.107 & 0.052 & 0.012 \\
  \multicolumn{1}{|c}{\cellcolor{gray!25}} & \cellcolor{gray!25}n=50 & 0.107 & 
    0.043 & 0.010 & 0.103 & 0.054 & 0.010 \\
  \multicolumn{1}{|c}{\cellcolor{gray!25}%
    \multirow{-3}{*}{\begin{sideways}Exp$(1)$\end{sideways}}}&
    \cellcolor{gray!25}n=100 & 0.104 & 0.065 & 0.017 & 0.110 & 0.055 & 0.015 \\
  \hline
  \multicolumn{1}{|c}{\cellcolor{gray!25}} & \cellcolor{gray!25}n=25 & 0.113 &
    0.055 & 0.014 & 0.097 & 0.058 & 0.016 \\
  \multicolumn{1}{|c}{\cellcolor{gray!25}} & \cellcolor{gray!25}n=50 & 0.109 & 
    0.058 & 0.014 & 0.098 & 0.056 & 0.018 \\
  \multicolumn{1}{|c}{\cellcolor{gray!25}%
    \multirow{-3}{*}{\begin{sideways}Exp$(2)$\end{sideways}}}&
    \cellcolor{gray!25}n=100 & 0.110 & 0.048 & 0.011 & 0.108 & 0.044 & 0.009  \\
  \hline
\end{tabular}
\end{document}

(I've also broken the lines so people reading this don't have to scroll three screens over to see the whole code.)

Related Question