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

I'm trying to make a table with the following code:

  \rowcolor[gray]{.9} a & b & c \\

Unfortunately the \rowcolor command seems to not care about the empty leading and ending spaces in the table, i.e. the @{}'s in the tabular 'preamble'.

Any suggestions to overcome this issue are most welcome.

share|improve this question
up vote 8 down vote accepted

  \rowcolor[gray]{.9}[0pt][0pt] a & b & c \\\hline

enter image description here

share|improve this answer
Thank you for the solution! I actually ended up using: \newcolumntype{C}{c<{\kern\tabcolsep}<{\kern\tabcolsep}@{}} since it gave me the same distance between columns. – lysbjerg Nov 17 '11 at 16:48
I think it would make more sense logically to define two new columns L and R (say) - for the left and right no-overhang columns - as \newcolumntype{L}{>{\hspace*{-\tabcolsep}}c} and \newcolumntype{R}{c<{\hspace*{-\tabcolsep}}} and use \begin{tabular}{L..R} without the additional \rowcolor options. That is, just \rowcolor[gray]{.9}. – Werner Nov 17 '11 at 17:03
Works like a charm! And I even understand what the code does :-) – lysbjerg Nov 17 '11 at 17:46

From the userguide of the colortbl package (which provides the commands \columncolor and \rowcolor):

\rowcolor takes the same argument forms as \columncolor. It must be used at the start of a row. If the optional overhang arguments are not used the overhangs will default to ... \tabcolsep ... [emphasis added]

Here, the length \tabcolsep is (half) the width of the intercolumn white space, and equals 6pt by default. However, specifying the \rowcolor command as

\rowcolor[gray]{.9}[][] % empty contents resolve to 0[pt]

will not produce what you're after either, I'm guessing, because this will leave white gaps in the table's two interior columns. The colortbl package doesprovides a \cellcolor command, but unfortunately this command doesn't take left- or right-hand trimming options, so you'd be back where you started out with.

In short, if you insist on using the \rowcolor command, you're probably best served by omitting the @{} specifiers at the far left and far right of the tabular specification.

share|improve this answer
Thank you for your suggestion. That fact that \tabcolsep equals half the width of the intercolumn white space helped me to modify Herbert's solution such that the intercolumn white space is unchanged. – lysbjerg Nov 17 '11 at 16:52

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.