# Table: colored row not aligned with toprule

I am creating a table with colored rows. The problem is that the colored strip is not aligned with the top rule, as shown in figure. How can I solve it? Thank you.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,italian]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{color, colortbl}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\usepackage[first=0,last=9]{lcg}
\newcommand{\ra}{\rand0.\arabic{rand}}

\begin{document}
\title{Title}
\author{Me}
%\date{10 dicembre 2015}

\maketitle

\begin{center}
\begin{tabular}{@{} lrr @{}}
\toprule
& \textbf{GE90} & \textbf{PW4000-100}\\
\midrule
\rowcolor{LightCyan}
\textbf{Company} & General Electric & Pratt \& Whitney\\
\textbf{Velivolo} & Boeing 777 & Airbus A330\\
\rowcolor{LightCyan}
\textbf{Pressure ratio} & 37.8 & 32.0 \\
\textbf{BPR} & 8.4 & 5.0\\
\rowcolor{LightCyan}
\textbf{Spinta al Take-off} (N) & 375300 & 286910\\
\textbf{Spinta al cruise} (N) & 69200 & 78071\\
\bottomrule
\end{tabular}
\captionof{table}{Caratteristiche della piastra e del canale}
\label{tab:dati_canale-piastra}
\end{center}

\end{document}


\rowcolor has two optional arguments (after the color name), the first optional argument has the left overhang, the 2nd one stands for the right overhang. As far as I know, the overhang defaults to 6pt.

If the left overhang should be killed, use [0pt]

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,italian]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{color, colortbl}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\usepackage[first=0,last=9]{lcg}
\newcommand{\ra}{\rand0.\arabic{rand}}

\begin{document}
\title{Title}
\author{Me}
%\date{10 dicembre 2015}

\maketitle

\begin{center}
\begin{tabular}{@{} lrr @{}}
\toprule
& \textbf{GE90} & \textbf{PW4000-100}\\
\midrule
\rowcolor{green}[0pt]
\textbf{Company} & General Electric & Pratt \& Whitney\\
\textbf{Velivolo} & Boeing 777 & Airbus A330\\
\rowcolor{green}[0pt]
\textbf{Pressure ratio} & 37.8 & 32.0 \\
\textbf{BPR} & 8.4 & 5.0\\
\rowcolor{green}[0pt]
\textbf{Spinta al Take-off} (N) & 375300 & 286910\\
\textbf{Spinta al cruise} (N) & 69200 & 78071\\
\bottomrule
\end{tabular}
\captionof{table}{Caratteristiche della piastra e del canale}
\label{tab:dati_canale-piastra}
\end{center}

\end{document}


• I changed the color to make it more outstanding (only for this screenshot). I would not recommend it for the real document of course – user31729 Dec 17 '15 at 18:28
• To my taste is such cases better not use @{} on begin and end of table option field. Result is nicer and aligning of colored rows with others is correct. However, tastes are different :-) – Zarko Dec 17 '15 at 18:30
• @Zarko: I agree, but at the moment I leave it as it is. You can of course provide another (better!) solution! – user31729 Dec 17 '15 at 20:58

This is not better solution as provided Christian Hupfer, actually, as question indicate problem with MWE, it is only possible. However, use of @{} on begin and on end table columns is usual last (desperate) measure to fit table in text width. As can be concluded from given MWE, this is not a case, so the both @{} can be omitted. By this the problem of protrusion of colored rows out of table disappear:

    \begin{tabular}{>{\bfseries}l r r}
\toprule
& \textbf{GE90}     & \textbf{PW4000-100}\\
\hline%midrule
\rowcolor{green}
Company                     & General Electric  & Pratt \& Whitney\\
Velivolo                    & Boeing 777 & Airbus A330\\
\rowcolor{green}
Pressure ratio              & 37.8              & 32.0 \\
BPR & 8.4 & 5.0\\
\rowcolor{green}
Spinta al Take-off $(N)$    & 375300            & 286910\\
Spinta al cruise $(N)$      & 69200             & 78071\\
\bottomrule
\end{tabular}