I've been looking for a particular symbol for AC sources (the kind of circle with wavy line) and seemed to have found it here: AC source symbol in TikZ circuits.ee.IEC library. Unfortunately there is a little extra I really miss here... Once I rotate the figure 90°, the wavy line (sine inside) obviously rotates, too, something I don't want to happen. I tried a workaround by rotating the symbol back 90°, but then adding an arrow with 'direction info' will be misplaced. Another way was to draw an empty circle and make the wavy line an annotation (See section SHAPES
and ANNOTATIONS
in the code).
Then, the arrow placed with 'direction information' is always rendered correctly, but the annotation is placed in a weird way. This can also be circumvented with extra coding, albeit not very elegantly:
\draw (0,0) to [source={DC voltage={rotate=90,%
shift={(-1.05\tikzcircuitssizeunit,1.05\tikzcircuitssizeunit)}},%
direction info={<-}, info={above:$V_{in}$}}] (0,-2);
Does anybody happen to know a better way? Is there a possibility to prevent the
transform shape
command used when defining the shape, to be executed on the annotation? Because that would really solve it once and for all.
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
%SHAPES
\tikzset{circuit declare symbol=source,
set source graphic={
draw,
circuit symbol lines,
circuit symbol size=width 2 height 2,
shape=generic circle IEC,
transform shape
}
}
%ANNOTATIONS
\tikzset{circuit declare annotation=
{AC voltage}
{0\tikzcircuitssizeunit}
{(-0.6\tikzcircuitssizeunit,-1.05\tikzcircuitssizeunit) %
edge[to path={sin ++(0.3\tikzcircuitssizeunit,0.25\tikzcircuitssizeunit) %
cos ++(0.3\tikzcircuitssizeunit,-0.25\tikzcircuitssizeunit) %
sin ++(0.3\tikzcircuitssizeunit,-0.25\tikzcircuitssizeunit) %
cos ++(0.3\tikzcircuitssizeunit,0.25\tikzcircuitssizeunit)}, -] ()}
}
\begin{tikzpicture}[circuit ee IEC, thick]
\draw (0,2.25) to [source={AC voltage={rotate=90,%
shift={(-1.05\tikzcircuitssizeunit,1.05\tikzcircuitssizeunit)}},%
direction info={<-}, info={above:$V_{AC}$}}] (0,0);
\end{tikzpicture}
\end{document}
What bothers me here is that I need to specify:
shift={(-1.05\tikzcircuitssizeunit,1.05\tikzcircuitssizeunit)}}
when drawing the source rotated by 90°. If I don't do it, the wavy line is misplaced. (Try it yourself!) This is what I'd like to solve in a more elegant way.
EDIT: As requested, there is a full working example (It was too long to include as a comment).
Working example
means if someone copies your code and compiles it, they see the problem reproduced in their systems such that they can make sure that their provided solution will answer your question. Moreover, they can see other possible causes of the problem mentioned that you might overlook. Hence, there must be a minimal working code addressing the problem (or reproducing the error).shift only
to thecircuit declare symbol
, the wavy line should be correct without theshift
.