TikZ/pgf 的更新破坏了用户定义的命令

TikZ/pgf 的更新破坏了用户定义的命令

TikZ/pgf 的最近一次更新似乎破坏了之前定义的一个命令问题关于在等式中划掉项的我的一些看法。

下面是一个可以说明该问题的 MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,tikzmark}

\newif\ifCancelToOverlay
\tikzset{CancelTo/.is family,
 CancelTo,
 angle/.initial=60,
 name/.initial=tmp,
 node/.style={},
 arrow/.style={->},
 topoffs/.initial=2pt, 
 nodeaboveoffs/.initial=1pt,
 nodeleftoffs/.initial=0pt,
 overlay/.is if=CancelToOverlay,
 overlay=true  
}

\newcommand{\CancelTo}[3][]{\bgroup\tikzset{CancelTo/.cd,#1}
\tikzmarknode{\pgfkeysvalueof{/tikz/CancelTo/name}}{#3}
\begin{tikzpicture}[overlay,remember picture]
 \draw[/tikz/CancelTo/arrow] let \p1=($(\pgfkeysvalueof{/tikz/CancelTo/name}.north)-(\pgfkeysvalueof{/tikz/CancelTo/name}.south)$),\n1={0.5*\y1*cot(\pgfkeysvalueof{/tikz/CancelTo/angle})},\n2={\y1/sin(\pgfkeysvalueof{/tikz/CancelTo/angle})} 
 in ([xshift=-\n1]\pgfkeysvalueof{/tikz/CancelTo/name}.south) -- ++ (\pgfkeysvalueof{/tikz/CancelTo/angle}:\n2+\pgfkeysvalueof{/tikz/CancelTo/topoffs}) 
 node[above left=\pgfkeysvalueof{/tikz/CancelTo/nodeaboveoffs} and \pgfkeysvalueof{/tikz/CancelTo/nodeleftoffs},inner sep=0pt,font=\scriptsize,/tikz/CancelTo/node] (tmplabel) {#2};
 \path let \p1=($(tmplabel.north east)-(\pgfkeysvalueof{/tikz/CancelTo/name}.east)$) in
 \pgfextra{\ifCancelToOverlay
 \xdef\mydist{0pt}
 \else 
 \xdef\mydist{\x1}
 \fi};
\end{tikzpicture}\egroup\vphantom{\cancelto{#2}{#3}}\hspace{\mydist}}

\input{math-defs}

\begin{document}
  \begin{equation*}
     \CancelTo[nodeleftoffs=-11pt]{ignore}{\frac{x^2}{4}}
  \end{equation*}
\end{document}

这段代码曾经可以工作,但现在产生了

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

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

l.39 ...nodeleftoffs=-11pt]{ignore}{\frac{x^2}{4}}

我在跑:

  • pdfTeX,版本 3.14159265-2.6-1.40.20(TeX Live 2019)
  • pgf 2019/08/03 v3.1.4b (3.1.4b)
  • tikz 2019/08/03 v3.1.4b (3.1.4b)

相关内容