[Tex/LaTex] Adding background color to table cells in LyX

backgroundscolorlyxtables

I'm doing some tables using LyX and I tried to set a color background in the cells , but I got this error:

Undefined control sequence

\rowcolor
         {cyan} &
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

I added this code in the cell: \rowcolor{cyan}, and I tried almost with this: \cellcolor{cyan}, but it doesn't work. I searched on the Internet some help about of how to set the color background in the cells, and some pages mentioned the package colortbl (but how can I use it, how does it works or what configuration in LyX do I need to change?)

I'll appreciate any help.

Best Answer

As Kevin has already pointed out in his comment: Load the colortbl package in the preamble.

In the case of LyX, it is generally a good idea to take a look into it's documentation before searching the internet: The necessary steps (including an example of using \rowcolor) are described precisely in Section 2.1.1 Colored Tables of the Embedded Objects Manual, which is available from the Help menu within LyX:

enter image description here

[...]

enter image description here