6

How to remove the extra color on the left and right of the rows?

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{array}
\setlength{\arrayrulewidth}{0.5mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.3}

\begin{document}
{\rowcolors{2}{gray!40}{gray!20}
\begin{table}
\centering
\caption{Table 1}
\bigskip
\label{tab:1}
\begin{tabular} [H]{@{} l l l@{}}
    \toprule
    xxx & xxx & xxx \\
    \midrule
    111 & 222 & 333 \\
    444&555&666\\
    \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

  • remove @{} in table columns specification! – Zarko Nov 18 '16 at 21:36
  • But I don't want extra space. – Muhammad Abdulrasool Nov 18 '16 at 21:38
  • you define "extras space", so i dont' understant what you like to obtain. if you like to have only "extra" space between column, you need to redefine table layout. can you define its width in advance? – Zarko Nov 18 '16 at 21:41
  • What I want is to get rid of the extra color (out of the lines border) and to fill the first and last row (not the head) to fill the white area. – Muhammad Abdulrasool Nov 18 '16 at 21:50
6

Is this what you want?

To get rid of the white space around the rules, you have to reset the value of both \aboverulesep and \belowrulesep to zero. The default values are \belowrulesep=.65ex and \aboverulesep=.4ex for booktabs.

\documentclass[12pt,a4paper]{report}
\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{array}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.3}   
\begin{document}

\begin{table}[H]
\centering
\caption{Table 1}
\bigskip
\label{tab:1}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\rowcolors{2}{gray!40}{gray!20} 
\begin{tabular}{>{\hspace{-1\tabcolsep}}l l l<{\hspace{-1\tabcolsep}}} 
    \toprule  
    xxx & xxx & xxx \\ \midrule
    111 & 222 & 333 \\
    444 & 555 & 666 \\ \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

  • Thanks, How to fill the white area in the first and last row? – Muhammad Abdulrasool Nov 18 '16 at 21:57
  • Well, I edited my answer to remove that white space – AboAmmar Nov 18 '16 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.