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

Sometimes you can see in books tables, that have alternating background color for rows in a table to support readability. How I can achieve this with LaTeX?

And yes, I could put macros \odd and \even into each row, but in that case I would have to change all following rows, if I input later another row into the table. I want TeX to decide itself, which row is odd or even and put the appropiate style into it.

share|improve this question
up vote 82 down vote accepted

You can use the features of the colortbl package with additions of xcolor. See code below for a small example.

\usepackage[table]{xcolor}    % loads also »colortbl«

    Table head & Table head \\
    Some values & Some values \\
    Some values & Some values \\
    Some values & Some values \\
    Some values & Some values

enter image description here

The particular package manuals have the details.

share|improve this answer
You beat me by 20 seconds. +1 – lockstep Nov 14 '10 at 13:24

This can easily be achieved using xcolor. It is explained at Wikibooks, you just add the table option to \usepackage{xcolor} and in the table itself you put

share|improve this answer

One thing that might be worth pointing out, is that apparently, many packages call on xcolor, and I had endless clashes first time I tried it, and it took me such a long time to figure this one out, so I felt it might help someone as slow as me to mention this: The xcolor package should be loaded last (or at least after the clashing packages).

share|improve this answer
Thanks, I could reproduce the clash, but had it not in first place, because I added it at the end anyways. But that was pure chance, so others might run into this problem. – Mnementh Nov 14 '10 at 18:14
I had that clash using beamer. Since beamer loads xcolor internally, you cannot add \usepackage[table]{xcolor} just to specify the table option. Therefore you have to put the line \PassOptionsToPackage{table}{xcolor} before the \documentclass{..}. Hope somebody else can use this :-) – Bertram Nudelbach Jun 6 '12 at 7:39
Thank you Bertram, this was exactly the solution I was looking for. I was using the tufte-book class. Now it works flawlessly ;) \PassOptionsToPackage{table}{xcolor} \documentclass{..} – user28917 Apr 12 '13 at 13:16
Another approach which might be worth trying in this case (xcolor already loaded by another package): just load colortbl instead of xcolor. – Paul Paulsen Feb 6 '15 at 17:33

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.