I want to use tikzmark in tikzcd. However, even the following sample returns errors
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{tikzcd}
\tikzmark{u1}A & B\\
C & \tikzmark{u2}D
\end{tikzcd}
\begin{tikzpicture}[remember picture,overlay]
\draw[->] (u1) edge (u2);
\end{tikzpicture}
\end{document}
The error report is
Package tikz Error: Cannot parse this coordinate. \tikzmark{u1}A
Package tikz Error: Cannot parse this coordinate. C & \tikzmark{u2}D
Package pgf Error: No shape named u1 is known. \draw[->] (u1)
Package pgf Error: No shape named u1 is known. \draw[->] (u1) edge (u2)
Package pgf Error: No shape named u2 is known. \draw[->] (u1) edge (u2)
Package pgf Error: No shape named u2 is known. \draw[->] (u1) edge (u2)
Package pgf Error: No shape named u1 is known. \draw[->] (u1) edge (u2)
Label(s) may have changed. Rerun to get cross-references right.
How to fix this kind of errors?
Update: I have tried this
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{tikzcd}[remember picture]
aaaaaa\subnode{u1}{A} & B\\
C & \subnode{u2}{D}ddddddd
\end{tikzcd}
\begin{tikzpicture}[remember picture,overlay]
\draw[->] (u1) edge (u2);
\end{tikzpicture}
\end{document}
and this
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{tikzcd}[remember picture]
aaaaaa\tikzmarknode{u1}{A} & B\\
C & \tikzmarknode{u2}{D}ddddddd
\end{tikzcd}
\begin{tikzpicture}[remember picture,overlay]
\draw[->] (u1) edge (u2);
\end{tikzpicture}
\end{document}
But none of them put the arrow in correct location.
Update: The \tikzmarknode command does work correctly if I use LuaLaTex instead of XeLaTeX.
remember picture
to thetikzcd
and refer to the nodes with(\tikzcdmatrixname-1-1)
and so on.