First, there is not any error message, but I have this problem in which I want to merge rows horizontally, but I do not know why the text appears like that:
Code:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{graphicx,color}
\usepackage{array}
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\arrayrulecolor{gray}
\caption{Statistics}\label{tab8}
\rowcolors{2}{gray!50}{white!10}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{country}} &
\multirow{2}{*}{\textbf{GDP}} &
\multicolumn{2}{|c|}{\textbf{Sex}} \\
& & \textbf{male} & \textbf{female} \\
A&B&C&D\\
A&B&C&D\\
A&B&C&D\\
\end{tabular}
\end{table}
\end{document}
I want the merged cells to be colored with only one color.
Thank you for your help.
Best Answer
By using
\multirow{-2}{*}{text}
you can properly colorize the background of the two rows.Related question: \rowcolor for a \multirow
MWE:
Output: