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

         {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.

  • 4
    Welcome to TeX.SX! It's probably because you haven't loaded the colortbl package, which defines the rowcolor command. To load the package, go to Document>Settings, scroll down the left panel to find LaTeX Preamble, and add the line \usepackage{colortbl}.
    – Herr K.
    Jun 11, 2014 at 22:37
  • Thank you, dude, I'm new in TEX.SX and LaTeX. It works, but the lines of the cell are now of the color of the bakground cell (not black). How can fix it?
    – ArCiGo
    Jun 11, 2014 at 22:56
  • 1
    I'm not sure I follow what you're saying. Can you edit the question to make it clearer? A screenshot and some code snippet would be helpful as well.
    – Herr K.
    Jun 11, 2014 at 23:13
  • @KevinC For example, I used \rowcolor to fill the header of lightgray, and I got this: link
    – ArCiGo
    Jun 14, 2014 at 17:44

3 Answers 3


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


In LyX insert a


into Document->Preferences->Preamble (Preamble is on the lower left side)


In the first step add \usepackage{colortbl} to the LaTeX preamble. After that at the start of every row type this command:


For example:

\begin{tabular}{c c }
\rowcolor[gray]{0.95}  { a & b}\\
\rowcolor[gray]{0.95}  { c & d}\\

In many journals authors use gray color for tables.

  • 1
    A full example would make this a full solution ;-)
    – user31729
    Aug 4, 2014 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .