TeX - LaTeX Asked by LudiWin on November 19, 2020
I was wondering whether it’s possible to combine nodes and arrows (which are defined only in relation to the positioning of the "parent node") in a shared tikzset?
A minimum working example is the following:
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}
Instead of defining an extra draw command to draw the little circle, I’d like to somehow move the draw command into the tikzset{LSTMCell/.style={...}}
definition.
Is something like that possible?
Many thanks in advance!
You can add anything you like to the definition of the node. This works as follows:
pic
that contains the stuff you want to add;pic
to the definition of the node via append after command
.Explicit example:
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}
Obviously the arrow would look better if you used bending
.
Correct answer by abcdefg on November 19, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP