Graphics, Figures & Tables ⇒ custom color for parts of the horizontal rule in tabular
custom color for parts of the horizontal rule in tabular
I need to create a 4-column table with the horizontal rule for the second row having the following feature:
for column 1 the horizontal rule must be blue in color while for the next 3 columns it must be black. Is there a way to achieve this with LaTeX? A solution with \hhline will be most helpful, but any other are welcome as well.
Thank you all in advance.
Regards, Martin
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
custom color for parts of the horizontal rule in tabular
Code: Select all
\documentclass[11pt,a4paper]{article}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage[dvipsnames,table]{xcolor} % »table« optons loads »colortbl« package\begin{document}\begin{tabular}{*4c}\arrayrulecolor{blue}\cline{1-1}\arrayrulecolor{black}\cline{2-4}Table Head & Table Head & Table Head & Table Head \\\arrayrulecolor{blue}\cline{1-1}\arrayrulecolor{black}\cline{2-4}Some Values & Some Values & Some Values & Some Values \\Some Values & Some Values & Some Values & Some Values \\Some Values & Some Values & Some Values & Some Values \\ \arrayrulecolor{blue}\cline{1-1}\arrayrulecolor{black}\cline{2-4}\end{tabular}\end{document}
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
custom color for parts of the horizontal rule in tabular
Thank you very much for your reply. Actually, I rather need a solution with \hhline than with cline. I read thoroughly the documentation for colortbl, but obviously I am missing something. Here is a minimal working example that I think should work, but it doesn't:
Code: Select all
\documentclass[utf8]{beamer}\mode<presentation>{ \usetheme{Darmstadt}\setbeamercovered{transparent}}\usepackage[utf8]{inputenc}\usepackage[english]{babel}\usepackage[T1]{fontenc}\usepackage{hhline}\usepackage{colortbl}\usepackage{helvet}\usepackage{array}\begin{document}\begin{frame}[plain]{}\newcommand\rainbowline{\hhline{%>{\arrayrulecolor{black}}-%>{\arrayrulecolor{blue}}-%}}\begin{tabular}{*2{>{\columncolor[gray]{1}}c}}\rainbowline1&2 \\\rainbowlinebla & bla \\\rainbowline\end{tabular}\end{frame}\end{document}
Regards,
Martin