# Change appearance of voltage source in circuitikz

I prefer my voltage sources as in the image below. How can I achieve this in circuitikz?

There is an identical question here, however for plain tikz. I tried to implement the solution given their, but it does not seem to work in combination with circtuitikz. In fact it generates an error.

• Cisrcuitikz IS a tikzpicture. You can use the same solution, only easier with node[ocirc] or \to[short,-o]. Mar 25 '19 at 23:51

One simple approach is to use open with o-o option:

\draw (0,0) to ++(1,0) to[open,o-o,l={$U_\sim$}] ++(1,0) to ++(1,0);


Or else, custom component customV can be defined and used:

\draw (3.5,0) to[customV,l={$U_\sim$}] ++(3,0);


MWE:

\documentclass[border=3mm]{standalone}
\usepackage{circuitikz}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/open/height}}{customV}{\ctikzvalof{bipoles/open/height}}{\ctikzvalof{bipoles/vsource/width}}{
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
\pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
\pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}
\def\pgf@circ@customV@path#1{\pgf@circ@bipole@path{customV}{#1}}
\compattikzset{customV/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@customV@path, label=#1}}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0) to ++(1,0) to[open,o-o,l={$U_\sim$}] ++(1,0) to ++(1,0);
\draw (3.5,0) to[customV,l={$U_\sim$}] ++(3,0);
\end{circuitikz}
\end{document}

• Works very well. Is it possible to add "+" / "-" for dc current sources? Mar 26 '19 at 16:55
• @user1583209 didn't quite understand what you are asking. Mar 26 '19 at 17:47
• If possible, I'd like to add the polarity, i.e. a plus and a minus sign below or above the small circles of the voltage source. Mar 26 '19 at 17:51
• @user1583209 replacing l={$U_\sim$} with v={$U_\sim$} will result in +/- symbols on either sides. See if that is fine for you. Mar 26 '19 at 18:19
• The `v={$U_\sim$}' creates a round arrow for me, not +/- symbols. Mar 26 '19 at 18:27