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
\textbf{Heading 1} & \textbf{Heading 2} & \textbf{Heading 3} & \textbf{Heading 4} \\
\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}
Best Answer
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 usebooktabs
and\(top|mid|bottom)rule
instead of\hline
.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?