tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

span rules shows white area when used with background color

Open parivalavanm opened this issue 7 months ago • 2 comments

Please refer to the original tex.stackexchange question I had asked. This looks similar to the another question about rules not being rendered properly on acrobat #468

Adding the same here

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabularray}

\definecolor{jobcolor}{RGB} {0,   146, 207}

\begin{document}

\begin{tblr}{
    colspec={|c| c| c| c| c| c |c|},
    rowspec={Q[jobcolor] Q[jobcolor]},
}

\hline
% first header row
\SetCell[r=2]{c} 2 Rows
& \SetCell[c=2]{c} 2 Columns
&
& \SetCell[c=2]{c}\cellcolor{blue!25} next 2 Columns
& & \SetCell[r=2,c=2]{c} 2 Rows\linebreak 2 Columns \\
\SetHline[1]{2-3}{fg=red,wd=0.5pt, leftpos=-0.5, rightpos=-0.5, endpos}
\SetHline[1]{4-5}{fg=red,wd=0.5pt, leftpos=-0.5, rightpos=-0.5, endpos}

% second header row
& 2-2 & 2-3 & 2-4 & 2-5 & &  \\
\hline

% first data row
3-1 & 3-2 & 3-3 & 3-4 & 3-5 & 3-6 & 3-7 \\
\hline
\end{tblr}
\end{document}

The output looks like given below:

The span rule is created using \SetHline[1]{2-3}{fg=red,wd=0.5pt, leftpos=-0.5, rightpos=-0.5, endpos}. If you look closely, there is a white rule that appears where the trimming is happening with leftpos and rightpos. I am not sure from where the white color/rule is coming from.

Is this a challenge with the package or am i doing something wrong?

To make it clear, if i remove the colspec from the tblr block and remove the leftpos=-0.5, rightpos=-0.5, from the SetHline, then the output will look like the following:

The rule below the spanned cells extend through the entire cell. i need them to not include the area of the column separator. This makes it look as if the columns 2,3 and 4,5 are merged together

parivalavanm avatar May 10 '25 11:05 parivalavanm

At present you cannot set bg colors for border lines. As a workaround you can add bg colors with tikz library (added in v2005A):

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\definecolor{jobcolor}{RGB}{0,146,207}
\begin{document}

\begin{tblrtikzbelow}
  \draw[jobcolor,line width=1pt] (h2-|v2) -- (h2-|v6);
\end{tblrtikzbelow}%
\begin{tblr}{
    colspec={|c| c| c| c| c| c |c|},
    rowspec={Q[jobcolor] Q[jobcolor]},
}
\hline
% first header row
\SetCell[r=2]{c} 2 Rows
& \SetCell[c=2]{c} 2 Columns
&
& \SetCell[c=2]{c} next 2 Columns
& & \SetCell[r=2,c=2]{c} 2 Rows\linebreak 2 Columns \\
\SetHline[1]{2-3}{fg=red,wd=0.5pt, leftpos=-0.5, rightpos=-0.5, endpos}
\SetHline[1]{4-5}{fg=red,wd=0.5pt, leftpos=-0.5, rightpos=-0.5, endpos}
% second header row
& 2-2 & 2-3 & 2-4 & 2-5 & &  \\
\hline
% first data row
3-1 & 3-2 & 3-3 & 3-4 & 3-5 & 3-6 & 3-7 \\
\hline
\end{tblr}

\end{document}
Image

lvjr avatar May 11 '25 08:05 lvjr