summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-circuits.tex
blob: 31d4345cb6952cd16d9fab156c9962dcaea3b6d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
% Copyright 2008 by Till Tantau and Mark Wibrow
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.


\section{Circuit Libraries}
\label{section-library-circuits}

\emph{Written and documented by Till Tantau, and Mark Wibrow. Inspired
by the work of Massimo Redaelli.}


\subsection{Introduction}

The circuit libraries can be used to draw different kinds of electrical or
logical circuits. There is not a single library for this, but a whole hierarchy
of libraries that work in concert. The main design goal was to create a balance
between ease-of-use and ease-of-extending, while creating high-quality
graphical representations of circuits.


\subsubsection{A First Example}

\begin{codeexample}[]
\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{codeexample}

An important feature of the circuit library is that the appearance of a circuit
can be configured in general ways and that the labels are placed automatically
by default. Here is the graphic once more, generated from \emph{exactly the
same source code}, with only the options of the |{tikzpicture}| environment
replaced by |[rotate=-90,circuit ee IEC,x=3.25cm,y=2.25cm]|:

\begin{tikzpicture}[rotate=-90,circuit ee IEC,x=3cm,y=2.25cm]
  % 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}


\subsubsection{Symbols}

A circuit typically consists of numerous electronic elements like logical gates
or resistors or diodes that are connected by wires. In \pgfname/\tikzname, we
use nodes for the electronic elements and normal lines for the wires.
\tikzname\ offers a large number of different ways of positioning and
connecting nodes in general, all of which can be used here. Additionally, the
|circuits| library defines an additional useful |to|-path that is particularly
useful for elements like a resistor on a line.

There are many different names that are used to refer to electrical
``elements'', so a bit of terminology standardization is useful: We will call
such elements \emph{symbols}. A \emph{symbol shape} is a \pgfname\ shape
declared using the |\pgfdeclareshape| command. A \emph{symbol node} is a node
whose shape is a symbol shape.


\subsubsection{Symbol Graphics}

Symbols can be created by |\node[shape=some symbol shape]|. However, in order
to represent some symbols correctly, just using standard \pgfname\ shapes is
not sufficient. For instance, most symbols have a visually appealing ``default
size'', but the size of a symbol shape depends only on the current values of
parameters like |minimum height| or |inner xsep|.

For these reasons, the circuit libraries introduce the concept of a
\emph{symbol graphic}. This is a style that causes a |\node| to not only have
the correct shape, but also the correct size and the correct path usage. More
generally, this style may set up things in any way so that the ``symbol looks
correct''. When you write, for instance, |\node[diode]|, then the style called
|diode graphic| is used, which in turn is set to something like
|shape=diode IEC,draw,minimum height=...|.

Here is an overview of the different kinds of circuit libraries:
%
\begin{itemize}
    \item The \tikzname-library |circuits| defines general keys for creating
        circuits. Mostly, these keys are useful for defining more specialized
        libraries.

        You normally do not use this library directly since it does not define
        any symbol graphics.
    \item The \tikzname-library |circuits.logic| defines keys for creating
        logical gates like and-gates or xor-gates. However, this library also
        does not actually define any symbol graphics; this is done by two
        sublibraries:
        %
        \begin{itemize}
            \item The library |circuits.logic.US| defines symbol graphics that
                cause the logical gates to be rendered in the ``US-style''. It
                includes all of the above libraries and you can use this
                library directly.
            \item The library |circuits.logic.IEC| also defines symbol graphics
                for logical gates, but it uses rectangular gates rather that
                the round US-gates. This library can coexist peacefully with
                the above library, you can change which symbol graphics are
                used ``on the fly''.
        \end{itemize}
    \item The \tikzname-library |cirucits.ee| defines keys for symbols from
        electrical engineering like resistors or capacitors. Again,
        sublibraries define the actual symbol graphics.
        %
        \begin{itemize}
            \item The library |circuits.ee.IEC| defines symbol shapes that
                follow the IEC norm.
        \end{itemize}
    \item The \pgfname-libraries |shapes.gates.*| define (circuit) symbol
        shapes. However, you normally do not use these shapes directly, rather
        you use a style that uses an appropriate symbol graphic, which in turn
        uses one of these shapes.
\end{itemize}

Let us have a look at a simple example. Suppose we wish to create a logical
circuit. Then we first have to decide which symbol graphics we would like to
use. Suppose we wish to use the US-style, then we would include the library
|circuits.logic.US|. If you wish to use IEC-style symbols, use
|circuits.logic.IEC|. If you cannot decide, include both:
%
\begin{codeexample}[code only]
\usetikzlibrary{circuits.logic.US,circuits.logic.IEC}
\end{codeexample}
%
To create a picture that contains a US-style circuit you can now use the option
|circuit logic US|. This will set up keys like |and gate| to create use an
appropriate symbol graphic for rendering an |and gate|. Using the
|circuit logic IEC| instead will set up |and gate| to use another symbol
graphic.
%
\begin{codeexample}[]
\begin{tikzpicture}[circuit logic US]
  \matrix[column sep=7mm]
  {
    \node (i0) {0}; &                            & \\
                    & \node [and gate] (a1) {};  & \\
    \node (i1) {0}; &                            & \node [or gate] (o) {};\\
                    & \node [nand gate] (a2) {}; & \\
    \node (i2) {1}; &                            & \\
  };
  \draw (i0.east) -- ++(right:3mm) |- (a1.input 1);
  \draw (i1.east) -- ++(right:3mm) |- (a1.input 2);
  \draw (i1.east) -- ++(right:3mm) |- (a2.input 1);
  \draw (i2.east) -- ++(right:3mm) |- (a2.input 2);
  \draw (a1.output) -- ++(right:3mm) |- (o.input 1);
  \draw (a2.output) -- ++(right:3mm) |- (o.input 2);
  \draw (o.output) -- ++(right:3mm);
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}[circuit logic IEC]
  \matrix[column sep=7mm]
  {
    \node (i0) {0}; &                            & \\
                    & \node [and gate] (a1) {};  & \\
    \node (i1) {0}; &                            & \node [or gate] (o) {};\\
                    & \node [nand gate] (a2) {}; & \\
    \node (i2) {1}; &                            & \\
  };
  \draw (i0.east) -- ++(right:3mm) |- (a1.input 1);
  \draw (i1.east) -- ++(right:3mm) |- (a1.input 2);
  \draw (i1.east) -- ++(right:3mm) |- (a2.input 1);
  \draw (i2.east) -- ++(right:3mm) |- (a2.input 2);
  \draw (a1.output) -- ++(right:3mm) |- (o.input 1);
  \draw (a2.output) -- ++(right:3mm) |- (o.input 2);
  \draw (o.output) -- ++(right:3mm);
\end{tikzpicture}
\end{codeexample}


\subsubsection{Annotations}

An \emph{annotation} is a little extra drawing that can be added to a symbol.
For instance, when you add two little parallel arrows pointing away from some
electrical element, this usually means that the element is light emitting.

Instead of having one symbol for ``diode'' and another for ``light emitting
diode'', there is just one |diode| symbol, but you can add the |light emitting|
annotation to it. This is done by passing the annotation as a parameter to the
symbol as in the following example:
%
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \draw (0,0) to [diode={light emitting}] (3,0)
              to [resistor={adjustable}]  (3,2);
\end{codeexample}


\subsection{The Base Circuit Library}

\begin{tikzlibrary}{circuits}
    This library is a base library that is included by other circuit libraries.
    You do not include it directly, but you will typically use some of the
    general keys, described below.
\end{tikzlibrary}

\begin{key}{/tikz/circuits}
  This key should be passed as an option to a picture or a scope that contains
  a circuit. It will do some internal setups. This key is normally called by
  more specialized keys like |circuit ee IEC|.
\end{key}


\subsubsection{Symbol Size}

\begin{key}{/tikz/circuit symbol unit=\meta{dimension} (initially 7pt)}
    This dimension is a ``unit'' for the size of symbols. The libraries
    generally define the sizes of symbols relative to this dimension. For
    instance, the longer side of an inductor is, by default, in the IEC library
    equal to five times this \meta{dimension}. When you change this
    \meta{dimension}, the size of all symbols will automatically change
    accordingly.

    Note, that it is still possible to overwrite the size of any particular
    symbol. These settings apply only to the default sizes.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC]
  \draw (0,1) to [resistor] (3.5,1);
  \draw[circuit symbol unit=14pt]
        (0,0) to [resistor] (3.5,0);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{stylekey}{/tikz/huge circuit symbols}
    This style sets the default circuit symbol unit to |10pt|.
\end{stylekey}
%
\begin{stylekey}{/tikz/large circuit symbols}
    This style sets the default circuit symbol unit to |8pt|.
\end{stylekey}
%
\begin{stylekey}{/tikz/medium circuit symbols}
    This style sets the default circuit symbol unit to |7pt|.
\end{stylekey}
%
\begin{stylekey}{/tikz/small circuit symbols}
    This style sets the default circuit symbol unit to |6pt|.
\end{stylekey}
%
\begin{stylekey}{/tikz/tiny circuit symbols}
    This style sets the default circuit symbol unit to |5pt|.
\end{stylekey}

