# Background for table cells in LyX

The title speaks for itself - how do I choose a background color for table cells in LyX?

-
This isn't nearly as easy as you think it is. Short answer is that there is no easy way to do this in LyX. – Seamus Apr 6 '11 at 14:58

Please check out the (excellent!) Embedded Objects manual that comes with Lyx (directly available from the Help menu). Section 2.11 describes in detail how to color tables, table cells, and cell backgrounds.

As Martin has already pointed out, the solution is based on colortbl:

which leads to this PDF output:

-
@Icoo it's a shame to choose one of your answers as Icoo gave the correct explanation and Daniel gave a great example. Would you consider merging your answers? – Amir Rachum Jun 6 '11 at 12:25
@Amir Rachum: Merging answers is not possible and it is quite common that a question triggers more than one good answer. Just accept the one that has been most helpful for you. Having to choose is both, fate and fortune, of the questioner :-) – Daniel Jun 6 '11 at 14:42
I'm well aware of the capabilities of SE, I was merely suggesting one of you editing the other's answer into his. Nevermind, thanks! – Amir Rachum Jun 6 '11 at 18:16
@Amir Rachum: Ah, I see. However, simply editing Martin's answer (which is good "as is", there is no point in changing much) into mine would feel a bit like cheating on him. – Daniel Jun 6 '11 at 21:15
Answer below is more general and LaTeX oriented. This answer is more LyXy. Read both of them and you know what to do (they cite the same document anyway). – Josef Kufner Jan 23 '15 at 10:59

I found this. Maybe it can help. It seems it's what you are looking for:

http://wiki.lyx.org/LyX/Tables#toc7

To create colored tables, we need the LaTeX-package colortbl, that is loaded in the preamble with the line

\usepackage{colortbl}


The color of a column is adjusted with the command

\columncolor{name of color}


inside the command >{ }. The following color names are predefined:

red, green, yellow, blue, cyan, magenta, black and white

We also define our own color with the command

\definecolor{color name}{color model}{color values}


The color model can be

cmyk: cyan magenta yellow black

rgb: red, green blue

gray

and the color values are comma separated numbers between 0 and 1 describing the factor for the corresponding color of the color model.

We can e.g. define the color "darkgreen" in the preamble with

\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}

-
Could you add the relevant information from the link you provided? We like answers here to be self contained. – Seamus Apr 6 '11 at 16:42