# Circuitikz voltage source American style

I am having an issue with an specific element in Circuitikz, the voltage source.

When I place horizontally this element on a circuit, the (−) and (+) symbols are also rotated, but this behavior is not right, the (−) symbol turns into a awful ( | ) because of the rotation of the voltage source. The same happens to get an oblique voltage source in any rotation angle, for example, when it is rotated 45°, the (+) symbol of the voltage source looks more like a (×) and so on.

What I want to know, is possible to get NON-ROTATED polarity symbols of the voltage source, that is, independent of the voltage source rotation?

Just like the books, they have a perfect representation of an American voltage source rotated in any angle without changing the position of the polarity symbols. (I could use the European style, but these people are not used to it and they might get confused).

• Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. May 9 '14 at 14:44
• The internal minus appears to be part of the component itself, rather than a label of some sort. A quick fix would be to create a second voltage source with the minus signs rotated appropriately. May 10 '14 at 16:17
• Ignore my previous comment. May 10 '14 at 17:50
• Hello, pal. Would you please help me out setting a code to do the same with a controlled voltage source? I still find hard to do it by myself. Thanks in advance. Oct 29 '14 at 14:21

\documentclass{article}
\usepackage{circuitikz}

%% Independent voltage source - American style

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourceam/height}}{vsourceAM}{\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/vsourceam/width}}{

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
\pgfusepath{draw}
\pgfscope
\pgftransformxshift{\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@left}
\pgftext[rotate=-\pgf@circ@direction]{$-$}
\pgfusepath{draw}
\endpgfscope
\pgfscope
\pgftransformxshift{\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@right}
\pgftext[rotate=-\pgf@circ@direction]{$+$}
\pgfusepath{draw}
\endpgfscope
}
\makeatother

\begin{document}

\begin{circuitikz}[american voltages]

\ctikzset{bipoles/vsourceam/margin=.5}% default too big

\draw (0,0) to[V={v1}] (3,0) to[V={v2}] (3,3) to[V={v3}] (0,3) to[V={v4}] (0,0);
\draw (4,0) to[V={v5}] (6,2);
\end{circuitikz}

\end{document}


For a controlled voltage source you could use

%% Controlled voltage source - American

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourceam/height}}{cvsourceAM}{\ctikzvalof{bipoles/cvsourceam/height}}{\ctikzvalof{bipoles/cvsourceam/width}}{

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
%\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@left]{$+$}
%\pgftext[top,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@right]{$-$}
\pgfusepath{draw}
\pgfscope
\pgftransformxshift{\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@left}
\pgftext[rotate=-\pgf@circ@direction]{$-$}
\pgfusepath{draw}
\endpgfscope
\pgfscope
\pgftransformxshift{\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@right}
\pgftext[rotate=-\pgf@circ@direction]{$+$}
\pgfusepath{draw}
\endpgfscope
}
\makeatother

• You are just awesome. You know what you do. I really need to thank you. You are a person who helps to make this world better. It’s been a excelent help. It works, it is perfect. Jun 10 '14 at 1:18
• Sorry about any inconvenience but, would you please help me out setting out a code to do exactly the same but with a controlled voltage source? Thanks. @Jhon-Kormylo Nov 15 '14 at 4:41
• @mov0021 What, no additional reputation points? ;-) Nov 15 '14 at 14:56
• How do I do that? I would really give you points, if that is what you mean. :) Nov 15 '14 at 15:42
• @mov0021 - Don't worry about it. But you might click the checkmark just to remove this from the list of unanswered questions. Nov 15 '14 at 22:30