3

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

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

1 Answer 1

4

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}
6
  • Works very well. Is it possible to add "+" / "-" for dc current sources? Mar 26, 2019 at 16:55
  • @user1583209 didn't quite understand what you are asking.
    – nidhin
    Mar 26, 2019 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, 2019 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, 2019 at 18:19
  • The `v={$U_\sim$}' creates a round arrow for me, not +/- symbols. Mar 26, 2019 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .