LaTex Table with Colored alternate Rows


To highlight alternate rows in a table with different colors, use the command

\rowcolors{1}{blue!15}{white}

{2} \rightarrow row number from where alternate colors should start. Row ‘2’ in this case.
{blue!15} \rightarrow start with blue color.
{white} \rightarrow alternate row color is white
Swap the colors, to change the colors ordering.

You have to add ‘xcolor’ package to preamble

\usepackage[table]{xcolor}

Here is an example code for creating alternate row colored table in \LaTeX. You can try online code compilation [here].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\documentclass[11pt,a4paper]{article}
\usepackage[table]{xcolor}    
 
\begin{document}
  \rowcolors{2}{blue!15}{white}   
  \begin{tabular}{|c | c|}
    \rowcolor{blue!50}              % Heading with different color to highlight it      
    Heading1       & Heading2       \\ \hline
    Row 1 column 1 & Row 1 column 2 \\
    Row 2 column 1 & Row 2 column 2 \\
    Row 3 column 1 & Row 3 column 2 \\
    Row 4 column 1 & Row 4 column 2 \\
    Row 5 column 1 & Row 5 column 2 \\ \hline
  \end{tabular}
\end{document}

Here is the screenshot of the compiled output
table-alternate-row-colors

But I remember there was an issue when specified that way and did not produce the desired output for me in beamer. The following code worked out for me in a beamer presentation

\documentclass[xcolor=table]{beamer}
\usepackage{xcolor}

Leave a Comment