2

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.

enter image description here

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

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

enter image description here

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? – user1583209 Mar 26 at 16:55
  • @user1583209 didn't quite understand what you are asking. – nidhin Mar 26 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. – user1583209 Mar 26 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. – nidhin Mar 26 at 18:19
  • The `v={$U_\sim$}' creates a round arrow for me, not +/- symbols. – user1583209 Mar 26 at 18:27

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.