\begin{key}{/tikz/circuit symbol size=|width| \meta{width} |height| \meta{height}}
    This key sets |minimum height| to \meta{height} times the current value of
    the circuit symbol unit and the |minimum width| to \meta{width} times this
    value. Thus, this option can be used with a node command to set the size of
    the node as a multiple of the circuit symbol unit.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC]
  \draw (0,1) to [resistor] (2,1) to[inductor] (4,1);

  \begin{scope}
    [every resistor/.style={circuit symbol size=width 3 height 1}]
    \draw (0,0) to [resistor] (2,0) to[inductor] (4,0);
  \end{scope}
\end{tikzpicture}
\end{codeexample}
    %
\end{key}


\subsubsection{Declaring New Symbols}

\begin{key}{/tikz/circuit declare symbol=\meta{name}}
    This key is used to declare a symbol. It does not cause this symbol to be
    shown nor does it set a graphic to be used for the symbol, it simply
    ``prepares'' several keys that can later be used to draw a symbol and to
    configure it.

    In detail, the first key that is defined is just called \meta{name}. This
    key should be given as an option to a |node| or on a |to| path, as
    explained below. The key will take options, which can be used to influence
    the way the symbol graphic is rendered.

    Let us have a look at an example. Suppose we want to define a symbol called
    |foo|, which just looks like a simple rectangle. We could then say
    %
\begin{codeexample}[code only]
\tikzset{circuit declare symbol=foo}
\end{codeexample}
    %
    The symbol could now be used like this:
    %
\begin{codeexample}[code only]
  \node [foo]       at (1,1) {};
  \node [foo={red}] at (2,1) {};
\end{codeexample}

    However, in the above example we would not actually see anything since we
    have not yet set up the graphic to be used by |foo|. For this, we must use
    a key called |set foo graphic| or, generally, |set| \meta{name} |graphic|.
    This key gets graphic options as parameter that will be set when a symbol
    |foo| should be shown:
    %
\begin{codeexample}[]
\begin{tikzpicture}
  [circuit declare symbol=foo,
   set foo graphic={draw,shape=rectangle,minimum size=5mm}]

  \node [foo]       at (1,1) {};
  \node [foo={red}] at (2,1) {};
\end{tikzpicture}
\end{codeexample}

    In detail, when you use the key \meta{name}=\meta{options} with a node, the
    following happens:
    %
    \begin{enumerate}
        \item The |inner sep| is set to |0.5pt|.
        \item The following style is executed:
            %
            \begin{stylekey}{/tikz/every circuit symbol}
                Use this style to set up things in general.
            \end{stylekey}
        \item The graphic options that have been set using |set| \meta{name}
            |graphic| are set.
        \item The style |every |\meta{name} is executed. You can use it to
            configure the symbol further.
        \item The \meta{options} are executed.
  \end{enumerate}

    The key \meta{name} will have a different effect when it is used on a |to|
    path command inside a |circuit| environment (the |circuit| environment sets
    up |to| paths in such a way that the use of a key declared using
    |circuit declare symbol| is automatically detected). When \meta{name} is
    used on a |to| path, the above actions also happen (setting the inner
    separation, using the symbol graphic, and so on), but they are passed to
    the key |circuit handle symbol|, which is explained next.
\end{key}

\begin{key}{/tikz/circuit handle symbol=\meta{options}}
    This key is mostly used internally. Its purpose is to render a symbol. The
    effect of this key differs, depending on whether it is used as the optional
    argument of a |to| path command or elsewhere.

    If the key is not used as an argument of a |to| path command, the
    \meta{options} are simply executed.

    The more interesting case happens when the key is given on a |to| path
    command. In this case, several things happen:
    %
    \begin{enumerate}
        \item The |to| path is locally changed and set to an internal path
            (which you should not try to change) that consists mostly of a
            single straight line.
        \item The \meta{options} are tentatively executed with filtering
            switched on. Everything is filtered out, except for the key |pos|
            and also the styles |at start|, |very near start|, |near start|,
            |midway|, |near end|, |very near end|, and |at end|. If none of
            them is found, |midway| is used.
        \item The filtered option is used to determine a position for the
            symbol on the path. At the given position (with |pos=0|
            representing the start and |pos=1| representing the end), a node
            will be added to the path (in a manner to be described presently).
        \item This node gets \meta{options} as its option list.
        \item The node is added by virtue of a special |markings| decoration.
            This means that a |mark| command is executed that causes the node
            to be placed as a mark on the path.
        \item The marking decoration will automatically subdivide the path and
            cause a line to be drawn from the start of the path to the node's
            border (at the position that lies on a line from the node's center
            to the start of the path) and then from the node's border (at a
            position on the other side of the node) to the end of the path.
        \item The marking decoration will also take care of the case that
            multiple marks are present on a path, in this case the lines from
            and to the borders of the nodes are only between consecutive nodes.
        \item The marking decoration will also rotate the coordinate system in
            such a way that the $x$-axis points along the path. Thus, if you
            use the |transform shape| option, the node will ``point along'' the
            path.
        \item In case a node is at |pos=0| or at |pos=1| some special code will
            suppress the superfluous lines to the start or end of the path.
    \end{enumerate}

    The net effect of all of the above is that a node will be placed ``on the
    path'' and the path will have a ``gap'' just large enough to encompass the
    node. Another effect is that you can use this key multiple times on a path
    to add several node to a path, provided they do not overlap.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit]
  \draw (0,0) to [circuit handle symbol={draw,shape=rectangle,near start},
                  circuit handle symbol={draw,shape=circle,near end}] (3,2);
  \end{tikzpicture}
\end{codeexample}
    %
\begin{codeexample}[]
\begin{tikzpicture}[transform shape,circuit]
  \draw (0,0) to [circuit handle symbol={draw,shape=rectangle,at start},
                  circuit handle symbol={draw,shape=circle,near end}] (3,2);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}


\subsubsection{Pointing Symbols in the Right Direction}

Unlike normal nodes, which generally should not be rotated since this will make
their text hard to read, symbols often need to be rotated. There are two ways
of achieving such rotations:
%
\begin{enumerate}
    \item When you place a symbol on a |to| path, the graphic symbol is
        automatically rotated such that it ``points along the path''. Here is
        an examples that shows how the inductor shape (which looks, unrotated,
        like this: \tikz[circuit ee IEC]\node[inductor]{};) is automatically
        rotated around:
        %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \draw (3,0) to[inductor] (1,0) to[inductor] (0,2);
\end{codeexample}
        %
    \item Many shapes cannot be placed ``on'' a path in this way, namely
        whenever there are more than two possible inputs. Also, you may wish to
        place the nodes first, possibly using a matrix, and connect them
        afterwards. In this case, you can simply add rotations like |rotate=90|
        to the shapes to rotate them. The following four keys make this
        slightly more convenient:
        %
        \begin{key}{/tikz/point up}
            This is the same as |rotate=90|.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC] \node [diode,point up] {};
\end{codeexample}
        \end{key}
        %
        \begin{key}{/tikz/point down}
            This is the same as |rotate=-90|.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC] \node [diode,point down] {};
\end{codeexample}
        \end{key}
        %
        \begin{key}{/tikz/point left}
            This is the same as |rotate=-180|.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC] \node [diode,point left] {};
\end{codeexample}
        \end{key}
        %
        \begin{key}{/tikz/point right}
            This key has no effect.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC] \node [diode,point right] {};
\end{codeexample}
        \end{key}
\end{enumerate}


\subsubsection{Info Labels}

Info labels are used to add text to a circuit symbol. Unlike normal nodes like
a rectangle, circuit symbols typically do not have text ``on'' them, but the
text is placed next to them (like the text ``$3\,\Omega$'' next to a resistor).

\tikzname\ already provides the |label| option for this purpose. The |info|
option is built on top of this option, but it comes in some predefined variants
that are especially useful in conjunction with circuits.

\begin{key}{/tikz/info=\opt{|[|\meta{options}|]|\meta{angle}|:|}\meta{text}}
    This key has nearly the same effect as the |label| key, only the following
    style is used additionally automatically:
    %
    \begin{stylekey}{/tikz/every info}
        Set this style to configure the styling of info labels. Since this
        key is \emph{not} used with normal labels, it provides an easy way
        of changing the way info labels look without changing other
        labels.
    \end{stylekey}
    %
    The \meta{options} and \meta{angle} are passed directly to the |label|
    command.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
  \node [resistor,info=$3\Omega$] {};
