Alternating row color two at a time in tables

Here's a possible solution; the idea is to use an auxiliary counter for the rows, and depending on the value of this counter module 4, to set \rownum (internally used to decide wich color apply to a row) to 0 or to 1; the etoolbox package was used to patch tabular to set the row counter to 0:

\documentclass[a4paper]{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{pgf}
\usepackage{etoolbox}

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

\newcounter{row}
\newcolumntype{L}{%
  >{\stepcounter{row}%
  \pgfmathtruncatemacro{\j}{int(Mod(\therow,4))}
  \ifnum\j<2 
    \global\rownum=1
  \else
    \global\rownum=0
  \fi}%
l}

\BeforeBeginEnvironment{tabular}{\setcounter{row}{0}}

\begin{document}

\section{Section}

\begin{tabular}{Lp{10cm}}
\rowcolor{blue!10}Bla1 & reference1 \\
& Description1 \\
Bla2 & reference2 \\    
& Description2 \\
Bla3 & reference3 \\    
& Description3 \\ 
Bla4 & reference4 \\    
& Description4 \\ 
Bla5 & reference5 \\    
& Description5 \\ 
Bla6 & reference6 \\    
& Description6 \\ 
\end{tabular}

\end{document}

enter image description here


You can use xcolor package \rowcolors command but just modify slightly to only change every other row.

\documentclass[a4paper]{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}

\rowcolors{0}{red}{yellow}
\newcount\xrownum
\makeatletter
 \def\@rowc@lors{\noalign{%  
  \global\advance\xrownum\@ne
  \ifodd\xrownum
  \global\advance\rownum\@ne
  \fi
  }\@rowcolors}

\makeatother

\begin{document}

\section{Section}
   \begin{tabular}{lp{10cm}}
    \hline
    \textbf{Col 1} & \textbf{Col 2} \\ \hline
    Bla1 &{reference1} \\
    Bla1 &{reference1} \\
    Bla1 &{reference1} \\
    Bla1 &{reference1} \\
    Bla1 &{reference1} \\
    & Description1 \\ 
    & Description1 \\ 
    Bla2 & {reference2} \\
    & Description2 \\ \hline
\end{tabular}
\end{document}

In ConTeXt, the same idea as Gonzalo's solution can be implemented as follows:

\definecolor[lightblue][r=0.8,g=0.8,b=1]
\defineconversion[tablecolor][lightblue,lightblue,white,white]

\startsetups doublerow:color
  \setupTABLE[row][each]
             [background=color,
              backgroundcolor={\convertnumber{tablecolor}{\positiverow}}]
\stopsetups

\starttext
\startTABLE[setups={doublerow:color}]
  \dorecurse{10}
    {\NC One \NC Two \NC Three \NC \NR}
\stopTABLE
\stoptext

Tags:

Color

Tables