color rows on table (Tabu package)

I am writing a table with colored rows using the tabupackage (2.10). For example

\documentclass[12pt]{article}
\usepackage{tabu}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}
\rowcolors{2}{red}{blue}
\begin{tabu}{cc}
\toprule
Row1 & A \\
Row2 & B \\
Row3 & C \\
\bottomrule
\end{tabu}
\end{table}
\end{document}


I have also tried with \taburowcolors 2{red ... blue} but the colors never show up at all.

I am aware of the issue at the github repo https://github.com/tabu-fixed/tabu/issues and even after manually updating to the 2.10 release, the problem still persists for me.

Does anyone know if the problem has been fixed? If so, how can I get the colored table.

It is worth to mention that I am using the tabuenviroment as I will be using the columns with custom lengths X[n]. Is there any other alternative to tabu where I can set up the length of the columns?

• You could switch to the tabularx package. Jun 7, 2019 at 15:30
• @leandriis I am not aware of an easy way of set custom column width with the tabularx package Jun 7, 2019 at 15:32
• Changing the column width of tabularx X type columns can be done using >{\hsize=2\hsize}X see for example: tex.stackexchange.com/a/337578/134144 Jun 7, 2019 at 15:37
• No the problem hasn't been fixed. Read carefully the readme of the github you mentioned before continuing to use tabu. Jun 7, 2019 at 16:47

like this?

Why not use tabu package is explained in comments below your question ...

Solution can be use tabularx instead of tabu and boldline for horizontal lines with adjusted thickness (instead booktabs rules, which have (white) space above/below rule):

\documentclass[12pt]{article}
\usepackage{boldline}% for rules, part of Shipunov bundle
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[table]{xcolor}
\newcounter{tblerows}% see https://tex.stackexchange.com/questions/297345/
% why-is-the-start-row-of-rowcolors-ignored-in-tabularx
\expandafter\let\csname c@tblerows\endcsname\rownum

\begin{document}
\begin{table}
\rowcolors{2}{red!30}{blue!30}
\begin{tabularx}{0.5\linewidth}{>{\hsize=1.5\hsize}C
>{\hsize=0.5\hsize}C
}
\hlineB{2}
Row1 & AA AA \\
Row2 & B \\
Row3 & C \\
\hlineB{2}
\end{tabularx}
\end{table}
\end{document}


The same question has been submitted in GitHub, see Simplest MWE to have an alternating row color #18. The proposed solution for the version v2.9 2019/01/11 of tabu comments some commands, see Figure. For further details, please check the solution provided in GitHub.

I try this fix in tabu.sty (v2.9) and does what you are looking for. Maybe it will be fixed in the next release of tabu.

In any case, please consider the above remark of Ulrike Fisher and thus the solution proposed by Zarco.