3

I was trying to add a thicker horizontal line for columns 2-13 (above columns A, B, and C in the following example). My code did not not work for shaded columns. Any suggestions? Thanks in advance.

\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}

2 Answers 2

2

It's possible to do that easily with the latest version of 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}

Output of the above code

0
1

Since makecell is already loaded, just replace

\arrayrulecolor{black}\hline

with

\Xhline{1.5pt}

as follows:

\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}

enter image description here

2
  • I think the OP wanted a heavy rule above the columns A, B, C, etc. It's difficult because the \clines protude in the following row and are shadowed by the colored panels of the following row. Commented Jun 17, 2020 at 14:06
  • I don't know how, but I've mistaken rows for columns (^^ゞ Commented Jun 18, 2020 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .