\task
takes one argument, passing it to \@task
which is defined in such a way that its arguments are delimited; if the call is
\@task xyz:AB:cde:u\@nil
the first argument is xyz
, the second is AB
and the third is cde:u
. Here \@nil
doesn't mean anything, it's just required by the syntax of \@task
and TeX throws it away.
\relax
is a primitive of TeX, its function is "do nothing". The test
\if\relax\detokenize{#2}\relax
is a safe way to determine if the argument #2
is empty. If it is, \detokenize{#2}
expands to nothing, so \if
compares the tokens \relax
and \relax
, which are indeed equal, so the "true" branch is followed, which starts immediately after the second \relax
, up to and excluding \else
. If #2
is not empty, say it's 30
, \if
will compare \relax
with 3
which are different, so the "false" branch is followed, which starts after \else
up to and excluding \fi
.[1]
The similar construct \if\relax#2\relax
does not work in all cases, because "all control sequences are equal as far as \if is concerned" [2]. It would not work if #2
was \relax
(or any other control sequence, possibly followed by other tokens)! So we use \detokenize
that, as explained also by Joseph, splits everything into a string. So, even in the weird case that #2
is \relax
, \if
would compare the token \relax
with the character \
, which are different.
[1] This is not strictly true, but it's an approximation of the truth sufficient for the purpose of this description.
[2] TeX by Topic (section 13.2.1)
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:
\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
Best Answer
Basically
\noalign
(which is a TeX primitive and not a supported LaTeX command) has to come as the first thing in a table row and its argument is evaluated as vertical mode material that is placed between rather than in the table rows. So\vspace
just inserts vertical space. (If the table had vertical rules from|
they would be broken by this additional space.)