[Tex/LaTex] How to set tikzmarks with \noalign at the edge of tabular rows

tablestex-coretikz-pgftikzmark

I'm trying to improve the lines in a tabular with colored rows (lines above a colored row can disappear in the adobe reader at some zoom levels) by redrawing the line above a row after the row itself has be created. I have p-columns so I can't use David's solution here https://tex.stackexchange.com/a/129835/2388.

So I thought to use tikzmark (or some other mark) but can't figure[1] out how to find the right edge. Whatever I do the right mark is at the right side of the page:

\documentclass[]{article}

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}
\renewcommand\arrayrulewidth{4pt}

\begin{tabular}{l}
abc    \\\noalign{\hrule height \arrayrulewidth}
blub   \\\noalign{\pgfmark{testa}\hfill\pgfmark{testb}}
abc\tikz [remember picture] \draw [overlay,->] (pic cs:testa)--(pic cs:testb);
\end{tabular}

\end{document}

Is there anyway to put the marks in the \noalign so that they respect the size of the tabular box like \hrule does it?

[1] I naturally can find the edge by putting a mark at the right end of some cell and then calculate the intersection but this is cheating ;-).

Best Answer

As egreg said, but as you hinted you were using colortbl it is already putting a coloured rule under the cell, so you can just ask it to stick a tikzmark at each end of that, so you know where it is:

enter image description here

\documentclass[]{article}
\usepackage{colortbl}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\makeatletter
\newcount\U@CT@
\def\CT@@do@color{%
\U@tm
  \global\let\CT@do@color\relax
        \@tempdima\wd\z@
        \advance\@tempdima\@tempdimb
        \advance\@tempdima\@tempdimc
        \kern-\@tempdimb
        \leaders\vrule
%^^A                     \@height\p@\@depth\p@
                \hskip\@tempdima\@plus  1fill
\U@tm
        \kern-\@tempdimc
        \hskip-\wd\z@ \@plus -1fill }


\def\U@tm{%
\global\advance\U@CT@\@ne
\tikzmark{test\the\U@CT@}}
%
\makeatother
\begin{document}
\renewcommand\arrayrulewidth{4pt}

\begin{tabular}{l}
\rowcolor{yellow}abc    \\
blub   \\
abc\tikz [remember picture] \draw [overlay,->] (pic cs:test1)--(pic cs:test2);
\end{tabular}

\end{document}

If you want the left edge of the arrow to be the left edge of the colour rather than the cell contents, move the first \U@tm down a few lines after the \kern-\@tempdimb

Related Question