I am looking for a way to mark particular positions within the math-text of node.
My MNWE is:
\documentclass[tikz]{standalone}
\usepackage{mathtools,xparse,bm}
\usetikzlibrary{tikzmark}
\NewDocumentCommand{\outermacro}{mO{}}{ p( #1 \mid #2 ) }
\NewDocumentCommand{\innermacro}{mO{}}{ \bm{x}_{#1}^{#2} }
\begin{document}
\begin{tikzpicture}
% \node (n1) at (0,0) { $\outermacro{ X }[ \subnode{x}{ \innermacro{2}[z] } ]$ }; % complains about missing $
\node (n2) at (2,0) { $\outermacro{ X }[ \innermacro{2}[z] ]$ }; % test for both macros, doesn't do what I want
\node (n4) at (0.5,1) {this is a note};
\draw (n4) -- (x.center);
\end{tikzpicture}
\end{document}
For the "real" case,I get the errors as given in the comment.
What is the right way of doing this?
P.S.: the subnode
part, I stole from https://tex.stackexchange.com/a/287727/34538
EDIT:
I tried
\begin{tikzpicture}
\node (n1) at (0,0) { $\outermacro{ X }[ \pgfmark{x}\innermacro{2}[z] ]$ }; % complains about missing $
\node (n2) at (3,0) { $\outermacro{ X }[ \innermacro{2}[z] ]$ }; % test for both macros
\node (n4) at (0.5,1) {this is a note};
\draw (n4) -- (pic cs:x);
\end{tikzpicture}
which compiles, but does not yield a line to correct position.
\subnode
? See the documentation of tikzmark pag.7.