# Table cell with unwanted black background

I'm trying to create the following table, but the first cell has a black background. How can I get rid of it? I need alternate colors and multiple rows feature provided by tabularx.

\documentclass[]{article}

\usepackage[table]{xcolor}
\usepackage{tabularx}

\begin{document}

\begin{table}[h]
\centering
\caption{Points}
\label{tab:Points}
\begin{tabularx}{.9\textwidth}{cccX}
\hline
\hline
1 & a & 10 & Some text, Some text, Some text, Some text, Some text  \\
\rowcolor[gray]{0.90}1 & b & 4 &  \\
1 & c & 4 &  \\
\rowcolor[gray]{0.90}1 & d & 4 & Some other text, Some other text \\
1 & e & 4 &  \\
\hline
Total &  & 26 &  \\
\rowcolor[gray]{0.90} \hline
\end{tabularx}
\end{table}

\end{document}

• It comes from the last, strangely-located, \rowcolor[gray]{0.90}... – Werner Mar 4 '16 at 17:38

The problem is cause by the \rowcolor command in the last line of your {tabular}. Just remove it ;-)

By the way. You could use \rowcolors to automatically change the colors of the rows. Furthermore I recommend to use booktabs and \(top|mid|bottom)rule instead of \hline.

\documentclass[]{article}

\usepackage{tabularx}
\usepackage[table]{xcolor}

% fix for \rowcolors in {tabularx}, see https://tex.stackexchange.com/a/297357/4918
\newcounter{tblerows}
\expandafter\let\csname c@tblerows\endcsname\rownum

\usepackage{booktabs}

\begin{document}

\begin{table}[h]
\centering
\caption{Points}
\label{tab:Points}
\rowcolors{2}{}{black!10}
\begin{tabularx}{.9\textwidth}{cccX}
\toprule
\midrule
1 & a & 10 & Some text, Some text, Some text, Some text, Some text  \\
1 & b & 4 &  \\
1 & c & 4 &  \\
1 & d & 4 & Some other text, Some other text \\
1 & e & 4 &  \\
\midrule
Total &  & 26 &  \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}


For some reason with {tabularx} the {2} argument of \rowcolors is ignored, which is not the case for {tabluar} … I ask a new question regarding this issue: Why is the start row of \rowcolors ignored in tabularx?