# Customized table with colored row

How can I create a table like the following?

\documentclass{article}

\usepackage{svg}
\usepackage{amsmath}
\usepackage{float}
\usepackage{comment}
\usepackage{subfig}
\usepackage{url}
\usepackage{physics}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage[super]{nth}
\usepackage{amssymb}
\usepackage[bottom]{footmisc}
\usepackage{multirow}
\usepackage{color,colortbl}

\begin{document}

\begin {table}[H]
\caption {Table Title} \label{tab:title}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
\multirow{2}{*}{A} & \multicolumn{3}{c|}{B} \\
\cline{2-4}
& C & D &F\\
\hline
1 & x &  x & x \\
\hline
2 & x &x & x\\
\hline
3 & x & x& x\\
\hline
% etc. ...
\end{tabular}
\end{center}
\end{table}

\end{document}

• have you tried to create a basic table with the same content? At least this would be a starting point to attract further advice. At the moment it comes across as you wanting someone else to do the hard work for you :-( – Steve Hodgkinson May 9 '16 at 12:03
• Could you please show us what you have already tried in LaTeX in the from of a minimal working example (MWE)? – ienissei May 9 '16 at 12:06
• This one I made by Microsoft Word. But I have a similar table in latex without the coloring. I used "\usepackage[table]{xcolor}" and I got errors. I wanted to see if there is another approach than using \multicolumn and \multirow that is compatible with the coloring of certain cells. – faf May 9 '16 at 12:15
• @PeterEbelsberger A Minimal Working Example is added 20 min ago! – faf May 9 '16 at 12:46
• @faf a MWE must be compilable --- starting from \documentclass and adding all the needed packages. Yours is just a snippet... – Rmano May 9 '16 at 13:25

Similar solution, other package:

\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\begin{document}
\begin {table}[h]
\caption {Table Title} \label{tab:title}
\begin{center}
\begin{tabular}{c c c c c}
\rowcolor{Gray}
\multicolumn{1}{c}{A} & \multicolumn{2}{c}{B} & \multicolumn{1}{c}{C} & \multicolumn{1}{c}{D} \\
\hline
\rowcolor{Gray}
& E & F & &\\
1 & x &  x & x \\
2 & x &x & x\\
3 & x & x& x\\
\hline
% etc. ...
\end{tabular}
\end{center}
\end{table}


produces the following table.

• @faf good that the above solution was useful. It will help others with similar issues if you mark the answer as accepted (by clicking on the tick) ;-) – Steve Hodgkinson May 10 '16 at 7:48

I edited your code a bit and now it looks like this:

Here is the code:

\begin {table}[H]
\caption {Table Title} \label{tab:title}
\centering
\begin{tabular}{|c|c|c|c|c|}
\toprule
\rowcolor{Gray} & \multicolumn{2}{c|}{B}  &  &\\
\cline{2-3}
\rowcolor{Gray}\multirow{-2}{*}{A}&E&F&\multirow{-2}{*}{C}&\multirow{-2}{*}{D}\\
\midrule
1 & x &  x & x &x\\
\midrule
2 & x &x & x&x\\
\midrule
3 & x & x& x&x\\
\bottomrule
% etc. ...
\end{tabular}
\end{table}


I also replaced your \hline by \top-/mid-/bottomrule as it makes nicer tables. I also replaced \begin{center}...\end{center} through \centering.

Unfortunately, your \cline won't be visible as the color hides the line. The reason for this you can also see here in a former asked question.

• Thanks! Which package should I use with it? – faf May 9 '16 at 13:03
• You need these packages: \usepackage{multirow} \usepackage{booktabs} \usepackage[table, dvipsnames]{xcolor} – SeRe May 9 '16 at 13:09
• I'm getting again this error. "option clash for package xcolor." P.S. I'm using Overleaf, but it shouldn't matter I guess. – faf May 9 '16 at 13:11
• Okay, then you are using a package, which already loads xcolor. Do you use tikz? – SeRe May 9 '16 at 13:17
• you get option clashes with \usepackage[table]{xcolor} with other packages, for example \usepackage{textgreek}. What does the editor in Overleaf flag up? – Steve Hodgkinson May 9 '16 at 13:18