# [texhax] Coloring table cells

Jan Eden lists at janeden.org
Thu Apr 15 17:07:07 CEST 2004

Hi fellows,

I cannot solve the following issue:

In a longtable, I want to color cells spanning over multiple rows, using the colortbl package. My first attempt with columns defined by \newcolumntype delivers the correct output:

\documentclass{article}
\usepackage{longtable, array, color, colortbl}
\begin{document}

\newcolumntype{A}{>{\columncolor{yellow}}l}
\newcolumntype{B}{>{\columncolor[rgb]{.8,.2,.3}}l}
\newcolumntype{C}{>{\columncolor{red}}l}

\begin{longtable}{ABC}
\multicolumn{1}{A}{Vorlesung} & \multicolumn{1}{B}{Vorlesung} & \multicolumn{1}{C}{Vorlesung}\\
Vorlesung & \multicolumn{1}{B}{Vorlesung} & \multicolumn{1}{C}{Vorlesung}\\
Vorlesung & \multicolumn{1}{B}{Vorlesung} & \multicolumn{1}{C}{Vorlesung} \\
\multicolumn{2}{B}{Vorlesung} & \multicolumn{1}{C}{Vorlesung} \\
\end{longtable}
\end{document}

Unfortunately, the LaTeX document  is generated from a HTML table, which uses rowspan=n, so I have to use the multirow package. This package, however, does not seem to be compatible with the other packages involved. At least I have not found a way to use a certain columntype as one of \multirow's arguments.

Informally, the table should look like this, defining cells spanning over a single column but multiple rows in a certain color:

\begin{longtable}{ABC}
\multirow{3}{A}{Veranstaltung} & \multirow{5}{B}{Veranstaltung} & \multirow{2}{C}{Veranstaltung}\\
\multirow{4}{B}{Veranstaltung} & \multirow{1}{C}{Veranstaltung} & \multirow{3}{A}{Veranstaltung}\\
\end{longtable}

Any suggestions?

Thanks,

Jan Eden
--
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.