I want to create a tabular with an empty top left cell and a background color on the column and row headers (except the empty top left).
I try to combine this two answers:
color only a cell of a table
Remove border of top left table cell
But the background color seams to be drawn on top of the upper rule when using \cline
. This does not happen with \hline
.
How do I draw \cline
on top of the background color?
$ lualatex --version
This is LuaTeX, Version beta-0.80.0 (TeX Live 2015/Debian) (rev 5238)
MCVE:
\documentclass[24pt a6paper, landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage[paperheight=3.7in,paperwidth=6.2in, margin=0.5cm]{geometry}
\begin{document}
\newcommand{\sometext}{this is just to demonstrate line breaking}
\definecolor{headercolor}{RGB}{209,220,204}
\newcommand{\cellDefinition}[1]{\parbox{3cm}{\vspace{3mm}#1\vspace{3mm}}}
This table has a line at the top of the gray cell (1-3) because of \verb|\hrule| :
\begin{tabular}{c|c|c|c|}\hline
\multicolumn{1}{c|}{} & \cellDefinition{\sometext} & \cellcolor{headercolor} \cellDefinition{\sometext} & \cellDefinition{\sometext} \\ \hline
\cellDefinition{\sometext} & \cellDefinition{\sometext} & \cellDefinition{\sometext} & \cellDefinition{\sometext} \\ \hline
\end{tabular}
\vspace{1em}
How do I draw the same (evenly thick) line on top of the gray cell with \verb|\crule| ?
\begin{tabular}{c|c|c|c|}\cline{2-4}\cline{2-4}
\multicolumn{1}{c|}{} & \cellDefinition{\sometext} & \cellcolor{headercolor} \cellDefinition{how do I bring the line at top before the background? } & \cellDefinition{\sometext} \\\hline
\cellDefinition{\sometext} & \cellcolor{headercolor} \cellDefinition{I want such top line at the other cell too.} & \cellDefinition{\sometext} & \cellDefinition{\sometext} \\ \hline
\end{tabular}
\end{document}
result
Best Answer
You have to
\usepackage{hhline}
and have to replace\cline{2-4}
by\hhline{~|-|-|-|}
. The argument of\hhline
is a specification of what to draw:~
corresponds to an empty column,-
to a line spanning one column, and|
signals a junction with a vertical line.