I am drawing a simple power system in a single line diagram and want to define a shape for a transformer, which looks like two partly overlapping circles. I have already defined styles for generators and impedances using \tikzset. By doing this I can easily draw generators and impedances using the node command. However, I haven't figured out how to do this for the transformer as it consists of two circles not one. Does anyone know an easy way to define this transformer shape, such that I can easily create one with the the node command?
A for
loop is an answer for you here:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
mycirc/.pic={
\foreach \w in {0,1} {
\draw (0,\w) circle (1cm);
}
}
}
\begin{tikzpicture}
\pic at (2,2) {mycirc};
\end{tikzpicture}
\end{document}
which will give you:
Even you can change the design choices of your transformers:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
main/.style ={circle, inner sep=0pt, minimum size=0.6cm, dashed},
mycirc/.pic={
\foreach \w in {0,1} {
\draw[main] (0,\w) circle (1cm);
}
}
}
\begin{tikzpicture}
\pic at (2,2) {mycirc};
\end{tikzpicture}
\end{document}
which will give you:
-
Hi, many thanks. Your solution looks exactly, like what I was thinking about. One question. Is it possible to change your code such that I can draw the shape using the following command:
\node[mycirc] (pos) {};
. For the generator shape I get this behavior, when I write.style
where you have written.pic
. – Sigurd Hofsmo Jakobsen Feb 4 '19 at 12:08 -
@SigurdHofsmoJakobsen It will not work (I think), because, it is not a style instead it is a picture ;) But if you want to draw it with
mypic
then you need to define a custommacro
for that purpose (which is out-of-scope of this question here :D). [off-topic] IMHO, it is an over-kill :D – Raaja_is_at_topanswers.xyz Feb 4 '19 at 12:16 -
Ok, many thanks. Yes, I don't want to define a custom macro, it does seem a bit overkill ;P. Anyway, your proposal work fine for my purpose :) – Sigurd Hofsmo Jakobsen Feb 4 '19 at 12:27
-
-
1No problems, now you know :) Happy
TeXing
:D or must I sayTikZing
:D – Raaja_is_at_topanswers.xyz Feb 4 '19 at 12:42
\draw (0,0) circle (1cm); \draw (0,1) circle (1cm);
but please explain more about the size of the shape, how you use the shape, etc. – user156344 Feb 4 '19 at 10:13circuitikz
. Then you can do e.g.\draw (0,0) to[ioosource] (0,2);
– StefanH Feb 4 '19 at 11:22