
共有 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
ノードの定義には好きなものを追加できます。これは次のように機能します。
pic
追加したい内容を含むを定義します。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
。