5

I've got a problem with the following code. I'm trying to draw a circuit using circuitikz. However, the current source should be shifted by 1 unit in the x-direction, so that it is placed parallel to the first inductor of the transformer. I figured it should work with this relative coordinate positioning but there seems to be a problem.

\begin{figure}[h!]
    \begin{center}
        \begin{circuitikz}
            \draw (0,0)
            node[transformer core, yscale=1.25] (T) {};
            \draw (T.A2)+(-1,0)
            to [sI] (T.A1)+(-1,0);              
            \end{circuitikz}
        \caption{My first circuit.}
    \end{center}
\end{figure}
4

You should use something like

\draw (T.A2) -- +(-1,0)
            to [sI] ($(T.A1)+(-1,0)$) -- (T.A1);

Start with T.A2, move the pen to left by 1 unit, then draw the current source up to the point ($(T.A1)+(-1,0)$) (this needs calc library) and then connect to T.A1.

Full code:

\documentclass{article}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\begin{document}
  \begin{circuitikz}
            \draw (0,0)
            node[transformer core, yscale=1.25] (T) {};
            \draw (T.A2) -- +(-1,0)
            to [sI] ($(T.A1)+(-1,0)$) -- (T.A1);
  \end{circuitikz}
\end{document}

enter image description here

1

A PSTricks solution using the pst-circ package:

\documentclass{article}

\usepackage{pst-circ}

\begin{document}

\begin{pspicture}(4.5,4)
  \pnodes(0.5,0){A}(0.5,4){B}(2.5,4){C}(4.5,4){D}(4.5,0){E}(2.5,0){F}
  \transformer(C)(F)(D)(E){}
  \wire(A)(F)
  \vac(A)(B){}
  \wire(B)(C)
\end{pspicture}

\end{document}

output

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.