1. To do alternating row colors, you can also include the xcolor package with the table option (i.e. \usepackage[table]{xcolor}), and immediately preceding the tabular environment use the command


    — this will produce a table with colored rows, starting at the row indicated by start, with odd rows colored color1 and even rows colored color2.

    A bit simpler than putting the rowcolor command before each row.

  2. Julia Sokol

    For some reason using the \rowcolors command seems to do strange things to the table’s border colours. Especially if this table moves to a different part of the page. Very frustraiting.

    • Hi Julia,

      Could you send a small code example for illustration. I’d be interested to see that and might be able to help…

  3. Mallika Thomas

    Do you know whether it’s possible to have the highlighting get turned on piecewise in a beamer presentation?

    • Hi Mallika,

      Either you could repeat the entire table as shown in the code below or use a more sophisticated solution proposed here.

      \hline \hline
  4. Thanks for this – really helpful. I just wanted to say that \columncolor doesn’t work well with \cline – the colour of the column obscures the line – and that if you wish to colour a table that uses \cline you should switch to \hhline instead.

    • tom

      Hi there,

      Thanks for your comment. Here is a simple example:

      \usepackage{xcolor, colortbl}

      I know there’s an issue with figures and attachement on my blog. Will fix it asap.

      Cheers, Tom.

  5. Vincent

    Hi Tom,

    I have been trying to re-do your combination example, but the borders of some columns are misteriously disappearing… Here is my code :

    \usepackage{color, colortbl}
    	col1 & col2 & col3 & col4 & col5 & col6 & col7 \\
    	a & b & c & d & e & f & g \\
    	0 & 1 & 2 & 3 & 4 & 5 & 6 \\
    	9 & 8 & 7 & 6 & 5 & 4 & 3 \\
    	z & y & x & w & v & u & t \\

    Some vertical lines are missing and the one to the left is disappearing only for the white rows.
    Thank you in advance for your help.

    • tom

      Hi Vincent,

      Thanks for the nice code example. Unfortunately, I’m not able to reproduce the issue. I can see all vertical lines. Make sure it’s not just the rendering on your screen by zooming in onto the table.

      You may want to try the following line of code. Let me know if the vertical lines still disappear.

      \begin{tabular}{|c|*{6}{>{\hspace{-\tabcolsep}\,}b< {\hspace{-\tabcolsep}\,}|}}[\sourcecode] I got the code from here.

Leave a Reply