TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline



\multicolumn{1}{c}{} &   & \multicolumn{2}{c|}{Overexpression}\tabularnewline
\multicolumn{1}{c}{} &  & Cancer & Control \tabularnewline
Marked & Cancer  & 45  & 61\tabularnewline
Cell Line & Control  & 42  & 52\tabularnewline
share|improve this question
up vote 20 down vote accepted
\cellcolor{blue} foo & \cellcolor{red} bar\\


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

share|improve this answer

Put \usepackage[table]{xcolor} in the preamble, use nested tables & these commands:

\rowcolor{}, \columncolor{}

share|improve this answer
Will this work well on merged cells? – denilw Jan 13 '11 at 18:59
@denilw: I don't use merged cells. I use nested tables instead. – xport Jan 14 '11 at 0:43
Hi @xport,that is an interesting idea, could you provide an example of how to do my example with nested tables, and include the colouring? – denilw Jan 15 '11 at 20:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.