[Tugindia] Colored tables in LaTeX involving multirow

E. Krishnan ekmath at asianetindia.com
Thu Feb 2 15:25:58 CET 2006


On Thu, 2 Feb 2006, Venkatesh Choppella wrote:

> %%%% TABLE WITH ALTERNATING BLUE AND WHITE ROWS BUT TRYING
> %%%% TO USE \rowcolors or \rowcolor command
> 
> % \rowcolors%[\hline]  %% DOESN'T WORK!
> % {1}{White}{blue!10}
> \begin{center}
>  \renewcommand{\arraystretch}{1.5}
>  \begin{tabular}{|c|c|c|}
>    \hline
>    \multicolumn{1}{|y|}{Yellow}
>    & \multicolumn{2}{g|}{Green}\\
>    \hline
>    \rowcolor{blue!20}  %% DOESN'T WORK.
>                        %% HOW CAN I FIX IT?
>    \multicolumn{1}{|r|}{}
>    Blue & Blue\\

Seems you missed an "&" at the beginning of the last line here. The 
corrected code is given below:

\begin{center}
 \renewcommand{\arraystretch}{1.5}
 \begin{tabular}{|c|c|c|}
   \hline
   \multicolumn{1}{|y|}{Yellow}
   & \multicolumn{2}{g|}{Green}\\
   \hline
   \rowcolor{blue!20}  
   \multicolumn{1}{|r|}{}
   & Blue & Blue\\   %%%%% MISSING "&" INSERTED %%%%%%%%
   \cline{2-3}
   \multicolumn{1}{|r|}{}
   &\multicolumn{1}{w|}{White}
   &\multicolumn{1}{w|}{White}\\
   \cline{2-3}
   \multicolumn{1}{|r|}{}
   &\multicolumn{1}{b|}{Blue}
   &\multicolumn{1}{b|}{Blue}\\
   \cline{2-3}
   \multicolumn{1}{|r|}{%
     \multirow{-4}*{Red}}
   &\multicolumn{1}{w|}{White}
   &\multicolumn{1}{w|}{White}\\
   \hline
   &\multicolumn{1}{|b|}{Blue}
   &\multicolumn{1}{b|}{Blue}\\
   \cline{2-3}
   &\multicolumn{1}{|w|}{White}
   &\multicolumn{1}{w|}{White}\\
   \cline{2-3}
   &\multicolumn{1}{|b|}{Blue}
   &\multicolumn{1}{b|}{Blue}\\
   \cline{2-3}
   \multirow{-4}*{White}
   &\multicolumn{1}{|w|}{White}
   &\multicolumn{1}{w|}{White}\\
   \hline
 \end{tabular}
\end{center}

Note also that I've removed some duplicate "|" (Otherwise some vertical 
separators will be doubly thick).

By the way, please note that when you post, it's not necessary that you
include the entire contents of the last mail at the bottom. Just a
relevant clipping at the appropriate place  will do.

-- 
Krishnan




More information about the tugindia mailing list