You already have these nice pics. You could give them a node-like name using the local bounding box
option.
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\tikzset{generator/.pic={
code={
\draw (0,0) circle (2);
\draw (0,0) arc (0:180:0.5);
\draw (0,0) arc (180:360:0.5);
\draw (-2,0) --++ (-2,0);
}
}
}
\tikzset{infinite bus/.pic={
code={
\draw (0,0) circle (2) node[inner sep=0, outer sep = 0] {{$\infty$}};
\draw (2,0) --++ (2,0);
}
}
}
\begin{document}
\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
% Infinite bus
%\node at (0,0) (bus) {\tikz\path (0,0) pic[scale=0.2] {infinite bus};};
\path (0,0) pic[scale=0.2,local bounding box=bus] {infinite bus};
% Generator
\path (5,0) pic[scale=0.2,local bounding box=gen] {generator};
% Line
\draw (bus.east) -- (gen.west);
\end{tikzpicture}
\end{document}
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/bAQUo.png)
Of course, you could also work with \savebox
es. For the infinite bus you do not even need a \savebox
, you can just use a plain node with circle,draw
, and in the second case you could use a \savebox
. This version does not have the hard coded horizontal lines, and the gap of your previous question isn't an issue either since you draw the border.
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\newsavebox\Generator
\sbox\Generator{\tikz{\draw (0,0) arc (0:180:0.5);
\draw (0,0) arc (180:360:0.5);}}
\begin{document}
\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
% Infinite bus
\node[circle,draw,minimum size=1cm] at (0,0) (bus) {$\infty$};
% Generator
\node[circle,draw,minimum size=1cm] at (5,0) (gen) {\scalebox{0.2}{\usebox\Generator}};
% Line
\draw (bus.east) -- (gen.west);
\end{tikzpicture}
\end{document}
Yet another option is to work with path pictures. In this case this might be advantageous as the node then inherits the anchors from the circle shape rather than an rectangle, which it does if you use local bounding box
.
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{generator/.style={circle,draw,minimum size=1cm,path picture={
\draw (-0.25,0) to[out=90,in=90,tension=1.2] (0,0) to[out=-90,in=-90,tension=1.2] (0.25,0);
}},
infinite bus/.style={circle,draw,minimum size=1cm}}
\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
% Infinite bus
\path (0,0) node[infinite bus] (bus) {$\infty$} (5,0) node[generator] (gen){};
\draw (bus) -- (gen);
\end{tikzpicture}
\end{document}
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/QOzn0.png)
circuitikz
?