选定阴影单元格的水平线较粗

选定阴影单元格的水平线较粗

我试图为 2-13 列(以下示例中的 A、B 和 C 列上方)添加一条更粗的水平线。我的代码不适用于阴影列。有什么建议吗?提前致谢。

\documentclass[11pt]{article}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{array}
\usepackage{float}
\restylefloat{table}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{colortbl}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\definecolor{Grey1}{RGB}{243,243,243}
\definecolor{Grey2}{RGB}{191,191,191}
\definecolor{Grey3}{RGB}{163,163,163}
\newcolumntype{A}[1]{>{\raggedleft\arraybackslash\columncolor{Grey1}}m{#1}}
\newcolumntype{B}[1]{>{\raggedleft\arraybackslash\columncolor{Grey2}}m{#1}}
\newcolumntype{C}[1]{>{\raggedleft\arraybackslash\columncolor{Grey3}}m{#1}}

\begin{document}

{\renewcommand{\arraystretch}{1.38}
\begin{table}[!h]
\large
\textbf{Table 1} \\
\vspace{-.35cm}

\textit {\textbf {Summary}}

 \begin{tabular}{!{\vrule width 1.5pt} L{6cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt}}
\noalign{\hrule height 1.5pt}
\multicolumn{1}{!{\vrule width 1.5pt} c !{\vrule width 1.5pt}}{Percent} & \multicolumn{3}{c !{\vrule width 1.5pt}}{\underline {2009}} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2010} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2011} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2012}       \\ [-0.9ex] 
\cline {2-13}
\multicolumn{1}{!{\vrule width 1.5pt} c !{\vrule width 1.5pt}}{(\%)} & A & B & C & A & B & C & A & B & C & A & B & C  \\ [-0.9ex]
\noalign{\hrule height 1.5pt}
Row 1 & 30 & 58 & 12 & 30 & 56 & 14 & 34 & 52 & 14 & 26 & 55 & 19 \\
\arrayrulecolor{black}\hline
Row 2 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\arrayrulecolor{black}\hline
Row 3 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\arrayrulecolor{black}\hline
Row 4 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\arrayrulecolor{black}\hline
Row 5 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\arrayrulecolor{black}\hline
Row 6 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\noalign{\hrule height 1.5pt}
\end{tabular}
\end{table}

\end{document}

答案1

使用最新版本的 可以轻松做到这一点nicematrix

\documentclass[11pt]{article}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{xcolor}
\usepackage{nicematrix}
\usepackage{tikz}

\definecolor{Grey1}{RGB}{243,243,243}
\definecolor{Grey2}{RGB}{191,191,191}
\definecolor{Grey3}{RGB}{163,163,163}
\newcolumntype{A}[1]{>{\raggedleft\arraybackslash}m{#1}}
\newcolumntype{I}{!{\vrule width 1.5pt}}

\begin{document}

\renewcommand{\arraystretch}{1.38}

\begin{NiceTabular}{Iwl{5cm}IA{0.45cm}|A{0.45cm}|A{0.45cm}IA{0.45cm}|A{0.45cm}|%
               A{0.45cm}IA{0.45cm}|A{0.45cm}|A{0.45cm}IA{0.45cm}|A{0.45cm}|A{0.45cm}I}
\CodeBefore
  \rectanglecolor{Grey1}{2-2}{8-2}
  \rectanglecolor{Grey1}{2-5}{8-5}
  \rectanglecolor{Grey1}{2-8}{8-8}
  \rectanglecolor{Grey1}{2-11}{8-11}  
  \rectanglecolor{Grey2}{2-3}{8-3}
  \rectanglecolor{Grey2}{2-6}{8-6}
  \rectanglecolor{Grey2}{2-9}{8-9}
  \rectanglecolor{Grey2}{2-12}{8-12}  
  \rectanglecolor{Grey3}{2-4}{8-4}
  \rectanglecolor{Grey3}{2-7}{8-7}
  \rectanglecolor{Grey3}{2-10}{8-10}
  \rectanglecolor{Grey3}{2-13}{8-13} 
\Body
\noalign{\hrule height 1.5pt}
\Block{1-1}{Percent} & \Block{1-3}{2009} &&& \Block{1-3}{2010} &&& \Block{1-3}{2011} &&& \Block{1-3}{2012} &&\\ 
\cline {2-13}
\Block{1-1}{(\%)} & A & B & C & A & B & C & A & B & C & A & B & C  \\ 
\noalign{\hrule height 1.5pt}
Row 1 & 30 & 58 & 12 & 30 & 56 & 14 & 34 & 52 & 14 & 26 & 55 & 19 \\
\hline
Row 2 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\hline
Row 3 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\hline
Row 4 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\hline
Row 5 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\hline
Row 6 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\noalign{\hrule height 1.5pt}
\CodeAfter
  \tikz \draw [line width = 1.5pt] (2-|2) -- (2-|14) ;
\end{NiceTabular}

\end{document}

上述代码的输出

答案2

由于makecell已经加载,只需替换

\arrayrulecolor{black}\hline

\Xhline{1.5pt}

如下:

\documentclass[11pt]{article}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{array}
\usepackage{float}
\restylefloat{table}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{colortbl}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\definecolor{Grey1}{RGB}{243,243,243}
\definecolor{Grey2}{RGB}{191,191,191}
\definecolor{Grey3}{RGB}{163,163,163}
\newcolumntype{A}[1]{>{\raggedleft\arraybackslash\columncolor{Grey1}}m{#1}}
\newcolumntype{B}[1]{>{\raggedleft\arraybackslash\columncolor{Grey2}}m{#1}}
\newcolumntype{C}[1]{>{\raggedleft\arraybackslash\columncolor{Grey3}}m{#1}}

\begin{document}

{\renewcommand{\arraystretch}{1.38}
\begin{table}[!h]
\large
\textbf{Table 1} \\
\vspace{-.35cm}

\textit {\textbf {Summary}}

\begin{tabular}{!{\vrule width 1.5pt} L{6cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt} A{0.45cm} | B{0.45cm} | C{0.45cm} !{\vrule width 1.5pt}}
\noalign{\hrule height 1.5pt}
\multicolumn{1}{!{\vrule width 1.5pt} c !{\vrule width 1.5pt}}{Percent} & \multicolumn{3}{c !{\vrule width 1.5pt}}{\underline {2009}} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2010} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2011} & \multicolumn{3}{c !{\vrule width 1.5pt}}{2012}       \\ [-0.9ex]
\cline {2-13}
\multicolumn{1}{!{\vrule width 1.5pt} c !{\vrule width 1.5pt}}{(\%)} & A & B & C & A & B & C & A & B & C & A & B & C  \\ [-0.9ex]
\Xhline{1.5pt}
Row 1 & 30 & 58 & 12 & 30 & 56 & 14 & 34 & 52 & 14 & 26 & 55 & 19 \\
\Xhline{1.5pt}
Row 2 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\Xhline{1.5pt}
Row 3 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\Xhline{1.5pt}
Row 4 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\Xhline{1.5pt}
Row 5 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\Xhline{1.5pt}
Row 6 & 20 & 8 & 22 & 40 & 36 & 54 & 3 & 52 & 14 & 26 & 55 & 19 \\
\noalign{\hrule height 1.5pt}
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

相关内容