[Tugindia] Colored tables in LaTeX involving multirow

E. Krishnan ekmath at asianetindia.com
Wed Feb 1 17:11:40 CET 2006


On Tue, 31 Jan 2006, CV Radhakrishnan wrote:

> From: Venkatesh Choppella <choppell at gmail.com>
> To: tugindia at tug.org
> Date: Tue, 31 Jan 2006 16:56:59 +0530
> Subject: Colored tables in LaTeX involving multirow
> 
> Are there a set of good examples of doing colored tables that have
> cells spanning multiple rows (multirow).  

> More specifically, how do I generate a colored table with multirow and
> multicolumn with indicated background color (and text)
> entries drawn  schematically (in ascii) in the attached file.  

Here's a (somewhat crude) way of doing it:

\newcolumntype{r}{>{\columncolor{red}}c}
\newcolumntype{g}{>{\columncolor{green}}c}
\newcolumntype{b}{>{\columncolor{blue}}c}
\newcolumntype{y}{>{\columncolor{yellow}}c}

\renewcommand{\multirowsetup}{\centering}

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


-- 
Krishnan



More information about the tugindia mailing list