由於某些原因(為了使節點影響 tikzcd 中指向它的箭頭的樣式),我需要執行一段程式碼\tikzlastnode
來取得 tikz(cd) 矩陣中目前位置的名稱,但這是僅在建立節點後定義。不幸的是,append after command
需要一個路徑(空路徑顯然不是有效的輸入),所以我需要創建一個假的空節點來執行路徑,這聽起來很髒,我擔心它可能會導致問題(添加空間,幹擾接下來的路徑......)。我們可以append after command
在不干擾路徑的情況下運行(或等效)嗎?
微量元素:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-cd}
\begin{document}
\makeatletter
\begin{tikzcd}
A \rar[/utils/exec={\message{BBBBB The message above (AAAA) should be equal to \tikzcd@ar@target}}, draw=\myfillcolor] & |[append after command={
%%% Creating an empty node + /utils/exec sounds really dirty:
node[/utils/exec={%
\message{AAAA I need to have access to the name of the current node \tikzlastnode}%
\gdef\myfillcolor{red}
}%
] {}
}
]| B
\end{tikzcd}
\end{document}
編輯
有人提議\pgfextra ... \endpgfextra
並且有效!謝謝!
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-cd}
\begin{document}
\makeatletter
\begin{tikzcd}
A \rar[/utils/exec={\message{BBBBB The message above (AAAA) should be equal to \tikzcd@ar@target}}, draw=\myfillcolor] & |[append after command={%
\pgfextra% this syntax with \endpgfextra completely turns off the tikz syntax, that might be safer than \pgfextra{...}.
\message{AAAA I need to have access to the name of the current node \tikzlastnode}%
\gdef\myfillcolor{red}%
\endpgfextra%
}]| B
\end{tikzcd}
\end{document}