Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm making a table with tabu having alternating row color, but I'm getting a pink row, which is not a color that I defined.

The code:

\definecolor{lightb}{RGB}{217,224,250}
\begin{table}
    \begin{tabu}{>{\bfseries}lX[l]}
        \toprule
        \taburowcolors{lightb..white}
        Row1 & #1 \\
        Row2 & #2 \\
    Row3 & #3 \\
        \bottomrule
    \end{tabu}
\end{table}

And the result:

output

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

It is because tabu does not use “real” alternate colors but colorseries provided by package xcolor.

\documentclass{article}
\usepackage{tabu,booktabs}
\usepackage[table]{xcolor}

\begin{document}

\noindent
\definecolor{lightb}{RGB}{217,224,250}
\begin{table}
    \begin{tabu}{>{\bfseries}lX[l]}
        \toprule
        \taburowcolors[1]3{lightb..white}
        Row1 & 1 \\
        Row2 & 2 \\
    Row3 & 3 \\
        \bottomrule
    \end{tabu}
\end{table}
\end{document}

enter image description here

Changing to \taburowcolors[1]4{lightb..white} gives

\documentclass{article}
\usepackage{tabu,booktabs}
\usepackage[table]{xcolor}

\begin{document}

\noindent
\definecolor{lightb}{RGB}{217,224,250}
\begin{table}
    \begin{tabu}{>{\bfseries}lX[l]}
        \toprule
        \taburowcolors[1]4{lightb..white}
        Row1 & 1 \\
        Row2 & 2 \\
    Row3 & 3 \\
    Row4 & 4 \\
    Row5 & 5 \\
        \bottomrule
    \end{tabu}
\end{table}
\end{document}

enter image description here

Coloring with table option of xcolor

If you want alternating rows between two colors (lightb and white) as said in the comment, you may go with xcolor and its table coloring.:

\documentclass{article}
\usepackage{tabu,booktabs}
\usepackage[table]{xcolor}
%\definecolor{headercolor}{rgb}{0.392,0.584,0.929}
%\definecolor{oddrowcolor}{rgb}{0.961,1.000,0.980}
%\definecolor{evenrowcolor}{rgb}{0.902,0.902,0.980}
%\definecolor{white}{rgb}{1.0,1.0,1.0}
\usepackage{booktabs}

\begin{document}

\noindent
\definecolor{lightb}{RGB}{217,224,250}

\begin{table}
\rowcolors{1}{lightb}{white}%
    \begin{tabu}{>{\bfseries}lX[l]}
        \toprule
        %\taburowcolors[1]4{lightb..white}
        Row1 & 1 \\
        Row2 & 2 \\
    Row3 & 3 \\
    Row4 & 4 \\
    Row5 & 5 \\
        \bottomrule
    \end{tabu}
\end{table}
\end{document}

enter image description here

share|improve this answer
    
Thank you for answering, but if I want alternating rows between two colors (lightb and white) ? –  regisk7 Dec 25 '12 at 12:30
    
Are there big differences? –  regisk7 Dec 25 '12 at 12:45
    
@regisk7: See the update using xcolor. –  Harish Kumar Dec 25 '12 at 14:45
add comment

Your Answer

 
discard

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.