I'm confused about tikz pics. I can freely define them without issue, and even add coordinates inside that will be available by name inheritance like (-A)
as for example in \pic (S) at (0,0) {myPic}; \draw (S-A) -- ++(0,0);
. This is all documented around p. 255 of the pgf manual.
However I don' understand why it is not possible to give a name to a pic like the one above if no coordinate is defined inside it. By default it would be great if it could behave like a normal node.
MWE:
\documentclass{minimal}
\usepackage{tikz}
\tikzset{
myBlock/.pic = {
\node[draw,minimum width=1cm,minimum height=0.5cm] at (0,0) {};
},
myBlockNamed/.pic = {
\node[draw,minimum height=1cm,minimum width=0.5cm] (-m) at (0,0) {};
},
}
\begin{document}
\begin{tikzpicture}
\pic () at (0,0) {myBock}; % can't give it a name
\pic (S) at (3,0) {myBlockNamed}; % can give it a name
\draw (S-A) -- ++(2,0);
\end{tikzpicture}
\end{document}
The underlying point is I'm working on a control blocs library (so that we can stop the chat below with @Alenanno). For example here is the definition of a math operator
\tikzset{
mySum background/.style = {
circle, minimum size=1.5em, fill=white,
},
mySum edge/.style = {
draw=black, circle, minimum size=1.5em, line width=.5pt,
},
pics/bOp/.style = {
code = {
\node [mySum background] {};
\foreach \t [count=\i] in {#1}{
\pgfmathsetmacro{\angle}{\i*90}
\node[anchor=center, font=\tiny] at (\angle:0.45em) {$\t$};
}
\node [mySum edge] {};
},
},
}
pic
is the mechanism to include a predefined drawing. It is not a referable object. Unless there is something defined in it, that is. Think of it as a container. And your example needs some corrections to be compiled e.g.,\pic at (0,0) {myBlock};\pic (S) at (3,0) {myBlockNamed};\draw (S-m) -- ++(2,0);
works. The first one you need to remove theat (0,0)
from the definition – percusse May 2 '15 at 9:01