5

I've drawn a simple circuit diagram with CircuiTikZ, but my wires do somehow reach into my resistors which doesn't look very pretty. I guess this is quite easy to fix, but I couldn't do it.

\documentclass{article}
\usepackage[european,straightvoltages]{circuitikz}

\begin{document}
\begin{circuitikz}
    \draw (0,2) to[open,v=$u_q(t)$] (0,0);
    \draw (0,2) to[short,o-] (1,2);
    \draw (1,2) to[R, l=$R$, v>=$u_R(t)$] (2,2);
    \draw (2,2) -- (3,2);
    \draw (3,2) to[L, l=$L$,v>=$u_{ind}(t)$] (4,2);
    \draw (4,2) -- (5,2);
    \draw (5,2) to[short,i=$i(t)$] (5,0);
    \draw (0,0) to[short,o-] (5,0);
\end{circuitikz}
\end{document}

Enter image description here

2
  • 1
    The main problem here (to clarify a bit) is that the distance between (1,2) and (2,2) is (1,0), and with default TikZ settings that is 1cm. By default, the resistor is bigger... You can scale every component see the manual for example with \ctikzset{bipoles/length=.8cm}.
    – Rmano
    Commented Jun 18, 2021 at 7:25
  • In other words, instead of extending into the resistor, you are starting inside the resistor and extending out to the anchors. Commented Jun 18, 2021 at 13:24

1 Answer 1

8

You are overdrawing the wire into the "R" component by the code

      \draw (0,2) to[short,o-] (1,2);

Have a look now:

Enter image description here

\documentclass{article}
\usepackage[european,straightvoltages]{circuitikz}

\begin{document}
\begin{circuitikz}
    \draw (0,2) to[open,v=$u_q(t)$] (0,0);
    \draw (0,2) to[short,o-] (0,2);
    \draw (0,2) to[R, l=$R$, v>=$u_R(t)$] (2,2);
    \draw (2,2) -- (3,2);
    \draw (3,2) to[L, l=$L$,v>=$u_{ind}(t)$] (4,2);
    \draw (4,2) -- (5,2);
    \draw (5,2) to[short,i=$i(t)$] (5,0);
    \draw (0,0) to[short,o-] (5,0);
\end{circuitikz}
\end{document}

With relative positioning you will not go wrong -- will give the same result

And avoid overlap of wire into the inductor ("L") also:

Enter image description here

\documentclass{article}
\usepackage[european,straightvoltages]{circuitikz}

\begin{document}
\begin{circuitikz}
    \draw (0,2) to [open,v=$u_q(t)$]            (0,0);
    \draw (0,2) to [short,o-]                   ++(0,0)
                to [R, l=$R$, v>=$u_R(t)$]      ++(2,0)
                to [L, l=$L$,v>=$u_{ind}(t)$]   ++(3,0)
                to [short]                      ++(0.5,0)
                to [short,i=$i(t)$]             ++(0,-2)
                to                              (0,0)
                to [short,o-]                   (0,0);
\end{circuitikz}
\end{document}
3
  • oh right I see, thank you for the very comprehensive answer! I think you have a tiny mistake in your code which makes the wire coming from the resistor reach into the node on the top left
    – M S
    Commented Jun 18, 2021 at 1:15
  • 1
    please see the edit above
    – js bibra
    Commented Jun 18, 2021 at 3:47
  • 1
    @MS the glitch with the pole is explained in the second example about poles in the manual: texdoc.org/serve/circuitikz/0#subsection.6.1
    – Rmano
    Commented Jun 18, 2021 at 7:27

You must log in to answer this question.

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