# Create a symbol-like shape in tikz and reuse it easily?

I wanted to create something like a circle and place arrows around it facing towards the circle (or maybe rectangle):

I did it in this way, if someone has improvements since my approach is very manually, you are welcome:

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\def\size{2}
\begin{tikzpicture}
\node[circle, draw, text width=\size cm, text height=\size cm](down){};
\foreach \x/\y in {
north/90,
north east/45,
east/0,
south east/315,
south/270,
south west/225,
west/180,
north west/135}
{\draw[latex-] (down.\x) to ++ (\y:1cm);
}
\end{tikzpicture}
\end{document}


I now want to use this picture inside a bigger tikz_diagramm like a easy, maybe scalable, symbol. Is there a more efficient way than create a new tikz-environment inside node (where the symbol is needed) and copy&paste the code above?

Do you maybe know good repsoitories for already predefines symbols in tikz (something like tikssymbols)?

You can use pics for such things. They can have parameters, here it is the size. Notice also that north and 90 are equivalent, so you only need one variable in the loop.

\documentclass[tikz,border=3.14mm]{standalone}
\tikzset{pics/.cd,
funky circle/.style={
code={
\node[circle, draw,minimum size=#1](down){};
\foreach \X in {90,45,...,-225}
{\draw[latex-] (down.\X) to ++ (\X:1cm);}
}}}
\begin{document}
\begin{tikzpicture}
\path (0,0) pic{funky circle=2cm};
\path (4,2) pic{funky circle=1cm};
\path (pi,-1) pic[blue]{funky circle=1cm};
\end{tikzpicture}
\end{document}


Just for fun: you can use these things for funky tasks.

\documentclass[tikz,border=3.14mm]{standalone}
\tikzset{pics/.cd,
funky circle/.style={
code={
\node[circle, draw,minimum size=#1](-down){};
\foreach \X in {0,45,...,315}
{\draw[latex-] (-down.\X) to ++ (\X:1cm) coordinate(-\X);}
}}}
\begin{document}
\begin{tikzpicture}
\pic (Emma) at (0,0) {funky circle=2cm};
\pic (Elisa) at (4,2) {funky circle=1cm};
\path (pi,-1) pic[blue,rotate=30,transform shape]{funky circle=1cm};
\draw[red,latex-latex] (Elisa-135) to[out=135,in=90] (Emma-90);
\end{tikzpicture}
\end{document}


As you see, some care has to be taken when rotating these pics: since you have a node inside, you have to add transform shape. This is particularly subtle here because a rotated circle does have the same shape as the unrotated one. Transform shape does, however, transform the anchors 90 and so on that are used in the construction of the pic.

• Awesome! Thank you. Is there some kind of way like for the figure-environment to say 'place the picture HERE where the code is'? Background: I am inside a textnode and write someting, then the mentiones symbol should appear after the word and then the text continues. My current code looks like this: \node[rectangle] (kp){this is text before picture \tikz \path (0,0) pic{funky circle=.3cm}; this is text after picture}; Currently the (0,0) coordinate positions the symbol not in the best places and I manually try to figure out what value perfects best. Maybe there is a automatic function? – SRel Sep 13 '18 at 15:34
• @SRel I guess you do not need any of this. You could just do bla bla bla \tikz[baseline=(Emma-down.south)]{\pic (Emma){funky circle=6mm};} bla bla bla. If you choose another base, e.g. (Emma-down.center), you move the funky circle down. – marmot Sep 13 '18 at 15:39