Tikz: 경로를 건드리지 않고 노드를 생성한 후 코드를 실행합니다.

Tikz: 경로를 건드리지 않고 노드를 생성한 후 코드를 실행합니다.

몇 가지 이유로(노드가 tikzcd에서 노드를 가리키는 화살표의 스타일에 영향을 미치게 하려면) \tikzlastnodetikz(cd) 행렬에서 현재 위치의 이름을 가져오기 위해 읽는 코드를 실행해야 하지만 이는 다음과 같습니다. 노드 생성 후에만 정의됩니다. 불행하게도 append after command경로가 필요하므로(빈 경로는 유효한 입력이 아닙니다) 경로를 실행하기 위해 가짜 빈 노드를 만들어야 하는데, 소리가 너무 지저분하고 문제가 발생할 수 있을지 걱정됩니다( 공간을 추가하고 다음 경로를 방해합니다…). append after command경로를 전혀 방해하지 않고 달릴 수 있습니까 ?

MWE:

여기에 이미지 설명을 입력하세요

\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}

관련 정보