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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- 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}}
\rainbowline
1&2 \\
\rainbowline
bla & bla \\
\rainbowline
\end{tabular}
\end{frame}
\end{document}
Regards,
Martin