[Tex/LaTex] Lighter midrule

colorrulestables

I have a table that looks like

\documentclass{article}

\usepackage{booktabs}

\begin{document}
\begin{tabular}{cc}
\toprule
A   &   B   \\
\midrule
Q   &   M   \\
W   &   N   \\
E   &   B   \\
R   &   V   \\
T   &   C   \\

Y   &   X   \\
U   &   L   \\
I   &   K   \\
O   &   J   \\
P   &   H   \\

A   &   5   \\
S   &   7   \\
D   &   8   \\
F   &   2   \\
G   &   4   \\
\bottomrule
\end{tabular}
\end{document}

The code has five-line blocks, which can be made distinguishable in the output with \midrule, but I consider that to be too distracting, as would be to number each row. I'd like to have a lighter rule, with tweakable space above and below it. I added some grey lines with Paint to a \midrule-less table.

Forcing a color onto \midrule with either \textcolor or \color produces errors, while using \rule allows coloring but requires making measurements to get the correct width.

L: Goal, R: <code>\midrule</code> attempt

Best Answer

You can use \arrayrulecolor{<colour>} from colortbl to change the colour, and \specialrule{<width>}{<above>}{<below>} to set a rule of specific dimensions:

enter image description here

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{ c c c }
  \toprule
  A   &   B   \\
  \midrule
  Q   &   M   \\
  W   &   N   \\
  E   &   B   \\
  R   &   V   \\
  T   &   C   \\
  \arrayrulecolor{black!30}\midrule
  Y   &   X   \\
  U   &   L   \\
  I   &   K   \\
  O   &   J   \\
  P   &   H   \\
 \arrayrulecolor{black!50}\specialrule{3pt}{2\jot}{1pc}
  A   &   5   \\
  S   &   7   \\
  D   &   8   \\
  F   &   2   \\
  G   &   4   \\
  \arrayrulecolor{black}\bottomrule
\end{tabular}

\end{document}

Note that the rule colour change is global, so you'll have to reset to black if it's been changed before.