I have a working table with cell colors:

\begin{tabular}{l l l}
        & A        & B\\
Test1   & \gr Good & \re Bad \\
test2   & \ye OK   & \re Bad \\
test3   & \gr Good & \re Good \\

However it would improve the readability a lot, if I there were some spacing between the colors, just like the examples on page two of The official guide.

Based on section 4.3 and 4.1 in this guide I have tried both:


Both of those throws these two errors (multiple times) when I compile.

! Missing number, treated as zero.
! Illegal unit of measure (pt inserted).

If i try any of


The text [0.5][0.5] is just inserted as normal text.

So my question is: How to add padding/spacing to the \cellcolor command, so I achieve a small white border between the cells? Preferably I would be able to control vertical and horizontal padding sperately


\tabcolsep is a length so you can set


before the table to set the spacing between columns, then use a smaller amount (such as 0pt in the color optional arguments so perhaps


note it has to have a unit such as pt not a number as in the examples in your question.

  • 8
    Tried it out. The '\tabcolsep' seems to work fine, but '\cellcolor{green}[1pt]' still only puts [1pt] as text into the cell. Is there a command length for rows, '\tabrowsep' doesn't works – Bittenus May 30 '12 at 8:48

I have found a half solution. It only solves vertical spacing, and is a bit hacky.

The solution is to use \midrule defined in booktabs to create the spacing. A normal \hrule or \hline does not work. To avoid the black ruler simply make it white using \arrayrulecolor{white} so the entire table will look like:

\begin{tabular}{l l l}           \toprule
        & A        & B        \\ \toprule
Test1   & \gr Good & \re Bad  \\ \midrule
test2   & \ye OK   & \re Bad  \\ \midrule
test3   & \gr Good & \gr Good \\ 
\arrayrulecolor{black}           \bottomrule

I know it's not pretty, but it works - for row seperation =).

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.