1. Let us assume that we want to put a resistor between (0,0) and (2,0).
  2. This task is easy using the \usetikzlibrary {circuits.ee.IEC}:
    \draw (0,0) to [resistor={info={ $R=1\Omega$}}] (2cm,0);
  1. As we see the width and height of the resistor are automatically selected by the IEC library.

  2. Now suppose we want to draw the same size resistor at the same location using the node shape. The challenge is to guess the inner xsep and ysep. But we can do it by trial and error to get the same size resistor:

    \draw [red](0,0) to node[draw,name=res,shape=var resistor IEC,inner xsep = 0.6cm,inner ysep=0.1cm] {}  (2,0);

5)The main problem is the resistor crosses the wire as below: enter image description here

Do you know how to avoid this wire crossing still using the node shape command? Below is my code:

\usetikzlibrary {circuits.ee.IEC}


\draw [help lines,xstep=.1cm,ystep=.1cm] (0,0.4) grid (2,-.8);
\begin{scope}[circuit ee IEC,set resistor graphic=var resistor IEC graphic,line width=1]
\draw (0,0) to [resistor={info={ $R=1\Omega$}}] (2cm,0);

 \begin{scope}[yshift=-.7cm,line width=1]
\draw [red](0,0) to node[draw,name=res,shape=var resistor IEC,inner xsep = 0.6cm,inner 
ysep=0.1cm] {}  (2,0);



1 Answer 1


Notice that saying (A) to node[]{} (B) is very different from using a to[ to_path_style ]: what you are doing is to draw a line from (A) to (B) and then will add the node after drawing the path.

If you look at the TikZ manual, when they describe how to add a new shape (around page 604 in my version, when they describe /tikz/circuit handle symbol, it is explained that the to path operation that installs the node in the path as a marking. This is probably a more advanced way with respect the circuitikz(*) one --- it will have better joins, I think.

If you try to position the node alone, and then connect it, you'll have problems with the joins.

\begin{scope}[yshift=-1.4cm,line width=1]
    \draw (1,0) node [blue,draw,name=res,shape=var resistor IEC,inner xsep = 0.6cm,inner ysep=0.1cm, name=R]{};
    \draw [blue] (0,0) -- (R.west) (R.east) -- (2,0);

enter image description here

(*) Just a comment because I am maintaining circuitikz here... I will remove my comment now, because I was guessing wrong the circuit library internals.

  • Thanks Rmano, do you know how to fully connect the east and west anchors of resistor to the wires? In your blue circuit there are two gaps at the two ends of the resistor
    – Aria
    Commented Oct 24, 2021 at 19:20
  • Yes, @Aria: that was what I am saying when I say "you'll have problems with the joins". You can try line caps=rect (or round) and it will be better, but not perfect. That shapes are designed to work inside a decoration, so the best thing is to use them in the way they are designed for (in a to[resistor... path). Could be this an XY problem? What is the final result you are looking for?
    – Rmano
    Commented Oct 24, 2021 at 20:22
  • Thanks for the comment. My goal was to use node shape to have a better control on all the aspects such as size, label, location,... But it seems that the to[resistor...] also gives us something controllable although we do not know how they designed it.
    – Aria
    Commented Oct 24, 2021 at 20:58

You must log in to answer this question.

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