Graphics, Figures & TablesRowcolor overlaps with vertical table lines

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
MatthiasN
Posts: 41
Joined: Sun Mar 11, 2012 1:21 pm

Rowcolor overlaps with vertical table lines

Post by MatthiasN »

Hi everyone,

Currently, I am having trouble using the package colortbl for coloring my table rows. When using the command \rowcolor{colorname}, the result is that the vertical lines that frame my table are partially overlapped by the rowcolor. I browsed the web for solutions and found that many users are experiencing the same problem, but so far I have found no satisfactory solutions. What they suggest is using some optional arguments of the \rowcolor command to adjust the margin at the sides. However, this is then automatically applied to each cell, and in order to get no overlap with the vertical lines, white lines between the cells become visible. What I have right now is the following:

Code: Select all

\documentclass{report}
\usepackage{amsmath}
\usepackage[svgnames]{xcolor}
\usepackage{tabularx}
\usepackage{colortbl}
\begin{document}
	\begin{table}
		\centering
		\begin{tabular}{|rrrrrr|}
			\hline\hline
			\rowcolor{Beige}
			Setting & $J_{\text{ini}}$ $\left[\frac{\text{L}}{\text{m}^2\text{h}}\right]$ & $t_{\text{ini}}$ $\left[\text{s}\right]$ & $J_{\text{bulk}}$ $\left[\frac{\text{L}}{\text{m}^2\text{h}}\right]$ & $t_{\text{bulk}}$ $\left[\text{s}\right]$ & $t_{\text{rel}}$ $\left[\text{s}\right]$ \\
			\hline
			1     & 30.0  & 0     & 16.7  & 576   & 24 \\
			\rowcolor{Lavender}
			2     & 30.0  & 0     & 17.8  & 540   & 60 \\
			3     & 30.0  & 0     & 20.0  & 480   & 120 \\
			\rowcolor{Lavender}
			4     & 30.0  & 0     & 22.5  & 426   & 174 \\
			5     & 30.0  & 0     & 25.0  & 384   & 216 \\
			\rowcolor{Lavender}
			6     & 30.0  & 0     & 30.0  & 320   & 280 \\
			\hline\hline
		\end{tabular}
	\end{table}
\end{document}
The solution of which I was thinking is adding some space between the vertical line and the adjacent column, instead of trying to solve the problem by manipulating what is done by \rowcolor. I tried to achieve this by adding \hspace{length} to the argument specifying the number of columns and their alignment. That would thus become \begin{tabular}{|\hspace{2mm}rrrrrr|}. However, this results in an error.

Thanks for reading.
Matthias

Recommended reading 2024:

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

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

Post Reply