\end{tikzpicture}
\end{codeexample}

    You will find a detailed discussion of the |label| option on
    page~\pageref{label-option}.

    Hint: To place some text \emph{on} the main node, use |center| as the
    \meta{angle}:
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
  \node [resistor,info=center:$3\Omega$] {};
  \node [resistor,point up,info=center:$R_1$] at (2,0) {};
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/info'=\opt{|[|\meta{options}|]|\meta{angle}|:|}\meta{text}}
    This key works exactly like the |info| key, only in case the \meta{angle}
    is missing, it defaults to |below| instead of the current value of
    |label position|, which is usually |above|. This means that when you use
    |info|, you get a label above the node, while when you use the |info'| key
    you get a label below the node. In case the node has been rotated, the
    positions of the info nodes are rotated accordingly.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
  \draw (0,0) to[resistor={info={$3\Omega$},info'={$R_1$}}] (3,0)
              to[resistor={info={$4\Omega$},info'={$R_2$}}] (3,2);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/info sloped=\opt{|[|\meta{options}|]|\meta{angle}|:|}\meta{text}}
    This key works like |info|, only the |transform shape| option is set when
    the label is drawn, causing it to follow the sloping of the main node.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
  \draw (0,0) to[resistor={info sloped={$3\Omega$}}] (3,0)
              to[resistor={info sloped={$4\Omega$}}] (3,2);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/info' sloped=}
    This is a combination of |info'| and |info sloped|.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,every info/.style=red]
  \draw (0,0) to[resistor={info' sloped={$3\Omega$}}] (3,0)
              to[resistor={info' sloped={$4\Omega$}}] (3,2);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/circuit declare unit=\marg{name}\marg{unit}}
    This key is used to declare keys that make it easy to attach physical units
    to nodes. The idea is that instead of |info=$3\Omega$| you can write
    |ohm=3| or instead of |info'=$5\mathrm{S}$| you can write |siemens'=5|.

    In detail, four keys are defined, namely |/tikz/|\meta{name},
    |/tikz/|\meta{name}|'|, |/tikz/|\meta{name} |sloped|, and
    |/tikz/|\meta{name}|'| |sloped|. The arguments of all of these keys are of
    the form \opt{|[|\meta{options}|]|\meta{angle}|:|}\meta{value} and it is
    passed (slightly modified) to the corresponding key |info|, |info'|, |info|
    |sloped|, or |info'| |sloped|. The ``slight modification'' is the
    following: The text that is passed to the, say, |info| key is not
    \meta{value}, but rather |$\mathrm{|\meta{value}\meta{unit}|}$|

    This means that after you said |circuit declare unit={ohm}{\Omega}|, then
    |ohm=5k| will have the same effect as
    |info={[every ohm]$\mathrm{5k\Omega}$}|. Here, |every ohm| is a style that
    allows you to configure the appearance of this unit. Since the |info| key
    is used internally, by changing the |every info| style, you can change the
    appearance of all units infos.
    %
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC,circuit declare unit={my ohm}{O}]
  \draw (0,0) to[resistor={my ohm' sloped=3}] (3,2);
\end{tikzpicture}
\end{codeexample}
    %
\end{key}


\subsubsection{Declaring and Using Annotations}

Annotations are quite similar to info labels. The main difference is that they
generally cause something to be drawn by default rather than some text to be
added (although an annotation might also add some text).

Annotations can be declared using the following key:

\begin{key}{/tikz/circuit declare annotation=\marg{name}\marg{distance}\marg{path}}
    This key is used to declare an annotation named \meta{name}. Once declared,
    it can be used as an argument of a symbol and will add the drawing in
    \meta{path} to the symbol. In detail, the following happens:


    \textbf{The Main Keys.}
    Two keys called \meta{name} and \meta{name}|'| are defined. The second
    causes the annotation to be ``mirrored and placed on the other side'' of
    the symbol. Both of these keys may also take further keys as parameter like
    |info| keys. Whenever the \meta{name} key is used, a local scope is opened
    and in this scope the following things are done:
    %
    \begin{enumerate}
        \item The style |every| \meta{name} is executed.
        \item The following style is executed and then |arrows=->|:
            %
            \begin{stylekey}{/tikz/annotation arrow}
                This style should set the |>| key to some desirable arrow tip.
            \end{stylekey}
        \item The coordinate system is shifted such that the origin is at the
            north anchor of the symbol. (For the \meta{name}|'| key the
            coordinate system is flipped and shifted such that the origin is at
            the south anchor of the symbol.)
        \item The |label distance| is locally set to \meta{distance}.
        \item The parameter options given to the \meta{name} key are executed.
        \item The \meta{path} is executed.
    \end{enumerate}


    \textbf{Usage.}
    What all of the above amounts to is best explained by an example. Suppose
    we wish to create an annotation that looks like a little circular arrow
    (like \tikz \draw [->] (0,0) arc (-270:80:1ex);). We could then say:
    %
\begin{codeexample}[code only]
\tikzset{circuit declare annotation=
  {circular annotation}
  {9pt}
  {(0pt,8pt) arc (-270:80:3.5pt)}
}
\end{codeexample}
    %
    We can then use it like this:
    %
\tikzset{circuit declare annotation=
  {circular annotation}
  {8pt}
  {(0pt,8pt) arc (-270:80:3.5pt)}
}
\begin{codeexample}[]
\tikz[circuit ee IEC]
  \draw (0,0) to [resistor={circular annotation}]   (3,0);
\end{codeexample}
    %
    Well, not very impressive since we do not see anything. This is due to the
    fact that the \meta{path} becomes part of a path that contains the symbol
    node an nothing else. This path is not drawn or filled, so we do not see
    anything. What we must do is to use an |edge| path operation:
    %
\begin{codeexample}[]
\tikzset{circuit declare annotation={circular annotation}{9pt}
  {(0pt,8pt) edge[to path={arc(-270:80:3.5pt)}] ()}
}
\tikz[circuit ee IEC]
  \draw (0,0) to [resistor={circular annotation}]   (3,0)
              to [capacitor={circular annotation'}] (3,2);
\end{codeexample}
    %
    The \meta{distance} is important for the correct placement of additional
    |info| labels. When an annotation is present, the info labels may need to
    be moved further away from the symbol, but not always. For this reason, an
    annotation defines an additional \meta{distance} that is applied to all
    info labels given as parameters to the annotation. Here is an example, that
    shows the difference:
    %
\tikzset{circuit declare annotation={circular annotation}{9pt}
  {(0pt,8pt) edge[to path={arc (-270:80:3.5pt)}] ()}
}
\begin{codeexample}[]
\tikz[circuit ee IEC]
  \draw (0,0) to [resistor={circular annotation,ohm=5}]   (2,0)
              to [resistor={circular annotation={ohm=5}}] (4,0);
\end{codeexample}
    %
\end{key}


\subsubsection{Theming Symbols}
\label{section-theming-symbols}

For each symbol, a certain graphical representation is chosen to actually show
the symbol. You can modify this graphical representation in several ways:
%
\begin{itemize}
    \item You can select a different library and use a different |circuit ...|
        key. This will change all graphics used for the symbols.
    \item You can generally change the size of graphic symbols by setting
        |circuit size unit| to a different value or using a key like
        |small circuit symbols|.
    \item You can add options to the graphics used by symbols either globally
        by setting the |every circuit| |symbol| style or locally by setting the
        |every| \meta{name} style, where \meta{name} is the name of a symbol.
        For instance, in the following picture the symbols are ridiculously
        thick and resistors are red.
        %
\begin{codeexample}[]
\begin{tikzpicture}
  [circuit ee IEC,
   every circuit symbol/.style={ultra thick},
   every resistor/.style={red}]

  \draw (0,0) to [inductor] ++(right:3) to [resistor] ++(up:2);
\end{tikzpicture}
\end{codeexample}
        %
    \item You can selectively change the graphic used for a symbol by saying
        |set resistor graphic=|.
    \item You can change one or more of the following styles:
        %
        \begin{stylekey}{/tikz/circuit symbol open (initially draw)}
            This style is used with symbols that consist of lines that surround
            some area. For instance, the IEC version of a resistor is an open
            symbol.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC,
       circuit symbol open/.style={thick,draw,fill=yellow}]
  \draw (0,0) to [inductor] ++(right:3) to [resistor] ++(up:2);
\end{codeexample}
        \end{stylekey}
        %
        \begin{stylekey}{/tikz/circuit symbol filled (initially {draw,fill=black})}
            This style is used with symbols that are completely filled. For
            instance, the variant IEC version of an inductor is a filled, black
            rectangle.
        \end{stylekey}
        %
        \begin{stylekey}{/tikz/circuit symbol lines (initially draw)}
            This style is used with symbols that consist only of lines that do
            not surround anything. Examples are a capacitor.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC,
       circuit symbol lines/.style={thick,draw=red}]
  \draw (0,0) to [capacitor] ++(right:3) to [resistor] ++(up:2);
\end{codeexample}
        \end{stylekey}
        %
        \begin{stylekey}{/tikz/circuit symbol wires (initially draw)}
            This style is used for symbols that consist only of ``wires''. The
            difference to the previous style is that a symbol consisting of
            wires will look strange when the lines are thicker than the lines
            of normal wires, while for symbols consisting of lines (but not
            wires) it may look nice to make them thicker. An example is the
            |make contact| symbol.

            Compare
            %
\begin{codeexample}[]
\tikz [circuit ee IEC,circuit symbol lines/.style={draw,very thick}]
  \draw (0,0) to [capacitor={near start},
                  make contact={near end}] (3,0);
\end{codeexample}
            %
            to
            %
\begin{codeexample}[]
\tikz [circuit ee IEC,circuit symbol wires/.style={draw,very thick}]
  \draw (0,0) to [capacitor={near start},
                  make contact={near end}] (3,0);
\end{codeexample}
        \end{stylekey}
\end{itemize}

All circuit environments like |circuit logic IEC| mainly use options like
|set and gate graphic=...| to set up the graphics used for a certain symbol. It
turns out that graphic hidden in the ``|...|'' part is also always available as
a separate style, whose name contains the library's initials. For instance, the
|circuit logic IEC| option actually contains the following command:
%
\begin{codeexample}[code only]
  set and gate graphic = and gate IEC graphic,
\end{codeexample}
%
The |and gate IEC graphic| style, in turn, is defined as follows:
%
\begin{codeexample}[code only]
\tikzset{and gate IEC graphic/.style=
  {
    circuit symbol open,
    circuit symbol size=width 2.5 height 4,
    shape=and gate IEC,
    inner sep=.5ex
  }
}
\end{codeexample}

Normally, you do not need to worry about this, since you will not need to
access a style like |and gate IEC graphic| directly; you will only use the
|and gate| key. However, sometimes libraries define \emph{variants} of a
graphic; for instance, there are two variants for the resistor graphic in the
IEC library. In this case you can set the graphic for the resistor to this
variant (or back to the original) by saying |set resistor graphic| yourself:
%
\begin{codeexample}[]
\begin{tikzpicture}[circuit ee IEC]
  % Standard resistor
  \draw (0,2) to [resistor] (3,2);

  % Var resistor
  \begin{scope}[set resistor graphic=var resistor IEC graphic]
    \draw (0,1) to [resistor] (3,1);

    % Back to original
    \draw [set resistor graphic=resistor IEC graphic]
      (0,0) to [resistor] (3,0);
  \end{scope}
\end{tikzpicture}
\end{codeexample}


\subsection{Logical Circuits}

\subsubsection{Overview}

A \emph{logical circuit} is a circuit that contains what we call \emph{logical
gates} like an |and gate| or an |xor gate|. The logical libraries are intended
to make it easy to draw such circuits.

In the following, we first have a look at the different libraries that can be
used in principle and how the symbols look like. Then we have a more detailed
look at how the symbols are used. Finally, we discuss the implementation
details.

There are different ways of depicting logical gates, which is why there are
different (sub-)libraries for drawing them. They provide the necessary
graphical representations of the symbols declared in the following library:

\begin{tikzlibrary}{circuits.logic}
    This library declares the logical gate symbols, but does not provide the
    symbol graphics. The library also defines the following key which, however,
    is also only used indirectly, namely by other libraries:
    %
    \begin{key}{/tikz/circuit logic}
        This style calls the keys |circuit| (which internally calls
        |every circuit|, then it defines the |inputs| key and it calls the
        |every circuit logic| key.
        %
        \begin{key}{/tikz/inputs=\meta{inputs}}
            This key is defined only inside the scope of a |circuit logic|.
            There, it has the same effect as |logic gate inputs|, described on
            page~\pageref{logic-gate-inputs}.
        \end{key}
        %
        \begin{stylekey}{/tikz/every circuit logic}
            Use this key to configure the appearance of logical circuits.
        \end{stylekey}
    \end{key}
\end{tikzlibrary}

Since the |circuit.logic| library does not define any actual graphics, you need
to use one of the following libraries, instead:

\begin{pgflibrary}{circuits.logic.IEC}
    This library provides graphics based on gates recommended by the
    International Electrotechnical Commission.  When you include this library,
    you can use the following key to set up a scope that contains a logical
    circuit where the gates are shown in this style.

    \begin{key}{/tikz/circuit logic IEC}
        This key calls |circuit logic| and installs the IEC-like graphics for
        the logical symbols like |and gate|.

        As explained in Section~\ref{section-theming-symbols}, for each graphic
        symbol of the library there is also a style that stores this particular
        appearance. These keys are called |and gate IEC graphic|,
        |or gate IEC graphic|, and so on.
        %
\begin{codeexample}[]
\begin{tikzpicture}[circuit logic IEC,
                    every circuit symbol/.style={
                      logic gate IEC symbol color=black,
                      fill=blue!20,draw=blue,very thick}]
  \matrix[column sep=7mm]
  {
    \node (i0) {0}; &                            & \\
                    & \node [and gate] (a1) {};  & \\
    \node (i1) {0}; &                            & \node [or gate] (o) {};\\
                    & \node [nand gate] (a2) {}; & \\
    \node (i2) {1}; &                            & \\
  };
  \draw (i0.east) -- ++(right:3mm) |- (a1.input 1);
  \draw (i1.east) -- ++(right:3mm) |- (a1.input 2);
  \draw (i1.east) -- ++(right:3mm) |- (a2.input 1);
  \draw (i2.east) -- ++(right:3mm) |- (a2.input 2);
  \draw (a1.output) -- ++(right:3mm) |- (o.input 1);
  \draw (a2.output) -- ++(right:3mm) |- (o.input 2);
  \draw (o.output) -- ++(right:3mm);
\end{tikzpicture}
\end{codeexample}
    \end{key}
\end{pgflibrary}

\begin{pgflibrary}{circuits.logic.US}
    This library provides graphics showing ``American'' logic gates. It defines
    the following key:

    \begin{key}{/tikz/circuit logic US}
        This style calls |circuit logic| and installs US-like graphics for the
        logical symbols like |and gate|. For instance, it says
        %
\begin{codeexample}[code only]
set and gate graphic = and gate US graphic
\end{codeexample}

        Here is an example:
        %
\begin{codeexample}[]
\begin{tikzpicture}[circuit logic CDH,
                    tiny circuit symbols,
                    every circuit symbol/.style={
                      fill=white,draw}]
  \matrix[column sep=7mm]
  {
    \node (i0) {0}; &                            & \\
                    & \node [and gate] (a1) {};  & \\
    \node (i1) {0}; &                            & \node [or gate] (o) {};\\
                    & \node [nand gate] (a2) {}; & \\
    \node (i2) {1}; &                            & \\
  };
  \draw (i0.east) -- ++(right:3mm) |- (a1.input 1);
  \draw (i1.east) -- ++(right:3mm) |- (a1.input 2);
  \draw (i1.east) -- ++(right:3mm) |- (a2.input 1);
  \draw (i2.east) -- ++(right:3mm) |- (a2.input 2);
  \draw (a1.output) -- ++(right:3mm) |- (o.input 1);
  \draw (a2.output) -- ++(right:3mm) |- (o.input 2);
  \draw (o.output) -- ++(right:3mm);
\end{tikzpicture}
\end{codeexample}
    \end{key}
\end{pgflibrary}

\begin{pgflibrary}{circuits.logic.CDH}
    This library provides graphics based on the logic symbols used in A. Croft,
    R. Davidson, and M. Hargreaves (1992),  \emph{Engineering Mathematics},
    Addison-Wesley, 82--95. They are identical to the US-style symbols, except
    for the and- and nand-gates.

    \begin{key}{/tikz/circuit logic CDH}
        This key calls |circuit logic US| and installs the two special and- and
        nand-gates, that is, it uses |set and gate graphic| with
        |and gate CDH graphic| and likewise for nand-gates.
    \end{key}
\end{pgflibrary}

Inside |circuit logic XYZ| scopes, you can now use the keys shown in
Section~\ref{section-logic-symbols}. We have a more detailed look at one of
them, all the other work the same way:

\begin{key}{/tikz/and gate}
    This key should be passed to a |node| command. It will cause the node to
    ``look like'' an |and gate|, where the exact appearance of the gate is
    dictated by the which circuit environment is used. To further configure the
    appearance of the |and gate|, see Section~\ref{section-theming-symbols}.
    %
\begin{codeexample}[]
\tikz [circuit logic IEC] \node [and gate] {$A$};
\end{codeexample}
    %
\begin{codeexample}[]
\tikz [circuit logic US]
{
  \node [and gate,point down] {$A$};
  \node [and gate,point down,info=center:$A$] at (1,0) {};
}
\end{codeexample}

    \medskip\textbf{Inputs.}
    Multiple inputs can be specified for a logic gate (provided they support
    multiple inputs: a not gate -- also known as an inverter -- does not).
    However, there is an upper limit for the number of inputs which has been
    set to 1024, which should be \emph{way} more than would ever be needed.

    The following key is used to configure the inputs. It is available only
    inside a |circuit logic| environment.

    \begin{key}{/tikz/inputs=\meta{input list} (initially \char`\{normal,normal\char`\})}
        If a gate has $n$ inputs, the \meta{input list} should consists of $n$
        letters, each being |i| for ``inverted'' or |n| for ``normal''.
        Inverted gates will be indicated by a little circle. In any case the
        anchors for the inputs will be set up appropriately, numbered from top
        to bottom |input 1|, |input 2|, \ldots and so on. If the gate only
        supports one input the anchor is simply called |input| with no
        numerical index.
        %
\begin{codeexample}[]
\begin{tikzpicture}[circuit logic IEC]
  \node[and gate,inputs={inini}] (A) {};
  \foreach \a in {1,...,5}
    \draw (A.input \a -| -1,0) -- (A.input \a);
  \draw (A.output) -- ++(right:5mm);
\end{tikzpicture}
\end{codeexample}
    \end{key}

    (This key is just a shorthand for |logic gate inputs|, described in detail
    on page~\pageref{logic-gate-inputs}. There you will also find descriptions
    of how to configure the size of the inverted circles and the way the symbol
    size increases when there are too many inputs.)

    \textbf{Output.}
    Every logic gate has one anchor called |output|.
\end{key}


\subsubsection{Symbols: The Gates}
\label{section-logic-symbols}

The following table shows which symbols are declared by the main
|circuits.logic| library and their appearance in the different sublibraries.
\medskip

\def\gateexamples#1{%
  \texttt{#1}
  \indexkey{#1} &
  \tikz[baseline,circuit logic IEC] \node[#1,label=] {}; &
  \tikz[baseline,circuit logic US]  \node[#1] {}; &
  \tikz[baseline,circuit logic CDH] \node[#1] {};
}
\begin{tabular}{lccc}
  \emph{Key} & \emph{Appearance inside} & \emph{Appearance inside} & \emph{Appearance inside} \\
      & |circuit logic IEC| & |circuit logic US| & |circuit logic CDH| \\
  \gateexamples{/tikz/and gate}\\
  \gateexamples{/tikz/nand gate}\\
  \gateexamples{/tikz/or gate}\\
  \gateexamples{/tikz/nor gate}\\
  \gateexamples{/tikz/xor gate}\\
  \gateexamples{/tikz/xnor gate}\\
  \gateexamples{/tikz/not gate}\\
  \gateexamples{/tikz/buffer gate}
\end{tabular}


\subsubsection{Implementation: The Logic Gates Shape Library}

The previous sections described the \tikzname\ interface for creating logical
circuits. In this section we take a closer look at the underlying \pgfname\
libraries.

Just as there are several \tikzname\ circuit libraries, there are two
underlying \pgfname\ shape libraries, one for creating US-style gates and one
for IEC-style gates. These libraries define \emph{shapes} only. It is the job
of the circuit libraries to ``theme'' them so that they ``look nice''. However,
in principle, you can also use these shapes directly.

Let us begin with the base library that defines the handling of inputs.

\begin{pgflibrary}{shapes.gates.logic}
    This library defines common keys used by all logical gate shapes.

    \begin{key}{/pgf/logic gate inputs=\meta{input list} (initially \char`\{normal,normal\char`\})}
    \label{logic-gate-inputs}%
        Specify the inputs for the logic gate. The keyword |inverted| indicates
        an inverted input which will mean \pgfname{} will draw a circle
        attached to the main shape of the logic gate. Any keyword that is not
        |inverted| will be treated as a ``normal'' or ``non-inverted'' input
        (however, for readability, you may wish to use |normal| or
        |non-inverted|), and \pgfname{} will not draw the circle. In both cases
        the anchors for the inputs will be set up appropriately, numbered from
        top to bottom |input 1|, |input 2|, \ldots and so on. If the gate only
        supports one input the anchor is simply called |input| with no
        numerical index.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \node[and gate IEC, draw, logic gate inputs={inverted, normal, inverted}]
    (A) {};
  \foreach \a in {1,...,3}
    \draw (A.input \a -| -1,0) -- (A.input \a);
  \draw (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}

        For multiple inputs it may be somewhat unwieldy to specify a long list,
        thus, the following ``shorthand'' is permitted (this is an extension of
        ideas due to Jürgen Werber and Christoph Bartoschek): Using |i| for
        inverted and |n| for normal inputs, \meta{input list} can be specified
        \emph{without the commas}. So, for example, |ini| is equivalent to
        |inverted, normal, inverted|.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \node[or gate US, draw,logic gate inputs=inini] (A) {};
  \foreach \a in {1,...,5}
    \draw (A.input \a -| -1,0) -- (A.input \a);
  \draw (A.output) -- ([xshift=0.5cm]A.output);
\end{tikzpicture}
\end{codeexample}
    \end{key}

    The height of the gate may be increased to accommodate the number of
    inputs. In fact, it depends on three variables: $n$, the number of inputs,
    $r$, the radius of the circle used to indicate an inverted input and $s$,
    the distance between the centers of the inputs. The default height is then
    calculated according to the expression $(n+1)\times\max(2r,s)$. This then
    may be increased to accommodate the node contents or any minimum size
    specifications.

    The radius of the inverted input circle and the distance between the
    centers of the inputs can be customized using the following keys:

    \begin{key}{/pgf/logic gate inverted radius=\meta{length} (initially 2pt)}
        Set the radius of the circle that is used to indicate inverted inputs.
        This is also the radius of the circle used for the inverted output of
        the |nand|, |nor|, |xnor| and |not| gates.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=0.75cm]
  \tikzset{every node/.style={shape=nand gate CDH, draw, logic gate inputs=ii}}
  \node[logic gate inverted radius=2pt] {A};
  \node[logic gate inverted radius=4pt] at (0,-1) {B};
\end{tikzpicture}
\end{codeexample}
        %
    \end{key}

    \begin{key}{/pgf/logic gate input sep=\meta{length} (initially .125cm)}
        Set the distance between the \emph{centers} of the inputs to the logic
        gate.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum size=0.75cm]
  \draw [help lines] grid (3,2);
  \tikzset{every node/.style={shape=and gate IEC, draw, logic gate inputs=ini}}
  \node[logic gate input sep=0.33333cm] at (1,1)(A) {A};
  \node[logic gate input sep=0.5cm]     at (3,1) (B) {B};
  \foreach \a in {1,...,3}
    \draw (A.input \a -| 0,0) -- (A.input \a)
          (B.input \a -| 2,0) -- (B.input \a);
\end{tikzpicture}
\end{codeexample}
        %
    \end{key}

    \pgfname{} will increase the size of the logic gate to accommodate the
    number of inputs, and the size of the inverted radius and the separation
    between the inputs. However with all shapes in this library, any increase
    in size (including any minimum size requirements) will be applied so that
    the default aspect ratio is unaltered. This means that changing the height
    will change the width and vice versa.
\end{pgflibrary}


\subsubsection{Implementation: The US-Style Logic Gates Shape Library}

\begin{pgflibrary}{shapes.gates.logic.US}
    This library provides ``American'' logic gate shapes whose names are
    suffixed with the identifier |US|. Additionally, alternative |and| and
    |nand| gates are provided which are based on the logic symbols used in A.
    Croft, R. Davidson, and M. Hargreaves (1992), \emph{Engineering
    Mathematics}, Addison-Wesley, 82--95. These two shapes are suffixed with
    |CDH|.

    The ``compass point'' anchors apply to the main part of the shape and do
    not include any inverted inputs or outputs. This library provides an
    additional feature to facilitate the relative positioning of logic gates:

    \begin{key}{/pgf/logic gate anchors use bounding box=\meta{boolean} (initially false)}
        When set to |true| this key will ensure that the compass point anchors
        use the bounding rectangle of the main shape, which, ignore any
        inverted inputs or outputs, but includes any |outer sep|. This
        \emph{only} affects the compass point anchors and is not set on a shape
        by shape basis: whether the bounding box is used is determined by value
        of this key when the anchor is accessed.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum height=1.5cm]
  \node[xnor gate US, draw, gray!50,line width=2pt] (A) {};
  \foreach \x/\y/\z in {false/blue/1pt, true/red/2pt}
    \foreach \a in {north, south, east, west, north east,
      south east, north west, south west}
      \draw[logic gate anchors use bounding box=\x, color=\y]
        (A.\a) circle(\z);
\end{tikzpicture}
\end{codeexample}
        %
    \end{key}

    The library defines a number of shapes. For each shape the allowed number
    of inputs is also shown:
    %
    \begin{itemize}
        \item |and gate US|, two or more inputs
        \item |and gate CDH|, two or more inputs
        \item |nand gate US|, two or more inputs
        \item |nand gate CDH|, two or more inputs
        \item |or gate US|, two or more inputs
        \item |nor gate US|, two or more Inputs
        \item |xor gate US|, two inputs
        \item |xnor gate US|, two inputs
        \item |not gate US|, one input
        \item |buffer gate US|, one input
    \end{itemize}

    In the following, we only have a detailed look at the anchors defined by
    one of them. We choose the |nand gate US| because it shows all the
    ``interesting'' anchors.

    \begin{shape}{nand gate US}
        This shape is a nand gate, which supports two or more inputs. If less
        than two inputs are specified an error will result. The anchors for
        this gate with two non-inverted inputs (using the normal compass point
        anchors) are shown below. Anchor |30| is an example of a border anchor.
        %
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nand gate US,shape example, inner sep=0cm,
  logic gate inputs={in},
  logic gate inverted radius=.5cm] {Nand Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

        (For the definition of the |shape example| style, see
        Section~\ref{section-libs-shapes}.)
    \end{shape}
\end{pgflibrary}


\subsubsection{Implementation: The IEC-Style Logic Gates Shape Library}

\begin{pgflibrary}{shapes.gates.logic.IEC}
    This library provides rectangular logic gate shapes. These shapes are
    suffixed with |IEC| as they are based on gates recommended by the
    International Electrotechnical Commission.

    By default each gate is drawn with a symbol, $\char`\&$ for |and| and
    |nand| gates, $\geq1$ for |or| and |nor| gates, $1$ for |not| and |buffer|
    gates, and $=1$ for |xor| and |xnor| gates. These symbols are drawn
    automatically (internally they are drawn using the ``foreground'' path),
    and are not strictly speaking part of the node contents. However, the gate
    is enlarged to make sure the symbols are within the border of the node. It
    is possible to change the symbols and their position within the node using
    the following keys:

    \begin{key}{/pgf/and gate IEC symbol=\meta{text} (initially \char`\\char\char`\`\char`\\\char`\&)}
        Set the symbol for the |and gate|. Note that if the node is filled,
        this color will be used for the symbol, making it invisible, so it will
        be necessary set \meta{text} to something like |\color{black}\char`\&|.
        Alternatively, the |logic gate IEC symbol color| key can be used to set
        the color of all symbols simultaneously.

        In \tikzname, when the |use IEC style logic gates| key has been used,
        this key can be replaced by |and gate symbol|.
    \end{key}

    \begin{key}{/pgf/nand gate IEC symbol=\meta{text} (initially \char`\\char\char`\`\char`\\\char`\&)}
        Set the symbol for the |nand gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |nand gate symbol|.
    \end{key}

    \begin{key}{/pgf/or gate IEC symbol=\meta{text} (initially \char`\$\char`\\geq1\char`\$)}
        Set the symbol for the |or gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |or gate symbol|.
    \end{key}

    \begin{key}{/pgf/nor gate IEC symbol=\meta{text} (initially \char`\$\char`\\geq1\char`\$)}
        Set the symbol for the |nor gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |nor gate symbol|.
    \end{key}

    \begin{key}{/pgf/xor gate IEC symbol=\meta{text} (initially \char`\{\char`\$=1\char`\$\char`\})}
        Set the symbol for the |xor gate|. Note the necessity for braces, as
        the symbol contains |=|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |xor gate symbol|.
    \end{key}

    \begin{key}{/pgf/xnor gate IEC symbol=\meta{text} (initially  \char`\{\char`\$=1\char`\$\char`\})}
        Set the symbol for the |xnor gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |xnor gate symbol|.
    \end{key}

    \begin{key}{/pgf/not gate IEC symbol=\meta{text} (initially 1)}
        Set the symbol for the |not gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |not gate symbol|.
    \end{key}

    \begin{key}{/pgf/buffer gate IEC symbol=\meta{text} (initially 1)}
        Set the symbol for the |buffer gate|. In \tikzname, when the
        |use IEC style logic gates| key has been used, this key can be replaced
        by |buffer gate symbol|.
    \end{key}

    \begin{key}{/pgf/logic gate IEC symbol align=\meta{align} (initially top)}
        Set the alignment of the logic gate symbol (in \tikzname, when the
        |use IEC style logic gates| key has been used, |IEC| can be omitted).
        The specification in \meta{align} is a comma separated list from |top|,
        |bottom|, |left| or |right|. The distance between the border of the
        node and the outer edge of the symbol is determined by the values of
        the |inner xsep| and |inner ysep|.
        %
\begin{codeexample}[]
\begin{tikzpicture}[minimum size=1cm, use IEC style logic gates]
    \tikzset{every node/.style={nor gate, draw}}
  \node (A) at (0,1.5) {};
  \node [logic gate symbol align={bottom, right}] (B) at (0,0) {};
  \foreach \g in {A, B}{
    \foreach \i in {1,2}
      \draw ([xshift=-0.5cm]\g.input \i) -- (\g.input \i);
    \draw (\g.output) -- ([xshift=0.5cm]\g.output);
  }
\end{tikzpicture}
\end{codeexample}
        %
    \end{key}

    \begin{key}{/pgf/logic gate IEC symbol color=\meta{color}}
        This key sets the color for all symbols simultaneously. This color can
        be overridden on a case by case basis by specifying a color when
        setting the symbol text.
    \end{key}

    The library defines the following shapes:
    %
    \begin{itemize}
        \item |and gate IEC|, two or more inputs
        \item |nand gate IEC|, two or more inputs
        \item |or gate IEC|, two or more inputs
        \item |nor gate IEC|, two or more inputs
        \item |xor gate IEC|, two inputs
        \item |xnor gate IEC|, two inputs
        \item |not gate IEC|, one input
        \item |buffer gate IEC|, one input
    \end{itemize}

    Again, we only have a look at the nand-gate in more detail:

    \begin{shape}{nand gate IEC}
        This shape is a nand gate. It supports two or more inputs. If less than
        two inputs are specified an error will result. The anchors for this
        gate with two inverted inputs are shown below. Anchor |30| is an
        example of a border anchor.
        %
\begin{codeexample}[]
\Huge
\begin{tikzpicture}
  \node[name=s,shape=nand gate IEC ,shape example, inner xsep=1cm, inner ysep=1cm,
    minimum height=6cm, nand gate IEC symbol=\color{black!30}\char`\&,
    logic gate inputs={in},
    logic gate inverted radius=0.65cm]
  {Nand Gate\vrule width1pt height2cm};
  \foreach \anchor/\placement in
    {center/above, text/above, 30/above right,
     mid/right, mid east/left, mid west/above,
     base/below, base east/below, base west/left,
     north/above, south/below, east/above, west/above,
     north east/above, south east/below, south west/below, north west/above,
     output/right, input 1/above, input 2/below}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    \end{shape}
\end{pgflibrary}


\subsection{Electrical Engineering Circuits}

\subsubsection{Overview}

An \emph{electrical engineering circuit} contains symbols like resistors or
capacitors or voltage sources and annotations like the two arrows pointing
toward an element whose behaviour is light dependent. The electrical
engineering libraries, abbreviated ee-libraries, provide such symbols and
annotations.

Just as for logical gates, there are different ways of drawing ee-symbols.
Currently, there is one main library for drawing circuits, which uses the
graphics from the International Electrotechnical Commission, but you can add
your own libs. This is why, just as for logical gates, there is a base library
and more specific libraries.

\begin{tikzlibrary}{circuits.ee}
    This library declares the ee symbols, but (mostly) does not provide the
    symbol graphics, which is left to the sublibraries. Just like the logical
    gates library, a key is defined that is normally only used internally:
    %
    \begin{key}{/tikz/circuit ee}
        This style calls the keys |circuit| (which internally calls
        |every circuit| and the following style:
        %
        \begin{stylekey}{/tikz/every circuit ee}
            Use this key to configure the appearance of logical circuits.
        \end{stylekey}
    \end{key}

    The library also declares some standard annotations and units.
\end{tikzlibrary}

As for logical circuits, to draw a circuit the first step is to include a
library containing the symbols graphics. Currently, you have to include
|circuits.ee.IEC|.

\begin{tikzlibrary}{circuit.ee.IEC}
    When this library is loaded, you can use the following style:
    %
    \begin{key}{/tikz/circuit ee IEC}
        This style calls |circuit ee| and installs the IEC-like graphics for
        the logical symbols like |resistor|.
    \end{key}
\end{tikzlibrary}

Inside the |circuit ee IEC| scope, you can now use the keys for symbols, units,
and annotations listed in the later sections. We have a more detailed look at
one of each of them, all the others work the same way.

Let us start with an example of a symbol: the resistor symbol. The other
predefined symbols are listed in Section~\ref{section-circuits-ee-symbols} and
later sections.

\begin{key}{/tikz/resistor=\opt{\meta{options}}}
    This key should be used with a |node| path command or with the |to| path
    command.

    \medskip\textbf{Using the Key with Normal Nodes.}
    When used with a node, it will cause this node to ``look like'' a resistor
    (by default, in the IEC library, this is just a simple rectangle).
    %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \node [resistor] {};
\end{codeexample}

    Unlike normal nodes, a resistor node generally should not take any text (as
    in |node [resistor] {foo}|). Instead, the labeling of resistors should be
    done using the |label|, |info| and |ohm| options.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \node [resistor,ohm=5] {};
\end{codeexample}

    The \meta{options} make no real sense when the |resistor| option is used
    with a normal node, you can just as well given them to the |node| itself.
    Thus, the following has the same effect as the above example:
    %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \node [resistor={ohm=5}] {};
\end{codeexample}

    In a circuit, you will often wish to rotate elements. For this, the options
    |point up|, |point down|, |point left| or |point right| may be especially
    useful. They are just shorthands for appropriate rotations like
    |rotate=90|.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC] {
  \node (R1) [resistor,point up,ohm=5] at (3,1) {};
  \node (R2) [resistor,ohm=10k]        at (0,0) {};
  \draw (R2) -| (R1);
}
\end{codeexample}

    \medskip\textbf{Using the Key on a To Path.}
    When the |resistor| key is used on a |to| path inside a |circuit ee IEC|,
    the |circuit handle symbol| key is called internally. This has a whole
    bunch of effects:
    %
    \begin{enumerate}
        \item The path currently being constructed is cut up to make place for
            a node.
        \item This node will be a |resistor node| that is rotated so that it
            points ``along'' the path (unless an option like |shift only| or an
            extra rotation is used to change this).
        \item The \meta{options} passed to the |resistor| key are passed on to
            the node.
        \item The \meta{options} are pre-parsed to identify a |pos| key or a
            key like |at start| or |midway|. These keys are used to determine
            where on the |to| path the node will lie.
    \end{enumerate}

    Since the \meta{options} of the |resistor| key are passed on to the
    resistor node on the path, you can use it to add labels to the node. Here
    is a simple example:
    %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \draw (0,0) to [resistor=red]        (3,0)
              to [resistor={ohm=2\mu}] (3,2);
\end{codeexample}

    You can add multiple labels to a resistor and you can have multiple
    resistors (or other elements) on a single path.

    \medskip\textbf{Inputs, Outputs, and Anchors.}
    Like the logical gates, all ee-symbols have an |input| and an |output|
    anchor. Special-purpose-nodes may have even more anchors of this type.
    Furthermore, the ee-symbols-nodes also have four standard compass direction
    anchors.

    \medskip\textbf{Changing the Appearance.}
    To configure the appearance of all |resistor|s, see
    Section~\ref{section-theming-symbols}. You can use the \meta{options} to
    locally change the appearance of a single resistor.
\end{key}

Let us now have a look at an example of a unit: the Ohm unit. The other
predefined units are listed in Section~\ref{section-circuits-units}.

\begin{key}{/tikz/ohm=\meta{value}}
    This key is used to add an |info| label to a node with a special text:
    |$\mathrm{|\meta{value}|\Omega}$|. In other words, the |ohm| key can only
    be used with the options of a node and, when used, it will cause the
    \meta{value} to be placed next to the node, followed by $\Omega$. Since the
    \meta{value} is typeset inside a |\mathrm| command, when you write |ohm=5k|
    you get $\mathrm{5k\Omega}$, |ohm=5p| yields $\mathrm{5p\Omega}$, and
    |ohm=5.6\cdot 10^{2}\mu| yields $\mathrm{5.6\cdot 10^{2}\mu\Omega}$.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC] \draw (0,0) to [resistor={ohm=5M}] (0,2);
\end{codeexample}

    Instead of |ohm| you can also use |ohm'|, which places the label on the
    other side.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC] \draw (0,0) to [resistor={ohm'=5M}] (0,2);
\end{codeexample}

    Finally, there are also keys |ohm sloped| and |ohm' sloped| for having the
    info label rotate together with the main node.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC]
  \draw (0,0) to [resistor={ohm sloped=5M}] (0,2)
        (2,0) to [resistor={ohm' sloped=6f}]  (2,2);
\end{codeexample}

    You can configure the appearance of an Ohm info label using the key
    |every ohm|.
\end{key}

Finally, let us have a look at an annotation: the |light emitting| annotation.
The other predefined units are listed in
Section~\ref{section-circuits-annotations}.

\begin{key}{/tikz/light emitting=\opt{\meta{options}}}
    Like a unit, an annotation should be given as an additional option to a
    node. It causes some drawings (in this case, two parallel lines) to be
    placed next to the node.
    %
\begin{codeexample}[]
\tikz [circuit ee IEC] \draw (0,0) to [diode=light emitting] (2,0);
\end{codeexample}

    The \meta{options} can be used for three different things:
    %
    \begin{enumerate}
        \item You can use keys like |red| to change the appearance of this
            annotation, locally.
        \item You can use keys like |<-|  or |-latex| to change the direction
            and kinds of arrows used in the annotation.
        \item You can use info labels like |ohm=5| or |info=foo| inside the
            \meta{options}. These info labels will be added to the main node
            (not to the annotation itself), but the label distance will have
            been changed to accommodate for the space taken up by the
            annotation.
            %
\begin{codeexample}[]
\tikz [circuit ee IEC]
{
  \draw (0,2) to [diode={light emitting,info=not good}] (2,2);
  \draw (0,0) to [diode={light emitting={info=better},
                         info'=also good}]  (2,0);
}
\end{codeexample}
    \end{enumerate}

    In addition to |light emitting| there is also a key called
    |light emitting'|, which simply places the annotation on the other side of
    the node.

    You can configure the appearance of annotations in three ways:
    %
    \begin{itemize}
        \item You can set the |every circuit annotation| style.
        \item You can set the |every light emitting| style.
        \item You can set the following key:
            %
            \begin{stylekey}{/tikz/annotation arrow}
                This style should set the default |>| arrow to some nice value.
            \end{stylekey}
    \end{itemize}
\end{key}

\def\eelineexample#1#2{%
  \texttt{#1}\indexkey{#1}
   &
  \tikz[baseline=-.5ex,circuit ee IEC] \draw (0,0) to [#1] (3,0);
  &
  \relax\def\temp{#2}
  \ifx\temp\empty\else
  {\tikz[baseline=-.5ex,circuit ee IEC,set #2 graphic=var #2 IEC graphic]
    \draw (0,0) to [#2] (3,0);}
  \fi \\[.2em]
}
\def\eeendexample#1#2{%
  \texttt{#1}\indexkey{#1}
   &
  \tikz[baseline=-.5ex,circuit ee IEC] \draw (0,0) to [#1={at end}] (1.5,0)(3,0);
  &
  \relax\def\temp{#2}
  \ifx\temp\empty\else
  {\tikz[baseline=-.5ex,circuit ee IEC,set #2 graphic=var #2 IEC graphic]
    \draw (0,0) to [#2={at end}] (1.5,0)(3,0);}
  \fi \\[.2em]
}
\def\unitexample#1{%
  \texttt{#1}\indexkey{#1}
  &
  \tikz [baseline,inner sep=0pt] \node[#1=1] {};\\
}
\def\annotationexample#1{%
  \texttt{#1}\indexkey{#1}
  &
  \tikz[baseline=-.5ex,circuit ee IEC]
    \draw (0,0) to [resistor={#1}] (2,0)
                to [diode   ={#1'}] (4,0);\\
}
\def\empty{}


\subsubsection{Symbols: Indicating Current Directions}
\label{section-ee-symbols}
\label{section-circuits-ee-symbols}

There \todosp{why two labels? The first doesn't seem to be used.} are two
symbols for indicating current directions. These symbols are defined directly
inside |circuit ee|.
\medskip

\noindent
\begin{tabular}{p{5cm}ll}
    \emph{Key} & \emph{Appearance}\\[.25em]
    \eelineexample{/tikz/current direction}{}
    \eelineexample{/tikz/current direction'}{}
\end{tabular}

\medskip
The examples have been produced by (in essence)
|\draw (0,0) to[|\meta{symbol name}|] (3,0);|.


\subsubsection{Symbols: Basic Elements}

The following table show basic symbols as they are depicted inside the
|circuit ee IEC| environment. To install one of alternate graphics, you have to
say |set| \meta{symbol name} |graphic=var| \meta{symbol name} |IEC graphic|.
\medskip

\noindent
\begin{tabular}{p{5cm}ll}
    \emph{Key} & \emph{Appearance}  & \emph{Alternate appearance} \\[.25em]
    \eelineexample{/tikz/resistor}{resistor}
    \eelineexample{/tikz/inductor}{inductor}
    \eelineexample{/tikz/capacitor}{}
    \eelineexample{/tikz/battery}{}
    \eelineexample{/tikz/bulb}{}
    \eelineexample{/tikz/current source}{}
    \eelineexample{/tikz/voltage source}{}
    \eeendexample{/tikz/ground}{}
\end{tabular}


\subsubsection{Symbols: Diodes}

The following table shows diodes as they are depicted inside the
|circuit ee IEC| environment.
\medskip

\noindent
\begin{tabular}{p{5cm}ll}
  \emph{Key} & \emph{Appearance}  & \emph{Alternate appearance} \\[.25em]
  \eelineexample{/tikz/diode}{diode}
  \eelineexample{/tikz/Zener diode}{Zener diode}
  \eelineexample{/tikz/Schottky diode}{Schottky diode}
  \eelineexample{/tikz/tunnel diode}{tunnel diode}
  \eelineexample{/tikz/backward diode}{backward diode}
  \eelineexample{/tikz/breakdown diode}{breakdown diode}
\end{tabular}


\subsubsection{Symbols: Contacts}

The following table shows contacts as they are depicted inside the
|circuit ee IEC| environment.
\medskip

\noindent
\begin{tabular}{p{5cm}ll}
    \emph{Key} & \emph{Appearance}  & \emph{Alternate appearance} \\[.25em]
    \eelineexample{/tikz/contact}{}
    \eelineexample{/tikz/make contact}{make contact}
    \eelineexample{/tikz/break contact}{}
\end{tabular}


\subsubsection{Units}
\label{section-circuits-units}

The |circuit.ee| library predefines the following unit keys:
\medskip

\noindent
\begin{tabular}{p{5cm}c}
    \emph{Key} & \emph{Appearance of $1$ unit} \\[.25em]
    \unitexample{/tikz/ampere}
    \unitexample{/tikz/volt}
    \unitexample{/tikz/ohm}
    \unitexample{/tikz/siemens}
    \unitexample{/tikz/henry}
    \unitexample{/tikz/farad}
    \unitexample{/tikz/coulomb}
    \unitexample{/tikz/voltampere}
    \unitexample{/tikz/watt}
    \unitexample{/tikz/hertz}
\end{tabular}


\subsubsection{Annotations}
\label{section-circuits-annotations}

The |circuit.ee.IEC| library defines the following annotations:
\medskip

\noindent
\begin{tabular}{p{5cm}ll}
    \emph{Key} & \emph{Appearance} \\[.25em]
    \annotationexample{/tikz/light emitting}
    \annotationexample{/tikz/light dependent}
    \annotationexample{/tikz/direction info}
    \annotationexample{/tikz/adjustable}
\end{tabular}
\medskip

The lines have been produced using, in essence,
%
\begin{codeexample}[code only]
\draw (0,0)  to [resistor=light emitting] (2,0)  to [diode=light emitting'] (4,0);
\end{codeexample}
%
and similarly for the other annotations.


\subsubsection{Implementation: The EE-Symbols Shape Library}

The \tikzname\ libraries depend on two shape libraries, which are included
automatically. Usually, you will not need to use these shapes directly.

\begin{pgflibrary}{shapes.gates.ee}
    This library defines basic shapes that can be used by all ee-circuit
    libraries. Currently, it defines the following shapes:
    %
    \begin{itemize}
        \item |rectangle ee|
        \item |circle ee|
        \item |direction ee|
    \end{itemize}
    %
    Additionally, the library defines the following arrow tip: The
    |direction ee| arrow tip is basically the same as a |triangle 45| arrow tip
    with rounded joins.

    \begin{tabular}{ll}
        \symarrow{direction ee}
    \end{tabular}

    However, unlike normal arrow tips, its size does \emph{not} depend on the
    current line width. Rather, it depends on the value of its arrow options,
    which should be set to the desired size. Thus, you should say something
    like |\pgfsetarrowoptions{direction ee}{5pt}| to set the size of the arrow.
\end{pgflibrary}

\begin{shape}{rectangle ee}
    This shape is completely identical to a normal |rectangle|, only there are
    two additional anchors: The |input| anchor is an alias for the |west|
    anchor, while the |output| anchor is an alias for the |east| anchor.
\end{shape}

\begin{shape}{circle ee}
    Like the |rectangle ee| shape, only for circles.
\end{shape}

\begin{shape}{direction ee}
    This shape is rather special. It is intended to be used to ``turn an arrow
    tip into a shape''. First, you should set the following key to the name of
    an arrow tip:
    %
    \begin{key}{/pgf/direction ee arrow=\meta{right arrow tip name}}
        The value of this key will be used for the arrow tip depicted in an
        |direction ee| shape.
    \end{key}
    %
    When a node of shape |direction ee| is created, several things happen:
    %
    \begin{enumerate}
        \item The size of the shape is computed according to the following
            rules: The width of the shape is set up so that the left border of
            the shape is at the left end of the arrow tip and the right border
            is at the right end of the arrow tip. These left and right ``ends''
            of the arrow are the tip end and the back end specified by the
            arrow itself (see Section~\ref{section-arrow-terminology} for
            details). You usually need not worry about this width setting.

            By comparison, the height of the arrow is given by the current
            setting of |minimum height|. Thus, this key must have been set up
            correctly to reflect the ``real'' height of the arrow tip. The
            reason is that the height of an arrow is not specified when arrows
            are declared and is, thus, not available, here.

            Possibly, the height computation will change in the future to
            reflect the real height of the arrow, so you should generally set
            up the |minimum height| to be the same as the real height.
        \item A straight line from left to right inside the shape's boundaries
            is added to the background path.
        \item The arrow tip, pointing right, is drawn before the background
            path.
    \end{enumerate}
    %
    The anchors of this shape are just the compass anchors, which lie on a
    rectangle whose width and height are the above-computed height and width.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \pgfsetarrowoptions{direction ee}{6cm}
  \node[name=s,shape=direction ee,shape example,minimum height=0.7654*6cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}[direction ee arrow=angle 45]
  \node[name=s,shape=direction ee,shape example,minimum height=1.75cm] {};
  \foreach \anchor/\placement in {north/above, south/below,
                                  output/right, input/left}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
\end{shape}


\subsubsection{Implementation: The IEC-Style EE-Symbols Shape Library}

\begin{pgflibrary}{shapes.gates.ee.IEC}
    This library defines shapes for depicting ee symbols according to the IEC
    recommendations. These shapes will typically be used in conjunction with
    the graphic mechanism detailed earlier, but you can also used them
    directly.
\end{pgflibrary}

\begin{shape}{generic circle IEC}
    This shape inherits from |circle ee|, which in turn is just a normal
    |circle| with additional |input| and |output| anchors at the left and right
    ends. However, additionally, this shape allows you to specify a path that
    should be added before the background path using the following key:
    %
    \begin{key}{/pgf/generic circle IEC/before background=\meta{code}}
        When a node of shape |generic circle IEC| is created, the current
        setting of this key is used as the ``before background path''. This
        means that after the circle's background has been
        drawn/filled/whatever, the \meta{code} is executed.

        When the \meta{code} is executed, the coordinate system will have been
        transformed in such a way that the point $(1\mathrm{pt},0\mathrm{pt})$
        lies at the right end of the circle and $(0\mathrm{pt},1\mathrm{pt})$
        lies at the top of the circle. (More precisely, these points will lie
        exactly on the middle of the radial line.)
    \end{key}
    %
    Here is an examples of how to use this shape:
    %
\begin{codeexample}[]
\tikz \node [generic circle IEC,
             /pgf/generic circle IEC/before background={
               \pgfpathmoveto{\pgfpointorigin}
               \pgfpathlineto{\pgfpoint{1pt}{0pt}}
               \pgfpathlineto{\pgfpoint{0pt}{1pt}}
               \pgfpathlineto{\pgfpoint{-0.5pt}{-0.5pt}}
               \pgfusepathqstroke
             },
             draw] {Hello world};
\end{codeexample}
    %
\end{shape}

\begin{shape}{generic diode IEC}
    This shape is used to depict diodes. The main shape is taken up by a
    ``right pointing'' triangle. The anchors are positioned on the border of a
    rectangle around the diode, see the below example. The diode's size is
    based on the current settings of |minimum width| and |minimum height|.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=generic diode IEC,shape example,minimum size=6cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}

    This shape, like the |generic circle IEC| shape, is generic in the sense
    that there is a special key that is used for the before background
    drawings:
    %
    \begin{key}{/pgf/generic diode IEC/before background=\meta{code}}
        Similarly to the |generic circle IEC| shape, when a node of shape
        |generic diode IEC| is created, the current setting of this key is used
        as the ``before background path''. When the \meta{code} is executed,
        the coordinate system will have been transformed in such a way that the
        origin is at the ``tip'' of the diode's triangle, the point
        $(0\mathrm{pt},1\mathrm{pt})$ is exactly half the diode's height above
        this origin, and the point $(1\mathrm{pt},0\mathrm{pt})$ is half the
        diode's height to the right of the origin.

        The idea is that you use this key to draw different kinds of diode
        endings.
        %
\begin{codeexample}[]
\tikz \node [minimum size=1cm,generic diode IEC,
             /pgf/generic diode IEC/before background={
               \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}}
               \pgfpathlineto{\pgfqpoint{.5pt}{-1pt}}
               \pgfpathmoveto{\pgfqpoint{0pt}{-1pt}}
               \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
               \pgfpathmoveto{\pgfqpoint{-.5pt}{1pt}}
               \pgfpathlineto{\pgfqpoint{.5pt}{1pt}}
               \pgfusepathqstroke
             },
             draw] {};
\end{codeexample}
    \end{key}
\end{shape}

\begin{shape}{breakdown diode IEC}
    This shape is used to depict a bidirectional breakdown diode. The diode's
    size is based on the current settings of |minimum width| and
    |minimum height|.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=breakdown diode IEC,shape example,minimum width=6cm,minimum height=4cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
\end{shape}

\begin{shape}{var resistor IEC}
    This shape is used to depict a variant version of a resistor. Its size is
    computed as for a rectangle (thus, its size depends things like the
    |minimum height|). Then, inside this rectangle, a background path is set up
    according to the following rule: Starting from the left end, zigzag
    segments are added to the path. Each segment consists of a line at a 45
    degree angle going up to the top of the rectangle, then going down to the
    bottom, then going up to mid height of the node. As many segments as
    possible are put inside as possible. The last segment is then connected to
    the output anchor via a straight line.

    All of this means that, in general, the shape should be much wider than
    high.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=var resistor IEC,shape example,minimum width=7cm,minimum height=1cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
\end{shape}

\begin{shape}{inductor IEC}
    This shape is used to depict an inductor, using a bumpy line. Its size is
    computed as follows: Any text and |inner sep| are ignored (and should
    normally not be given). The |minimum height| plus (twice) the |outer ysep|
    specify the distance between the |north| and |south| anchors, similarly for
    the |minimum width| plus the |outer xsep| for the |east| and |west|. The
    bumpy line is drawn starting from the lower left corner to the lower right
    corner with bumps being half-circles whose height is exactly the
    |minimum height|. The |center| of the shape is just above the |south|
    anchor, at a distance of the |outer ysep|.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=inductor IEC,shape example,minimum width=7cm,minimum height=1cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
    Just as for a |var resistor IEC|, as many bumps as possible are added and
    the last bump is connected to the output anchor via a straight line.
\end{shape}

\begin{shape}{capacitor IEC}
    This shape is based on a |rectangle ee|. However, instead of a rectangle as
    the background path, only the ``left and right lines'' that make up the
    rectangle are drawn.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=capacitor IEC,shape example,
        minimum width=2cm,minimum height=3cm,inner sep=0pt] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
\end{shape}

\begin{shape}{battery IEC}
    This shape is similar to a |capacitor IEC|, however, the right line is only
    half the height of the left line.
    %
\begin{codeexample}[]
\tikz \node[shape=battery IEC,shape example,minimum size=2cm,
            inner sep=0pt] {};
\end{codeexample}
    %
\end{shape}

\begin{shape}{ground IEC}
    This shape is similar to a |batter IEC|, only three lines of different
    heights are drawn.
    %
\begin{codeexample}[]
\tikz \node[shape=ground IEC,shape example,minimum size=2cm,
            inner sep=0pt] {};
\end{codeexample}
    %
\end{shape}

\begin{shape}{make contact IEC}
    This shape consists of a line going from the lower left corner to the upper
    right corner. The size and anchors of this shape are computed in the same
    way as for an |inductor IEC|.
    %
\begin{codeexample}[]
\begin{tikzpicture}
  \node[name=s,shape=make contact IEC,shape example,minimum width=3cm,minimum height=1cm] {};
  \foreach \anchor/\placement in
    {center/above, 30/above right,
     north/above, south/below, east/left, west/right,
     north east/above, south east/below, south west/below, north west/above,
     input/left,output/right}
     \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{codeexample}
    %
\end{shape}

\begin{shape}{var make contact IEC}
    This shape works like |make contact IEC|, only a little circle is added to
    the path at the lower left corner. The radius of this circle is one twelfth
    of the width of the node.
    %
\begin{codeexample}[]
\tikz \node[shape=var make contact IEC,shape example,
            minimum height=1cm,minimum width=3cm,inner sep=0pt] {};
\end{codeexample}
    %
\end{shape}

\begin{shape}{break contact IEC}
    This shape depicts a contact that can be broken. It works like
    |make contact IEC|.
    %
\begin{codeexample}[]
\tikz \node[shape=break contact IEC,shape example,
            minimum height=1cm,minimum width=3cm,inner sep=0pt] {};
\end{codeexample}
    %
\end{shape}