Graphics, Figures & Tablescustom color for parts of the horizontal rule in tabular

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
marto1980
Posts: 10
Joined: Sun Apr 11, 2010 8:51 am

custom color for parts of the horizontal rule in tabular

Post by marto1980 »

Hello!

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

custom color for parts of the horizontal rule in tabular

Post by localghost »

The colortbl manual (Section 9 — More fun with \hhline, p. 6) introduces a concrete example. Furthermore it mentions something like below.

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}
Adapting the code to your needs should be no big deal.


Thorsten
marto1980
Posts: 10
Joined: Sun Apr 11, 2010 8:51 am

custom color for parts of the horizontal rule in tabular

Post by marto1980 »

localghost,
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}

Here I want to create a 2x2 table with the horizontal rule for the first column black and for the second - blue. There are simply no rules printed, however. Any ideas?

Regards,
Martin
Post Reply