# Problem with rowcolor in tables

I have a problem with this table. I have other tables in my document, but rowcolor worked fine. Particularly, this code of my table has something wrong.
I want the header colored with gray.

\documentclass{article}

\usepackage{xcolor}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{caption}
\usepackage{multirow,array}

\begin{document}
\begin{table}[H]
\caption{Title}
\centering
\begin{tabular}{|>{\raggedright\arraybackslash}m{50mm}|>{\raggedleft\arraybackslash}m{20mm}|>{\raggedleft\arraybackslash}m{20mm}|>{\raggedleft\arraybackslash}m{20mm}|}
\hline
\rowcolor{Gray} \multicolumn{1}{|c|}{\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\textbf{Text}}\\
\hline
\rowcolor{Gray} \textbf{Descripción} & \textbf{Nº} & \textbf{Sueldo mes} & \textbf{Total Año}\\\hline
\textbf{Text} & Text & & Text\\
\textbf{Text} & Text & & Text\\
\hline
\end{tabular}

\end{table}

\end{document}


-
@HarishKumar Thanks, but i defined the color in the preamble. I've just change the code. – Isai Jan 19 '13 at 1:42
Your code works for me. May be you need an update of your tex distro.? – Harish Kumar Jan 19 '13 at 1:44
@HarishKumar I have a question, if I define a new row without multicolumn, it works: \hline \hline \rowcolor{Gray} \textbf{Text} & \textbf{Text} & \textbf{Text} & \textbf{Text}\\\hline \hline May have something more in the code of the row where there are multicolumn commands? – Isai Jan 19 '13 at 2:00
It works as it is for me! More details may be needed here. – Harish Kumar Jan 19 '13 at 2:04
@HarishKumar I answered the question, with rowcolor in each cell. Thanks. – Isai Jan 19 '13 at 2:33

For people who has the same problem, this code works for me; I defined the \multicolumn{1}{|c|}{\rowcolor{Gray}\textbf{Text}} for each cell, instead of define de \rowcolor at the beginning of the row.

\documentclass{article}

\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{caption}

\begin{document}
\begin{table}[H]
\caption{Title}
\centering
\begin{tabular}{|>{\raggedright\arraybackslash}m{50mm}|>{\raggedleft\arraybackslash}m{20mm}|>{\raggedleft\arraybackslash}m{20mm}|>{\raggedleft\arraybackslash}m{20mm}|}
\hline
\multicolumn{1}{|c|}{\rowcolor{Gray}\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\rowcolor{Gray}\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\rowcolor{Gray}\textbf{Text}} & \multicolumn{1}{>{\centering\arraybackslash}m{20mm}|}{\rowcolor{Gray}\textbf{Text}}\\
\hline
\textbf{Text} & Text & & Text\\
\textbf{Text} & Text & & Text\\
\hline
\end{tabular}

\end{table}

\end{document}

-
Of course you mean \cellcolor, because \rowcolor there will raise an error. But the table in your question compiles perfectly for me. – egreg Jan 19 '13 at 9:50
@egreg Maybe, the software I use miss some update, as HarishKumar said. I work in Texpad software. Anyway, cellcolor also works for me. – Isai Jan 20 '13 at 18:13