Graphics, Figures & TablesLine on top cells

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Line on top cells

Post by bstex »

Hi,
I have made this table:
Screen Shot 2017-11-04 at 18.10.10.png
Screen Shot 2017-11-04 at 18.10.10.png (54.28 KiB) Viewed 3820 times
with this code:

Code: Select all

\documentclass[11pt,a4paper]{book}

\usepackage[table]{xcolor}

\begin{document}

\begin{table}
\centering\arrayrulecolor{black}
\begin{tabular}{l|ccccc|}
\cline{2-6}
\rowcolor{red}\multicolumn{1}{c|}{\cellcolor{white}A} & B & C & D & E & F \\ \hline
\multicolumn{1}{|l|}{G}  & H & I & J  &   K   & L  \\ \hline
\multicolumn{1}{|l|}{M}  &  N & O  & P & Q & R  \\ \hline
\multicolumn{1}{|l|}{S}  &  T  & U &  V & W & X    \\ \hline
\end{tabular}
\end{table}

\end{document}
but the cline on the top of the table is not visible?
How can I make it visible?
Thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Stefan Kottwitz
Site Admin
Posts: 10314
Joined: Mon Mar 10, 2008 9:44 pm

Line on top cells

Post by Stefan Kottwitz »

This shifts the line a bit up to make it visible:

\cline{2-6}\noalign{\vskip.3pt}

Stefan
LaTeX.org admin
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Line on top cells

Post by bstex »

I still can't believe that I had to MOVE the line just to make it be seen.
Come on, LaTeX does billion of things, it cannot make a line to be seen over a colorful cell? :shock:
Thank you very much for the solution, Stefan. ;)
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Line on top cells

Post by Johannes_B »

The line is drawn first, the colour added on top of it.

Something many users trip over.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Line on top cells

Post by bstex »

I'm fine with the solution you provided, Stefan and thank you again.
I just want to add this:
I was trying to manage making the cline be seen with transparent colors, but I couldn't make it. I thought that if the background of the red cells was transparent, maybe the cline would be visible.
Is it possible?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10314
Joined: Mon Mar 10, 2008 9:44 pm

Line on top cells

Post by Stefan Kottwitz »

I think the normal color support does not work with transparency. But TikZ does. So one could create a table using TikZ, with transparent colors, see here for example:
TikZ can be used with layers. So it is possible, to have all table lines on the foreground layer, and the color filling on the background layer.

Stefan
LaTeX.org admin
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Line on top cells

Post by bstex »

Cool. I'll play with it and post if I find a solution.
Thank you.
Post Reply