How do I change the thickness and color of \hline on a table simultaneously?

It is easy to change the color or thickness of \hline in a table, but I want to change color and thickness which is hard for me...

\documentclass{article}
\usepackage{colortbl}

\begin{document}
\begin{tabular}{c}
\arrayrulecolor{red}\hline
a \\
\arrayrulecolor{green}\hline
\end{tabular}
\end{document}


The thickness of \hline is controlled by \arrayrulewidth. It can be changed globally inside \noalign:

\documentclass{article}
\usepackage{colortbl}

\begin{document}
\begin{tabular}{c}
\noalign{\global\arrayrulewidth=2mm}
\arrayrulecolor{red}\hline
a \\
\noalign{\global\arrayrulewidth=1mm}
\arrayrulecolor{green}\hline
\end{tabular}
\end{document}


• Is there anyway to change the color of \hhline? Also, is there any way to change the thickness locally? – H. R. Sep 22 '17 at 14:45
• @H.R. a) The method of the answer should also work for \hhline, see also "9 More fun with \hhline" in the documentation of package colortbl. – Heiko Oberdiek Sep 22 '17 at 16:28
• b) Also \arrayrulecolor uses a global definition internally. At the start of a new table row, TeX expands tokens. An assignment ends the expansion mode and starts the new cell already. As a workaround, the previous thickness can be saved in a register and restored afterwards. – Heiko Oberdiek Sep 22 '17 at 16:33
• What is the default thickness of hline? – Viesturs Apr 21 '19 at 6:56
• @Viesturs It depends on the document class, the standard classes (article, report, book) and other (memoir, ...) define \setlength\arrayrulewidth{.4\p@}. Then, the default thickness is 0.4 pt. – Heiko Oberdiek Apr 21 '19 at 16:13