如何去除行左右两侧多余的颜色?
\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}
答案1
这是你想要的吗?
要消除 s 周围的空白,您必须将和rule
的值都重置为零。booktabs 的默认值为和。\aboverulesep
\belowrulesep
\belowrulesep=.65ex
\aboverulesep=.4ex
\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}