[Tex/LaTex] Color merged and regular cells in a table individually

backgroundscolortables

In a LaTeX table with merged cells, how can I color each cell with a different color?

alt text

%% LyX 1.6.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

\makeatother

\usepackage{babel}

\begin{document}
\begin{tabular}{|c|c|c|c|}
\cline{3-4} 
\multicolumn{1}{c}{} &   & \multicolumn{2}{c|}{Overexpression}\tabularnewline
\cline{3-4} 
\multicolumn{1}{c}{} &  & Cancer & Control \tabularnewline
\hline 
Marked & Cancer  & 45  & 61\tabularnewline
\cline{2-4} 
Cell Line & Control  & 42  & 52\tabularnewline
\hline
\end{tabular}
\end{document}

Best Answer

\usepackage[table]{xcolor}
...   
\begin{tabular}{...}
\cellcolor{blue} foo & \cellcolor{red} bar\\

...

There is also a command for coloring whole columns and rows.