Loading the xcolor package with the [table] option provides the command(s) \rowcolors(*) for alternate table row coloring. Any attempt, however, to use \hiderowcolors and \showrowcolors inside table rows within from LyX -- both in- and outisde a LyX table-float -- results in failing to compile a PDF. The error message is: Undefined control sequence.

It seems that there is no discussion/question upon this on either LyX-Users' mailing list or tex.stackexchange itself. It certainly is preferable to resolve this in a clean way, i.e. with a correct usage of the above mentioned commands.


I suspect that you simply haven't left any space between the ERT containing \hiderowcolors/\showrowcolors, so that TeX reads the letter(s) after the command as part of the command. E.g. if you put \hiderowcolors at the start of a table cell, and then write text right after the ERT, without spaces, TeX will see the command \hiderowcolorstext, which is undefined.

Solution: Put a pair of empty braces after \hiderowcolors, within the ERT. (You could also add a space after the ERT, but that will lead to wrong alignment.)

enter image description here

  • I (remember that I) did try that! Will re-try ASAP. Jun 27 '12 at 12:18
  • Grrr... it works! (...I really used a pair of empty braces... :-?) Jun 27 '12 at 12:20
  • Wouldn't it be nice though to be able to instruct \rowcolors{no. of starting row}{no. of ending row}{1st color}{2nd color}? Jun 27 '12 at 12:24
  • @NikosAlexandris You could always ask a new question about that (is it possible/how to do it). Jun 27 '12 at 12:29
  • I think this could be seen as an enhancement request to xcolor... So it'd better be directed to xcolor directly. This is why I did not already asked for that. Jun 27 '12 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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