Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
    
Is it possible that you include a minimal working example such that we can understand what exactly your problem looks like? –  percusse Sep 10 '11 at 13:44
    
Working example? Sure! –  Count Zero Sep 10 '11 at 15:27
    
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). –  percusse Sep 10 '11 at 15:30
    
I know what a working example is. ;) Had problems inserting it as comment because of its length. Check the edit of the original message, there it is. :) –  Count Zero Sep 10 '11 at 15:40
    
If you add the option shift only to the circuit declare symbol, the wavy line should be correct without the shift. –  Peter Grill Sep 10 '11 at 16:00
show 1 more comment

1 Answer

up vote 6 down vote accepted

I would not define the wavy line as an annotation, but rather as a background path to the generic circle IEC. That way, you can use \pgftransformresetnontranslations to cancel the rotation (and the scaling, but that's okay here) and then just draw the sine path using PGF commands.

That way

\draw (0,0) to [source={AC,direction info={->},info={below:$V_{AC}$}}] (3,0)
        to [source={AC,direction info={->},info={$V_{AC}$}}] (3,3);

Here's the code:

\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
        },
    AC/.style={
        /pgf/generic circle IEC/before background={
            \pgftransformresetnontranslations
            \pgfpathmoveto{\pgfpoint{-0.75\tikzcircuitssizeunit}{0pt}}
            \pgfpathsine{
                \pgfpoint{0.375\tikzcircuitssizeunit}{0.375\tikzcircuitssizeunit}}
            \pgfpathcosine{
                \pgfpoint{0.375\tikzcircuitssizeunit}{-0.375\tikzcircuitssizeunit}}
            \pgfpathsine{
                \pgfpoint{0.375\tikzcircuitssizeunit}{-0.375\tikzcircuitssizeunit}}
            \pgfpathcosine{
                \pgfpoint{0.375\tikzcircuitssizeunit}{0.375\tikzcircuitssizeunit}}
            \pgfusepathqstroke
        }
    }
}

\begin{tikzpicture}[circuit ee IEC]
        \draw (0,0) to [source={AC,direction info={->},info={below:$V_{AC}$}}] (3,0)
        to [source={AC,direction info={->},info={$V_{AC}$}}] (3,3);
    \end{tikzpicture}
\end{document}
share|improve this answer
    
That's great! Thanks Jake! :) –  Count Zero Sep 11 '11 at 10:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.