Example: Electric circuit decorations

Published 2008-04-12 | Author: Umesh Rai

This example demonstrates an interesting use of decorations. A set of custom decorations have been defined to draw various electrical circuit elements. The code for the decorations can be found in the electComp.sty file.

To compile the example you will need the following style file:

Author:B. Umesh Rai

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Electric circuit decorations

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Electrical circuits using decorations
% Author: B. Umesh Rai

\title{Electrical Circuits with pgf}


\begin{tikzpicture}[line width=1pt]
    \draw (0,0) -- ++(0,1cm);
    \draw[decorate, decoration=cell] (0,1cm) -- ++(0,1.5cm);
    \draw (0,2.5cm) |- ++(1cm,1cm);
    \draw[decorate, decoration=diode] (1cm,3.5cm) -- ++(1.5cm,0);
    \draw (2.5cm,3.5cm) -- ++(2,0);
    \draw (3.5cm,3.5cm) -- ++(0,-1);
    \draw[decorate, decoration=switch] (3.5cm,2.5cm) -- ++(0,-1.5cm);
        decoration={inductor,amplitude=0.35cm, segment length=0.75cm}]
        (4.5cm,3.5cm) -- ++(1.5cm,0);
    \draw (6cm,3.5cm) -- ++(1,0);
    \draw (7cm,3.5cm) -- ++(3,0);
    \draw (8cm,3.5cm) -- ++(0,-1);
    \draw[decorate, decoration=capacitor] (8cm,2.5cm) -- ++(0,-1.5cm);
    \draw (0cm,0cm) -| ++(8cm,1cm);
    \draw (3.5cm,0cm) -- ++(0cm,1cm);
    \draw (10cm,3.5cm) -- ++(0,-1);
    \draw[decorate, decoration=resistor] (10cm,2.5cm) -- ++(0,-1.5cm);
    \draw (8cm,0cm) -| ++(2cm,1cm);
    \draw[decorate, decoration=ground] (5,0cm) -- ++(0,-1.5cm);



  • #1 Ivan Savov, February 3, 2012 at 10:30 p.m.

    Thank you.

    Very elegant work, and I really like the little circles which show that components are like LEGO pieces which can be connected in different ways.

    The link to electComp.sty above is broken, but it is available here: http://code.google.com/p/tikz-examples/source/browse/examples/contrib1/electComp.sty

Adding comments is currently not enabled.

Scientific and technical areas


LaTeX Beginners Guide

Limited discount 50%
coupon code tDRet6Y

Creative Commons License