4

I'm trying to create my own symbols for current and voltage sources - basically I want the current source as an encircled arrow in the direction of the current, and the voltage source as a + and - inside a circle, showing the direction of the potential difference.

I've gotten far enough to start to draw things on circles to create these elements, but I can't figure out how to get the orientation right - please see the following example:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\tikzset{set current source graphic = current source IEC graphic}
\tikzset{current source IEC graphic/.style={
    circuit symbol lines,
    circuit symbol size = width 3 height 3,
    shape = generic circle IEC,
    /pgf/generic circle IEC/before background={
        % What do I put here?
        \draw[->,thick] (0,-.5pt) -- (0,.5pt);
    }
}}

\begin{document}
\begin{tikzpicture}[circuit ee IEC,scale=5]
\draw (0,0) to[current source] (2,0) 
            to[current source] (2,2) 
            to[current source] (0,2) 
            to[current source] (0,0);
\end{tikzpicture}
\end{document}

MWE output

The arrows render OK, but they all point up, regardless of the orientation of the circuit element. I'd like the arrows to point along the direction of the element, which in this case is counter-clockwise in the circuit (i.e. the right one is correct, and the others are not).

How do I accomplish that?

7
  • Does transform shape do the job? Jan 31 '13 at 0:01
  • It might, if I knew how to use it. Would you care to give me an example? Jan 31 '13 at 0:05
  • Sorry it does not seem to work in this case... Not sure why. Jan 31 '13 at 0:07
  • Hm, I think I've found my problem, stated clearly on page 314-315 in the pgf manual - referring to the code within the before background key: "When the code is executed, the coordinate system will have been transformed in such a way that 314the point (1pt, 0pt) lies at the right end of the circle and (0pt, 1pt) lies at the top of the circle." This seems to be regardless of the orientation of the element, so whatever I do it will still be rotated back. Sigh... Any suggestion of a way around this is much appreciated. Jan 31 '13 at 0:25
  • In the meantime, I'll direct the arrow left-to-right (since standard for circuit elements is to be that direction when un-rotated) and then use point up etc to get the rotation right. Jan 31 '13 at 0:26
4

transform shape does the job, as suggested by Peter Grill above. The following style definition works for me.

\tikzset{current source IEC graphic/.style={
    circuit symbol lines,
    circuit symbol size = width 3 height 3,
    shape = generic circle IEC,
    /pgf/generic circle IEC/before background={
        % What do I put here?
        %\draw[->,thick] (0,-.5pt) -- (0,.5pt);
        \draw[->,thick] (-.5pt,0) -- (.5pt,0);
    },
    transform shape
}}
1
  • Perfect - this works just as I want it to! Thanks! =) Jan 31 '13 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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