I’m trying to create a table in my tex document that resembles more or less the table in the picture below:

enter image description here

I found this chunk of code but still, I don’t know how to separate each table as it appears in the picture.

\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{colortbl}% http://ctan.org/pkg/colortbl
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{graphicx}% http://ctan.org/pkg/graphicx

\colorlet{tableheadcolor}{gray!25} % Table header colour = 25% gray
\newcommand{\headcol}{\rowcolor{tableheadcolor}} %
\colorlet{tablerowcolor}{gray!10} % Table row separator colour = 10% gray
\newcommand{\rowcol}{\rowcolor{tablerowcolor}} %
    % Command \topline consists of a (slightly modified) \toprule followed by a \heavyrule rule of colour tableheadcolor (hence, 2 separate rules)
    % Command \midline consists of 3 rules (top colour tableheadcolor, middle colour black, bottom colour white)
    % Command \rowmidlinecw consists of 3 rules (top colour tablerowcolor, middle colour black, bottom colour white)
    % Command \rowmidlinewc consists of 3 rules (top colour white, middle colour black, bottom colour tablerowcolor)
    % Command \rowmidlinew consists of 1 white rule
    % Command \rowmidlinec consists of 1 tablerowcolor rule
    % Command \bottomline consists of 2 rules (top colour


  \headcol Approach & Estimator & ME & MAE \\
  & $\widehat{JV}_{\text{na\"ive}}$ & 4.37e-07 & 4.37e-07 \\
  \rowcol \smash{\raisebox{1em}{Na\"ive}} & $\widetilde{JV}_{\text{na\"ive}}$ & 3.88e-07 & 3.88e-07 \\
  & $\widehat{JV}$ & 1.33e-06 & 1.33e-06 \\
   \rowcol \smash{\raisebox{1em}{Regular}} & $\widetilde{JV}$ & 1.20e-06 & 1.20e-06 \\


2 Answers 2



\begin{tabular}[t]{c !{\color{white}\vrule width3pt} c !{\color{white}\vrule width3pt} c }
\rowcolor{black}\textcolor{white}{Movies} &\textcolor{white}{Ratings}\\\SR
\rowcolor{gray!25}ID & Movie ID\\\SR
\rowcolor{gray!10}Title (Year) & User ID\\\SR
\rowcolor{gray!25}Genre List & Rating \\\SR
                             & \cellcolor{gray!10}Timestamp


enter image description here

  • 1
    The row sep of each "normal" row (not the top row) is smaller.
    – user156344
    May 20, 2019 at 7:15
  • When I load \arrayrulecolor{white}\arrayrulewidth=1pt in the preamble, all the lines from the other tables disappear, or turn into white and you can't see them! How can I fix it?
    – NaveganTeX
    May 20, 2019 at 7:59
  • @naveganteX, you need change rules inside of group.it can be define for example { before definitions of commands and } after table.
    – Zarko
    May 20, 2019 at 10:22
  • 1
    see edited answer
    – user187802
    May 20, 2019 at 10:36

This might be an unpopular opinion, but the best way to use alternating colours in tables is to not use them. The trend to have alternating row colours goes back to word who used it at one point as default formatting. However this does not mean that this is good practise. Due to the changing background colour, the contrast between the font and the background gets reduces which actually makes it harder to read. I suggest to use a clean and professional looking design instead:




Movies & Ratings & Tags\\
ID & Movie ID & User ID\\
Title (Year) & User ID & Movie ID\\
Genre List & Rating & Tag\\
& Timestamp & Timestamp\\


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .