我想为表格标题添加阴影。一切都很顺利,直到我开始使用 \cmidrule。这是我的输出:
有没有办法遮蔽第一行和第二行之间的空白?
下面的代码重新定义了 toprule 和 midrule 命令来考虑标题的阴影。
\documentclass{article}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{colortbl}
%%%%%% Set up the coloured tables %%%%%
\colorlet{tableheadcolor}{gray!25} % Table header colour = 25% gray
\colorlet{tablerowcolor}{gray!10} % Table row separator colour = 10% gray
\newcommand{\headcol}{\rowcolor{tableheadcolor}}
\newcommand{\rowcol}{\rowcolor{tablerowcolor}}
% The top-most line of a table
\newcommand{\topline}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0pt}%
\arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
% The line between the headings and the table body
\newcommand{\midline}{\arrayrulecolor{tableheadcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
\arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
\arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
%%%%%END: Set up the coloured tables %%%%%
\begin{document}
\begin{tabular}{ccc}
\topline
\headcol & A & B\\ \cmidrule{2-3}
\headcol Blue & Red & Yellow\\ \midline
1 & 2 & 3 \\ \bottomrule
\end{tabular}
\end{document}
答案1
空格可以用命令填充\specialrule{<wd>}{<abovespace>}{<belowspace>}
,修改后的表格:
\begin{tabular}{ccc}
\topline
\headcol & A & B\\
\arrayrulecolor{tableheadcolor} \specialrule{6pt}{0pt}{-6pt} \arrayrulecolor{black}
\cmidrule{2-3}
\headcol Blue & Red & Yellow\\
\midline
1 & 2 & 3 \\
\bottomrule
\end{tabular}