3

Compiling the code below with LuaLaTeX with TeX Live 2018 gives me the desired result after three runs (to get the references correct).

Changing to TeX Live 2019, i get an error from PGF:

(c:/texlive/2019/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

! Package pgf Error: No shape named two is known.

See the pgf package documentation for explanation. Type H for immediate help. ...

l.18 \node[above=4mm of two] (minussigntext) { ?

Here is the code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,tikzmark}
% positioning used for above= and below=
% tikzmark used for subnode

\begin{document}
\begin{tikzpicture}[remember picture]
  \node{$
    \subnode{sign1}{$\color{red}-$}
    3
    \mathbin{\subnode{minusoperator}{$\color{blue}-$}}
    \subnode{two}{$2$}
    =
    \subnode{sign2}{$\color{red}-$}
    5
  $};
  \node[above=4mm of two] (minussigntext) {
    \color{red}  Minus symbol as sign
  };
  \node[below=4mm of two] (minusoperatortext) {
    \color{blue} Minus symbol for subtraction
  };
  \draw [-] (minussigntext)     to [out=230,in= 90] (sign1);
  \draw [-] (minussigntext)     to [out=310,in= 90] (sign2);
  \draw [-] (minusoperatortext) to [out=110,in=270] (minusoperator);  
\end{tikzpicture}
\end{document}

Desired result:

desired result

1
2

Ulrike Fischer points in the right direction. This seems to be an issue with tikzmark v1.7. I tried compiling with this this commit from may 13 2019 in the github page for tikzmark, and it solved my problem. There was also some other syntax problems with my original code; below is a better version. I shouldn't have used $ inside the subnodes, because that exited mathmode. I expect the issue is going to be resolved in a newer version of tikzmark.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,tikzmark}
% positioning used for above= and below=
% tikzmark used for subnode

\begin{document}

\begin{tikzpicture}[remember picture]
  \node (expression) {$
    \subnode{sign1}{\color{red}-}                     % -
    3                                                 % 3
    \mathbin{\subnode{minusoperator}{\color{blue}-}}  % -
    2                                                 % 2
    \mathrel{=}                                       % =
    \subnode{sign2}{\color{red}-}                     % -
    5                                                 % 5
  $};
  \node[above=4mm of expression] (minussigntext) {
    \color{red} Minus symbol as sign
  };
  \node[below=4mm of expression] (minusoperatortext) {
    \color{blue} Minus symbol for subtraction
  };
  \draw [-] (minussigntext)     to [out=230,in= 90] (sign1);
  \draw [-] (minussigntext)     to [out=310,in= 90] (sign2);
  \draw [-] (minusoperatortext) to [out=110,in=270] (minusoperator);
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.