\documentclass[border=5pt]{standalone}

% Base packages
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{upgreek}
\usepackage{fp}

% TikZ package
\usepackage{tikz}

% TikZ libraries
\usetikzlibrary{
arrows, arrows.meta, arrows.spaced, bending, babel, calc, fit, positioning, scopes, intersections, through, backgrounds, matrix, chains, quotes, angles, math, topaths, plotmarks,
decorations, decorations.pathmorphing, decorations.markings, decorations.pathreplacing, decorations.shapes, decorations.text, decorations.footprints, decorations.fractals,
shapes, shapes.geometric, shapes.symbols, shapes.arrows, shapes.multipart, shapes.callouts, shapes.misc, shapes.gates.logic.US, shapes.gates.logic.IEC,
patterns, patterns.meta, fadings, shadings, shadows, shadows.blur,
mindmap, calendar, folding, trees, automata, petri, er, turtle, lindenmayersystems, spy, svg.path, bbox, external, fixedpointarithmetic, fpu,
circuits.logic.US, circuits.logic.IEC, circuits.logic.CDH, circuits.ee.IEC,
datavisualization, datavisualization.polar, datavisualization.formats.functions,
3d, perspective, views,
graphs, graphs.standard,
rdf
}

% Math packages
\usepackage{amsmath,amssymb}

% Additional packages
\usepackage{xcolor}

% Restore styles and definitions from original
\makeatletter

% Node style for examples
\tikzset{
help lines/.style={gray,very thin},
important line/.style={thick},
information text/.style={rounded corners,fill=red!10,inner sep=1ex},
}

% Karl's student example
\tikzset{
Karl's grid/.style={help lines,color=blue!50},
Karl's axes/.style={<->},
}

% Petri net styles
\tikzset{
place/.style={circle,draw=blue!50,fill=blue!20,thick,minimum size=6mm},
transition/.style={rectangle,draw=black!50,fill=black!20,thick,minimum size=4mm},
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick},
}

% Automata styles
\tikzset{
state/.style={draw,circle,minimum size=0.6cm},
initial text={},
}

% Tree styles
\tikzset{
level distance=1cm,
sibling distance=1cm,
}

% Default arrow tip (CRITICAL for matching original output)
\tikzset{>=stealth}

% For examples with show path construction
\newcount\mycount

% Common colors
\colorlet{anglecolor}{green!50!black}
\colorlet{sincolor}{red}
\colorlet{tancolor}{orange!80!black}
\colorlet{coscolor}{blue}

% Coordinate styles
\tikzset{
dot/.style={circle,fill,inner sep=0pt,minimum size=4pt},
small dot/.style={circle,fill,inner sep=0pt,minimum size=2pt},
}

% Grid helpers
\newcommand{\drawgrid}[2][]{%
\draw[help lines,#1] #2
}

% Manual specific: concept color definitions for mindmap
\colorlet{concept color}{blue!40}

% Style for spy examples
\tikzset{
spy using outlines/.style={
spy scope={magnification=4, size=2cm, connect spies},
}
}

% For folding library
\newcommand{\face}[1]{%
\draw (0,0) circle (0.5);
\fill (#1+0.2,0.2) circle (0.05);
\fill (#1-0.2,0.2) circle (0.05);
\draw (#1-0.2,-0.15) .. controls (#1,-0.3) .. (#1+0.2,-0.15);
}

% For showing code in examples
\newcommand{\showcode}[1]{\texttt{#1}}

% Bounding box helper
\newcommand{\showbb}{%
\draw[red,thin] (current bounding box.south west) rectangle (current bounding box.north east);
}

% Animation placeholder
\newcommand{\animation}[1]{#1}

% Placeholder for references
\newcommand{\tikzsectionname}{Section}

% For fit examples
\newcommand{\convmark}[1]{\draw[thick] (#1) +(-0.1,-0.1) -- +(0.1,0.1) (#1) +(-0.1,0.1) -- +(0.1,-0.1);}

% Calendar helper
\newcommand{\holidaycalendar}{}

% Data visualization helpers
\newcommand{\showvalue}[1]{#1}

% Suppress some warnings
\pgfkeys{/pgf/decoration/.unknown/.code={}}

\makeatother

\begin{document}
  \begin{tikzpicture}[circuit ee IEC,x=3cm,y=2cm,semithick,
    every info/.style={font=\footnotesize},
    small circuit symbols,
    set resistor graphic=var resistor IEC graphic,
    set diode graphic=var diode IEC graphic,
    set make contact graphic= var make contact IEC graphic]
    % Let us start with some contacts:
    \foreach \contact/\y in {1/1,2/2,3/3.5,4/4.5,5/5.5}
    {
    \node [contact] (left contact \contact) at (0,\y) {};
    \node [contact] (right contact \contact) at (1,\y) {};
    }
    \draw (right contact 1) -- (right contact 2) -- (right contact 3)
    -- (right contact 4) -- (right contact 5);

    \draw (left contact 1) to [diode] ++(down:1)
    to [voltage source={near start,
    direction info={volt=3}},
    resistor={near end,ohm=3}] ++(right:1)
    to (right contact 1);
    \draw (left contact 1) to [resistor={ohm=4}] (right contact 1);
    \draw (left contact 1) to [resistor={ohm=3}] (left contact 2);
    \draw (left contact 2) to [voltage source={near start,
    direction info={<-,volt=8}},
    resistor={ohm=2,near end}] (right contact 2);
    \draw (left contact 2) to [resistor={near start,ohm=1},
    make contact={near end,info'={[red]$S_1$}}]
    (left contact 3);
    \draw (left contact 3) to [current direction'={near start,info=$\iota$},
    resistor={near end,info={$R=4\Omega$}}]
    (right contact 3);
    \draw (left contact 4) to [voltage source={near start,
    direction info={<-,volt=8}},
    resistor={ohm=2,near end}] (right contact 4);
    \draw (left contact 3) to [resistor={ohm=1}] (left contact 4);
    \draw (left contact 4) to [resistor={ohm=3}] (left contact 5);
    \draw (left contact 5) to [resistor={ohm=4}] (right contact 5);
    \draw (left contact 5) to [diode] ++(up:1)
    to [voltage source={near start,
    direction info={volt=3}},
    resistor={near end,ohm=3}] ++(right:1)
    to (right contact 5);
  \end{tikzpicture}
\end{document}