There seems to be a problem with tikzmark and xelatex. Ulrike Fischer from the xetex list helped to track this down. The following code does not work when compiled with xelatex but produces the expected result when compiled with pdflatex:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
x\pgfmark{tA}some text \pgfmark{tB} some text
\begin{tikzpicture}[remember picture]
\draw (0,0)node (A){A} rectangle (1,1)node (B){B};
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
\draw (0,0)node {\pgfmark{nA}} rectangle (1,1)node {\pgfmark{nB}};
\end{tikzpicture}
\vspace{3cm}\centering
\begin{tikzpicture}[overlay,remember picture]
\draw[red,->] (0,0)--(pic cs:tA) (0,0)--(pic cs:tB);
\draw[blue,->](0,0)--(pic cs:nA) (0,0)--(pic cs:nB); %nB faulty
\draw[green,->](0,0)--(A) (0,0)--(B);
\end{tikzpicture}
\end{document}
Is there a quick fix to this? The problem appeared after upgrading from texlive 2013 to texlive 2014.
Edit: The original code used \subnodebut it doesn't work either:
\documentclass{article}
\usepackage{forest}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{forest}
[V
[\subnode{ap1}{AP}
[ungewaschen]]
[V{[ \subnode{arg11}{1}, \subnode{arg12}{2} ]}
[isst]]]
\end{forest}
\begin{forest}
[V
[\subnode{ap2}{AP}
[ungewaschen]]
[V{[\subnode{arg21}{1} ]}]]
\end{forest}
\begin{tikzpicture}[overlay,remember picture]
%% this works with tikzmark
%% \draw[->, bend angle=40, bend left] ($(pic cs:ap1)+(1ex,2ex)$) to($(pic cs:arg11)+(1ex,2.5ex)$);
%% \draw[->, bend angle=40, bend left] ($(pic cs:ap1)+(1ex,2ex)$) to($(pic cs:arg12)+(1ex,2.5ex)$); % 1ex links, 2ex hoch
%% %
%% this used to work with subnode in texlive 2013 but is broken now
%% \draw[->, bend angle=40, bend left] ($(pic cs:ap2)+(1ex,2ex)$) to($(pic cs:arg21)+(1ex,2.5ex)$);
\draw[->, bend angle=40, bend left] (ap1.north) to (arg11.north);
\draw[->, bend angle=40, bend left] (ap1.north) to (arg12.north);
%
\draw[->, bend angle=40, bend left] (ap2.north) to (arg21.north);
\end{tikzpicture}
\end{document}
The AP should be connected to 1 and 2 respectively, but the arrows are up in the air.

\documentclass{article}\newcount\pdftexversion\pdftexversion140\def\pgfsysdriver{pgfsys-dvipdfm.def}\usepackage{tikz}\usetikzlibrary{tikzmark}\begin{document}...\end{document}gives correct result. However, experts should investigatepgfsys-xetex.defandpgfsys-dvipdfmx.defwhich are used in usual usage of xelatex. – Akira Kakuto Feb 23 '15 at 06:01tikzmarkpackage maintainer?xelatexpeople?pgfmaintainers? – Stefan Müller Feb 23 '15 at 16:39\pgfsys@hboxsynced. It is not possible to save a position inside a node. E.g.node {\pdfsavepos\write\@auxout{\@percentchar\the\pdflastxpos}}always store the zero coordinate. So probably the pgf maintainer should be informed. – Ulrike Fischer Feb 23 '15 at 18:47\pgfsys@hboxsyncedinpgfsys-common-pdf-via-dvi.definstead of that inpgfsys-dvipdfmx.def, the example becomes correct:\documentclass{article}\usepackage{tikz}\usetikzlibrary{tikzmark}\makeatletter\def\pgfsys@hboxsynced#1{%...\makeatother\begin{document}...\end{document}. However, the code must have been rewritten inpgfsys-dvipdfmx.defbecause of some reason, so pgf maintainer should be informed. – Akira Kakuto Feb 24 '15 at 03:47\pgfmarkinside the node as you could give a name to the node and use that instead.\tikzmarkand\pgfmarkshouldn't be used inside an existingtikzpicture. I wrote the\subnodecommand to avoid this problem since lots of people seemed to insist on using\tikzmarkinside atikzpicture! – Andrew Stacey Mar 29 '15 at 20:41node {\pgfmark{nA}tocoordinate (nA)and adjust the line drawing code accordingly then it works. So it solves the problem in that it gives code that works as expected. As I said above,\tikzmarkand\pgfmarkshould not be used inside atikzpicturebecause that is effectively putting a tikzpicture inside a tikzpicture and this Should Not Be Done. So while there may well be an underlying bug that should be squished, as far as the MWE in this question it doesn't need squishing to get code that will do what is wanted. – Andrew Stacey Jul 15 '15 at 20:48\subnodedoes not work around the bug which causestikzmarkto not work with XeTeX without the workaround mentioned in the comments above. That's nottikzmark's fault, of course. (At least, it certainly doesn't seem to be.) See this comment for a case where the solution uses\subnodebut the workaround is still required for XeTeX. – cfr Jul 15 '15 at 20:58\subnodeseems to be broken in texlive 2015. – Stefan Müller Sep 04 '15 at 16:13tikzpictures) by using\subnode, but I'm not sure how to eliminate the use oftikzmarkcompletely. I've also tried to reflect the discussion here and in the more recent question about this. – cfr Nov 20 '16 at 00:12