tikzset에서 노드와 화살표 결합

tikzset에서 노드와 화살표 결합

공유 tikzset에서 노드와 화살표("부모 노드"의 위치 지정과 관련해서만 정의됨)를 결합하는 것이 가능한지 궁금합니다.

최소 작업 예는 다음과 같습니다.

\begin{tikzpicture}[node distance=2cm]
            % \tikzset{arrow/.style={-latex, shorten >= 5pt, shorten <= 5pt}}
            % \tikzset{diff/.style={-latex, shorten >= 5pt, shorten <= 5pt}}
            % \tikzset{node/.style={draw, circle, fill, red, scale=0.25}}
            \tikzset{LSTMCell/.style={draw, rectangle, red, scale=1.}}

            \clip (-3,3) rectangle (10,-3);
            
            \node (lstm0) [LSTMCell] at (0,0) {LSTM}; 
            \draw [-latex, red, draw] ([xshift=-0.0cm]lstm0.185) arc[radius=0.4cm, start angle=90, end angle=360] node[midway, red, fill=white](){\scriptsize $c(t)$};
        \end{tikzpicture}

작은 원을 그리기 위해 추가 그리기 명령을 정의하는 대신 그리기 명령을 정의로 옮기고 싶습니다 \tikzset{LSTMCell/.style={...}}.

그런 일이 가능합니까?

미리 감사드립니다!

답변1

노드 정의에 원하는 것을 추가할 수 있습니다. 이는 다음과 같이 작동합니다:

  1. pic추가하려는 내용을 포함하는 a를 정의하십시오 .
  2. pic를 통해 노드의 정의에 추가합니다 append after command.

명시적인 예:

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\tikzset{pics/little arrow/.style={code={
    \draw[red,-latex] (0,0) arc[radius=0.4cm, start angle=90, end angle=360]
    node[midway, red, fill=white,font=\scriptsize ]{#1};
    }},
    LSTMCell/.style={draw, rectangle, red, scale=1.,
    append after command={([xshift=-0.0cm]\tikzlastnode.185)
    pic{little arrow={#1}}
    }}}
    \node (lstm0) [LSTMCell={$c(t)$}] at (0,0) {LSTM}; 
\end{tikzpicture}
\end{document}

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

분명히 화살표를 사용하면 화살표가 더 좋아 보일 것입니다 bending.

관련 정보