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
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
|
% % Konfiguration für Texstudio (Version > 2.9)
% !TeX program = xelatex
% !TeX TXS-program:compile = txs:///xelatex/[-8bit]
% !BIB program = biber
% !TeX spellcheck = en_US
% !TeX encoding = utf8
\documentclass[a4paper, titlepage]{article}
\usepackage{a4wide} % smaller borders
\usepackage{titling}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\def\modern{
\usepackage{fontspec}
\defaultfontfeatures{
Ligatures=TeX,
Numbers=OldStyle,
Mapping=tex-text,
SmallCapsFeatures={LetterSpace=8, Numbers=OldStyle}
}
% \setmainfont{Gentium Book Basic}
}
% do not split this line in more lines, otherwise "make git-manual" will show the wrong version
\usepackage[siunitx, RPvoltages]{circuitikz}
% Let this be the same as the chosen voltage direction for coherence
\def\chosenvoltoption{RPvoltages}
\usepackage{ifxetex,ifluatex}
\ifxetex
\modern
\else
\ifluatex
\modern
\else
% pdflatex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
% \usepackage{babel}
\fi
\fi
\def\tightlist{} % needed for latest pandoc-versions(pandoc used for including changelog)
\usepackage{microtype}
\sisetup{load=derived} % loading \siemens
\usepackage{showexpl}
%
% The following trick is used to silence showexpl a bit, so that the
% logs are readable...
%
\makeatletter
\let\SX@Info=\relax % silence showexpl a bit...
\makeatother
%
\lstset{
pos=l,
width=-99pt,
overhang=0pt,
hsep=\columnsep,
vsep=\bigskipamount,
rframe=single,
numbers=left,
numberstyle=\tiny,
numbersep=.3em,
xleftmargin=1em,
columns=flexible,
language=[LaTeX]TEX,breaklines=true,
basicstyle=\normalsize\ttfamily,tabsize=3
}
\usepackage{booktabs}
\renewcommand{\arraystretch}{1.2}
\usepackage{framed, xtab}
\usepackage{hyperref}
\hypersetup{
bookmarks=false, % show bookmarks bar?
pdftitle={CircuiTikZ \pgfcircversion\ - manual}, % title
pdfauthor={Massimo Redaelli, Stefan Lindner, Stefan Erhardt, Romano Giannetti}, % authors
pdfsubject={CircuiTikZ manual}, % subject of the document
pdfkeywords={}, % list of keywords
colorlinks=true, % false: boxed links; true: colored links
linkcolor=blue, % color of internal links
citecolor=blue, % color of links to bibliography
filecolor=blue, % color of file links
urlcolor=blue % color of external links
}
\usepackage{imakeidx}
\usepackage{textcomp}
\makeindex[title=Index of the components, intoc=true]
% Local utilities packages
\usepackage{ctikzmanutils}
\newcommand{\email}[1]{\href{mailto:#1}{#1}}
\long\def\comment#1{}
% There are a lot of boxes in the document; let's try to give TeX
% a bit of leverage... do not use parindent (which looks strange between examples)
% and add stretch between paragraph, to avoid a lot of sections and subsections
% starting at the end of the page.
\parindent=0pt
\parskip=4pt plus 6pt minus 2pt
\begin{document}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\def\TikZ{Ti\emph{k}Z}
\def\Circuitikz{Circui\TikZ}
\def\ConTeXt{Con\TeX t}
\lstset{frameround=fttt}
\lstloadlanguages{TeX}
\title{\Circuitikz \\{\large version \pgfcircversion{} (\pgfcircversiondate)}}
\author{Massimo A. Redaelli (\email{m.redaelli@gmail.com})\\
Stefan Lindner (\email{stefan.lindner@fau.de})\\
Stefan Erhardt (\email{stefan.erhardt@fau.de})\\
Romano Giannetti (\email{romano.giannetti@gmail.com})}
\date{\today}
\pretitle{\begin{center}%
\begin{circuitikz}
\draw (0,0) node[dipchip, rotate=90, num pins=40, fill=cyan!20!white](C){%
\rotatebox{-90}{\LARGE\Circuitikz}%
};
\draw (C.pin 20) -- ++(0,-8) node[ground](GND){};
\draw (C.pin 7) to[D, fill=blue] ++(0,-1) -- ++(0.5,0) to[R] ++(2,0)
coordinate(a1) to[short, -*]
node[above left, blue]{Massimo A. Redaelli}
node[below left,]{\email{m.redaelli@gmail.com}}
(a1-|GND);
\draw (C.pin 5) to[D, fill=red] ++(0,-3)-- ++(0.5,0) to[R] ++(2,0)
coordinate(a2) to[short, -*]
node[above left, blue]{Stefan Lindner}
node[below left,]{\email{stefan.lindner@fau.de}}
(a2-|GND);
\draw (C.pin 3) to[D, fill=green] ++(0,-5)-- ++(0.5,0) to[R] ++(2,0)
coordinate(a3) to[short, -*]
node[above left, blue]{Stefan Erhart}
node[below left,]{\email{stefan.erhardt@fau.de}}
(a3-|GND);
\draw (C.pin 1) to[D, fill=yellow] ++(0,-7)-- ++(0.5,0) to[R] ++(2,0)
coordinate(a4) to[short, -*]
node[above left, blue]{Romano Giannetti}
node[below left,]{\email{romano.giannetti@gmail.com}}
(a4-|GND);
\end{circuitikz}
\par\bigskip\vfill}
\posttitle{\end{center}}
\maketitle
\tableofcontents
\cleardoublepage
\section{Introduction}
\subsection{About}
\Circuitikz\ was initiated by Massimo Redaelli in 2007, who was working as a research assistant at the Polytechnic University of Milan, Italy, and needed a tool for creating exercises and exams.
After he left University in 2010 the development of \Circuitikz\ slowed down, since \LaTeX\ is mainly established in the academic world. In 2015 Stefan Lindner and Stefan Erhardt, both working as research assistants at the University of Erlangen-Nürnberg, Germany, joined the team and now maintain the project together with the initial author. In 2018 Romano Giannetti, full professor of Electronics at Comillas Pontifical University of Madrid, joined the team.
The use of \Circuitikz\ is, of course, not limited to academic teaching. The package gets widely used by engineers for typesetting electronic circuits for articles and publications all over the world.
\subsection{License}
Copyright \copyright\ 2007--2019 Massimo Redaelli. This package is author-maintained. Permission is granted to copy, distribute and/or modify this software under the terms of the \LaTeX\ Project Public License, version 1.3.1, or the GNU Public License. This software is provided ‘as is’, without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
\subsection{Loading the package}
\begin{table}[h]
\centering
\begin{tabular}{ll}\toprule
\LaTeX & \ConTeXt\footnotemark \\ \midrule
\verb!\usepackage{circuitikz}! & \verb!\usemodule[circuitikz]!\\
\bottomrule
\end{tabular}
\end{table}
\footnotetext{\ConTeXt\ support was added mostly thanks to Mojca Miklavec and Aditya Mahajan.}
\noindent \TikZ\ will be automatically loaded.
\noindent Circui\TikZ\ commands are just \TikZ\ commands, so a minimum usage example would be:
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) to[R=$R_1$] (2,0);
\end{LTXexample}
\subsection{Installing a new version of the package.}
The stable version of the package should come with your \LaTeX\ distribution. Downloading the files from CTAN and installing them locally is, unfortunately, a distribution-dependent task and sometime not so trivial. If you search for \texttt{local texmf tree} and the name of your distribution on \url{https://tex.stackexchange.com/} you will find a lot of hints.
Anyway, the easiest way of using whichever version of \Circuitikz\ is to point to the github page \url{https://circuitikz.github.io/circuitikz/} of the project, and download the version you want. You will download a simple (biggish) file, called \texttt{circuitikz.sty}.
Now you can just put this file in your local \texttt{texmf} tree, if you have one, or simply adding it into the same directory where your main file resides, and then use
\begin{verbatim}
\usepackage[...options...]{circuitikzgit}
\end{verbatim}
instead of \texttt{circuitikz}. This is also advantageous for ``future resilience''; the authors try hard not to break backward compatibility with new versions, but sometime things happen.
\subsection{Requirements}
\begin{itemize}
\item \texttt{tikz}, version $\ge 3$;
\item \texttt{xstring}, not older than 2009/03/13;
\item \texttt{siunitx}, if using \texttt{siunitx} option.
\end{itemize}
\subsection{Incompatible packages}
\TikZ's own \texttt{circuit} library, which is based on \Circuitikz, (re?)defines several styles used by this library. In order to have them work together you can use the \texttt{compatibility} package option, which basically prefixes the names of all \Circuitikz\ \texttt{to[]} styles with an asterisk.
So, if loaded with said option, one must write \verb!(0,0) to[*R] (2,0)! and, for transistors on a path, \verb!(0,0) to[*Tnmos] (2,0)!, and so on (but \verb!(0,0) node[nmos] {}!). See example at page~\pageref{ex:compatibility}.
\subsection{Known bugs and limitation}\label{sec:bugs}
\Circuitikz{} will \textbf{not work} correctly with global (in the main \texttt{circuitikz} environment, or in \texttt{scope} environments) \emph{negative} scale parameters (\texttt{scale}, \texttt{xscale} or \texttt{yscale}), unless \texttt{transform shape} is also used, and even in this cases the behavior is not guaranteed.
Neither it will work with angle-changing scaling (when \texttt{xscale} is different form \texttt{yscale}) and with the global \texttt{rotate} parameter.
Correcting this will need a big rewrite of the path routines, and although the authors are thinking about solving it, don't hold your breath; it will need changing a lot of interwoven code (labels, voltages, currents and so on). Contributions and help would be highly appreciated.
This same issue create a lot of problem of compatibility between \Circuitikz{} and the new \texttt{pic} Ti\emph{k}Z feature, so basically don't put components into \texttt{pic}s.
\subsection{Incompabilities between version}
Here, we will provide a list of incompabilitys between different version of circuitikz. We will try to hold this list short, but sometimes it is easier to break with old syntax than including a lot of switches and compatibility layers.
You can check the used version at your local installation using the macro \verb!\pgfcircversion{}!.
\begin{itemize}
\item After v0.9.4: added the concept of styling of circuits. It should be backward compatible, but it's a big change, so be ready to use the \texttt{0.9.3} snapshot (see below for details).
\item After v0.9.0: the parameters \texttt{tripoles/american or port/aaa}, \texttt{...bbb}, \texttt{...ccc} and \texttt{...ddd} are no longer used and are silently ignored; the same stands for \texttt{nor}, \texttt{xor}, and \texttt{xnor} ports.
\item After v0.9.0: voltage and current directions/sign (plus and minus signs in case of \texttt{american voltages} and arrows in case of \texttt{european voltages} have been rationalized with a couple of new options (see details in section~\ref{curr-and-volt}. The default case is still the same as v0.8.3.
\item Since v0.8.2: voltage and current label directions(v<= / i<=) do NOT change the orientation of the drawn source shape anymore. Use the "invert" option to rotate the shape of the source. Furthermore, from this version on, the current label(i=) at current sources can be used independent of the regular label(l=).
\item Since v0.7?: The label behaviour at mirrored bipoles has changes, this fixes the voltage drawing, but perhaps you have to adjust your label positions.
\item Since v0.5.1: The parts pfet, pigfete, pigfetebulk and pigfetd are now mirrored by default. Please adjust your yscale-option to correct this.
\item Since v0.5: New voltage counting direction, here exists an option to use the old behaviour
\end{itemize}
If you have older projects that show compatibility problems, you have two options:
\begin{itemize}
\item you can use an older version locally using the git-version and picking the correct commit from the repository (branch gh-pages) or the main GitHub site directly;
\item if you are using \LaTeX, the distribution has embedded several important old versions: \texttt{0.4}, \texttt{0.6}, \texttt{0.7}, \texttt{0.8.3} and \texttt{0.9.3}. To switch to use them, you simply change your \verb|\usepackage| invocation like
\begin{lstlisting}
\usepackage[]{circuitik-0.8.3} % or circuitikz-0.4, 0.6...
\end{lstlisting}
You have to take care of the options that may have changed between versions;
\item if you are using \ConTeXt, only versions \texttt{0.8.3} and \texttt{0.9.3} are packaged for now; if can use it with
\begin{lstlisting}
\usemodule[circuitik-0.8.3]
\end{lstlisting}
\end{itemize}
\subsection{Feedback}
The easiest way to contact the authors is via the official Github repository: \url{https://github.com/circuitikz/circuitikz/issues}. For general help question, a lot of nice people is quite active on \url{https://tex.stackexchange.com/questions/tagged/circuitikz} --- be sure to read the help pages for the site and ask!
\subsection{Package options}
\label{sec:package-options}
\noindent Circuit people are very opinionated about their symbols. In order to meet the individual gusto you can set a bunch of package options. The standard options are what the authors like, for example you get this:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
(2,2) to[V<=84<\volt>] (0,2)
-- (0,0);
\end{circuitikz}
\end{LTXexample}
Feel free to load the package with your own cultural options:
\begin{center}
\begin{tabular}{ll}\toprule
\LaTeX & \ConTeXt \\ \midrule
\verb!\usepackage[american]{circuitikz}! & \verb!\usemodule[circuitikz][american]!\\
\bottomrule
\end{tabular}
\end{center}
\begin{LTXexample}[varwidth=true,linerange={1-1,3-6}]
\begin{circuitikz}
[circuitikz/voltage=american, circuitikz/resistor=american] % line not printed
\draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
(2,2) to[V<=84<\volt>] (0,2)
-- (0,0);
\end{circuitikz}
\end{LTXexample}
\medskip{}
\noindent Here is the list of all the options:
{\sloppy % for the big lists of \texttt here
\begin{itemize}
\item \texttt{europeanvoltages}: uses arrows to define voltages, and uses european-style voltage sources;
\item \texttt{straightvoltages}: uses arrows to define voltages, and and uses straight voltage arrows;
\item \texttt{americanvoltages}: uses $-$ and $+$ to define voltages, and uses american-style voltage sources;
\item \texttt{europeancurrents}: uses european-style current sources;
\item \texttt{americancurrents}: uses american-style current sources;
\item \texttt{europeanresistors}: uses rectangular empty shape for resistors, as per european standards;
\item \texttt{americanresistors}: uses zig-zag shape for resistors, as per american standards;
\item \texttt{europeaninductors}: uses rectangular filled shape for inductors, as per european standards;
\item \texttt{americaninductors}: uses "4-bumps" shape for inductors, as per american standards;
\item \texttt{cuteinductors}: uses my personal favorite, "pig-tailed" shape for inductors;
\item \texttt{americanports}: uses triangular logic ports, as per american standards;
\item \texttt{europeanports}: uses rectangular logic ports, as per european standards;
\item \texttt{americangfsurgearrester}: uses round gas filled surge arresters, as per american standards;
\item \texttt{europeangfsurgearrester}: uses rectangular gas filled surge arresters, as per european standards;
\item \texttt{european}: equivalent to \texttt{europeancurrents}, \texttt{europeanvoltages}, \texttt{europeanresistors}, \texttt{europeaninductors}, \texttt{europeanports}, \texttt{europeangfsurgearrester};
\item \texttt{american}: equivalent to \texttt{americancurrents}, \texttt{americanvoltages}, \texttt{americanresistors}, \texttt{americaninductors}, \texttt{americanports}, \texttt{americangfsurgearrester};
\item \texttt{siunitx}: integrates with \texttt{SIunitx} package. If labels, currents or voltages are of the form \verb!#1<#2>! then what is shown is actually \verb!\SI{#1}{#2}!;
\item \texttt{nosiunitx}: labels are not interpreted as above;
\item \texttt{fulldiode}: the various diodes are drawn \emph{and} filled by default, i.e. when using styles such as \texttt{diode}, \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D-}, \ldots
\item \texttt{strokediode}: the various diodes are drawn \emph{and} stroke by default, i.e. when using styles such as \texttt{diode}, \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D*}, \ldots
\item \texttt{emptydiode}: the various diodes are drawn \emph{but not} filled by default, i.e. when using styles such as \texttt{D}, \texttt{sD}, \ldots Other diode styles can always be forced with e.g. \texttt{Do}, \texttt{D-}, \ldots
\item \texttt{arrowmos}: pmos and nmos have arrows analogous to those of pnp and npn transistors;
\item \texttt{noarrowmos}: pmos and nmos do not have arrows analogous to those of pnp and npn transistors;
\item \texttt{fetbodydiode}: draw the body diode of a FET;
\item \texttt{nofetbodydiode}: do not draw the body diode of a FET;
\item \texttt{fetsolderdot}: draw solderdot at bulk-source junction of some transistors;
\item \texttt{nofetsolderdot}: do not draw solderdot at bulk-source junction of some transistors;
\item \texttt{emptypmoscircle}: the circle at the gate of a pmos transistor gets not filled;
\item \texttt{lazymos}: draws lazy nmos and pmos transistors. Chip designers with huge circuits prefer this notation;
\item \texttt{straightlabels}: labels on bipoles are always printed straight up, i.e.~with horizontal baseline;
\item \texttt{rotatelabels}: labels on bipoles are always printed aligned along the bipole;
\item \texttt{smartlabels}: labels on bipoles are rotated along the bipoles, unless the rotation is very close to multiples of 90°;
\item \texttt{compatibility}: makes it possibile to load \Circuitikz\ and \TikZ\ circuit library together.
\item Voltage directions: until v0.8.3, there was an error in the coherence between american and european voltages styles (see section~\ref{curr-and-volt}) for the batteries. This has been fixed, but to guarantee backward compatibility and to avoid nasty surprises, the fix is available with new options:
\begin{itemize}
\item \texttt{oldvoltagedirection}: Use old way of voltage direction having a difference between european and american direction, with wrong default labelling for batteries;
\item \texttt{nooldvoltagedirection}: The standard from 0.5 onward, utilize the (German?) standard of voltage arrows in the direction of electric fields (without fixing batteries);
\item \texttt{RPvoltages} (meaning Rising Potential voltages): the arrow is in direction of rising potential, like in \texttt{oldvoltagedirection}, but batteries and current sources are fixed to follow the passive/active standard;
\item \texttt{EFvoltages} (meaning Electric Field voltages): the arrow is in direction of the electric field, like in \texttt{nooldvoltagedirection}, but batteries are fixed;
\end{itemize}
If none of these option are given, the package will default to \texttt{nooldvoltagedirection}, but will give a warning. The behavior is also selectable circuit by circuit with the \texttt{voltage dir} style.
\item \texttt{betterproportions}\footnote{May change in the future!}: nicer proportions of transistors in comparision to resistors;
\end{itemize}
The old options in the singular (like \texttt{american voltage}) are still available for compatibility, but are discouraged.
\medskip
Loading the package with no options is equivalent to the following options:
\texttt{[nofetsolderdot, europeancurrents, europeanvoltages, americanports,
americanresistors, cuteinductors, europeangfsurgearrester, nosiunitx, noarrowmos,
smartlabels, nocompatibility]}.
\medskip
In \ConTeXt\ the options are similarly specified: \texttt{current= european|american}, \texttt{voltage= european|american}, \texttt{resistor= american|european}, \texttt{inductor= cute|american|european}, \texttt{logic= american|european}, \texttt{siunitx= true|false}, \texttt{arrowmos= false|true}.
} %\stop the \sloppy processing
\section{Tutorials}
To draw a circuit, you have to load the \texttt{circuitikz} package; this can be done with
\begin{lstlisting}
\usepackage[siunitx, RPvoltages]{circuitikz}
\end{lstlisting}
somewhere in your document preamble. It will load automatically the needed packages if not already done before.
\subsection{Getting started with \Circuitikz: a current shunt}
Let's say we want to prepare a circuit to teach how a current shunt works; the idea is to draw a current generator, a couple of resistors in parallel, and the indication of currents and voltages for the discussion.
A circuit in \Circuitikz is drawn into a \texttt{circuitikz} environment (which is really an alias for \texttt{tikzpicture}). In this first example we will use absolute coordinates.
The electrical components can be divided in two main categories: the one that are bipoles and are placed along a path (also known as \texttt{to}-style component, for their usage), and components that are nodes and can have any number of poles or connections.
Let's start with the first type of component, and build a basic mesh:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[]
\draw (0,0) to[isource] (0,3) -- (2,3)
to[R] (2,0) -- (0,0);
\end{circuitikz}
\end{LTXexample}
The symbol for the current source can surprise somebody; this is actually the european-style symbol, and the type of symbol chosen reflects the default options of the package (see section~\ref{sec:package-options}). Let's change the style for now (the author of the tutorial, Romano, is European - but he has always used American-style circuits, so \dots); and while we're at it, let's add the other branch and some labels.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[isource, l=$I_0$] (0,3) -- (2,3)
to[R=$R_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3) to[R=$R_2$]
(4,0) -- (2,0);
\end{circuitikz}
\end{LTXexample}
You can use a single path or multiple path when drawing your circuit, it's just a question of style (but be aware that closing path could be non-trivial, see section~\ref{sec:line-joins}), and you can use standard \TikZ\ lines (\verb|--|, \verb+|-+ or similar) for the wires. Nonetheless, sometime using the \Circuitikz\ specific \texttt{short} component for the wires can be useful, because then we can add labels and nodes at it, like for example in the following circuit.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[isource, l=$I_0$] (0,3)
to[short, -*, i=$I_0$] (2,3)
to[R=$R_1$, i=$i_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3)
to[R=$R_2$, i=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
\end{LTXexample}
One of the problems with this circuit is that we would like to have the current in a different position, such as for example on the upper side of the resistors, so that Kirchoff's Current Law at the node is better shown to students. No problem; as you can see in section~\ref{curr-and-volt} you can use the position specifier \verb|<>^_}| after the key \texttt{i}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[isource, l=$I_0$] (0,3)
to[short, -*, i=$I_0$] (2,3)
to[R=$R_1$, i>_=$i_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3)
to[R=$R_2$, i>_=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
\end{LTXexample}
Finally, we would like to add voltages indication for carrying out the current formulas; as the default position of the voltage signs seems a bit cramped to me, I am adding the \texttt{voltage shift} parameter to make a bit more space for it\dots
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american, voltage shift=0.5]
\draw (0,0) to[isource, l=$I_0$, v=$V_0$] (0,3)
to[short, -*, i=$I_0$] (2,3)
to[R=$R_1$, i>_=$i_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3)
to[R=$R_2$, i>_=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
\end{LTXexample}
\emph{Et voilá!}. Remember that this is still \LaTeX, which means that you have done a description of your circuit, which is, in a lot of way, independent of the visualization of it. If you ever have to adapt the circuit to, say, a journal that force European style and flows instead of currents, you just change a couple of things and you have what seems a completely different diagram:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[european, voltage shift=0.5]
\draw (0,0) to[isourceC, l=$I_0$, v=$V_0$] (0,3)
to[short, -*, f=$I_0$] (2,3)
to[R=$R_1$, f>_=$i_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3)
to[R=$R_2$, f>_=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
\end{LTXexample}
And finally, this is still \TikZ, so that you can freely mix other graphics element to the circuit.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american, voltage shift=0.5]
\draw (0,0) to[isource, l=$I_0$, v=$V_0$] (0,3)
to[short, -*, f=$I_0$] (2,3)
to[R=$R_1$, f>_=$i_1$] (2,0) -- (0,0);
\draw (2,3) -- (4,3)
to[R=$R_2$, f>_=$i_2$]
(4,0) to[short, -*] (2,0);
\draw[red, thick] (1.5,2.5) rectangle (4.5,3.5)
node[pos=0.5, above]{KCL};
\end{circuitikz}
\end{LTXexample}
\subsection{A more complex tutorial: circuits, Romano style.}
\begingroup % do not propagate to the rest of the manual
The idea is to draw a two-stage amplifier for a lesson, or exercise, on the different qualities of BJT and MOSFET transistors.
Notice that this is a more ``personal'' tutorial, showing a way to draw circuits that is, in the author's opinion, highly reusable and easy to do.
The idea is using relative coordinates and named nodes as much as possible, so that changes in the circuit are easily done by changing keys numbers of position, and crucially, each block is reusable in other diagrams.
First of all, let's define a handy function to show the position of nodes:
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]45:#1}](#1){}}
\begin{lstlisting}
\def\coord(#1){coordinate(#1)}
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]45:#1}](#1){}}
\end{lstlisting}
The idea is that you can use \verb|\coord()| instead of \verb|coordinate()| in paths, and that will draw sort of \emph{markers} showing them. For example:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\draw (0,0) node[npn](Q){};
\path (Q.center) \coord(center)
(Q.B) \coord(B) (Q.C) \coord(C)
(Q.E) \coord(E);
\end{circuitikz}
\end{LTXexample}
After the circuit is drawn, simply commenting out the second definition of \verb|\coord| will hide all the markers.
So let's start with the first stage transistor; given that my preferred way of drawing a MOSFET is with arrows, I'll start with the command \verb|\ctikzset{tripoles/mos style/arrows}|:
\ctikzset{tripoles/mos style/arrows}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\ctikzset{tripoles/mos style/arrows}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\draw (0,0) node[nmos](Q1){};
\draw (Q1.center) node[right]{\killdepth{Q1}};
\end{circuitikz}
\end{LTXexample}
Another thing I like to modify with respect to the standard is the position of the arrows in transistors, which are normally in the middle the symbol. Using the following setting (see section~\ref{sec:styling-transistors}) will move the arrows to the start or end of the corresponding pin.
\ctikzset{transistors/arrow pos=end}
\begin{lstlisting}
\ctikzset{transistors/arrow pos=end}
\end{lstlisting}
The tricky thing about \verb|\killdepth{}| macro is finnicky details; I do not like the standard position of labels on transistors (which is near the collector/drain) so I plot the label at the right of the \texttt{center} anchor. Without the \verb|\killdepth| macro, the labels of different transistor will be adjusted so that the center of the box is at the \texttt{center} anchor, and as an effect, labels with descenders (like Q) will have a different baseline than labels without. You can see this here (it's really subtle):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\draw (0,0) node[nmos](Q1){} ++(2,0) node[nmos](M1){};
\draw (Q1.center) node[right]{q1};
\draw (M1.center) node[right]{m1};
\draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
\draw (0,-2)node[nmos](Q1){} ++(2,0) node[nmos](M1){};
\draw (Q1.center) node[right]{\killdepth{q1}};
\draw (M1.center) node[right]{\killdepth{m1}};
\draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
\end{circuitikz}
\end{LTXexample}
We will start connecting the first transistor with the power supply with a couple of resistors. Notice that I am naming the nodes \texttt{GND}, \texttt{VCC} and \texttt{VEE}, so that I can use the coordinates to have all the supply rails at the same vertical position (more on this later).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\draw (0,0) node[nmos,](Q1){};
\draw (Q1.center) node[right]{\killdepth{Q1}};
\draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3)
node[vee](VEE){$V_{EE}=\SI{-10}{V}$};
\draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3)
node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
\draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
\path (GND) \coord(GND) (VCC) \coord(VCC)
(VEE) \coord(VEE);
\end{circuitikz}
\end{LTXexample}
After that, let's add the input part. I will use a named node here, to refer to it to add the input source. Notice how the ground node is positioned: the coordinate \texttt{(in |- GND)} is the point with the horizontal coordinate of \texttt{(in)} and the horizontal one of \texttt{(GND)}, lining it up with the ground of the capacitor $C_1$.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american, scale=0.7]
\draw (0,0) node[nmos,](Q1){};
\draw (Q1.center) node[right]
{\killdepth{Q1}};
\draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3)
node[vee](VEE){$V_{EE}=\SI{-10}{V}$};
\draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3)
node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
\draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
\draw (Q1.G) to[short] ++(-1,0)
\coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}]
(in |- GND) node[ground]{};
\draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
\end{circuitikz}
\end{LTXexample}
Notice that the only absolute coordinate here is the first one, \texttt{(0,0)}; so the elements are connected with relative movements and can be moved by just changing one number (for example, changing the \verb| to[C=$C_1$] ++(0,-1.5) | will move \emph{all} the grounds down).
This is the final circuit, with the nodes still marked:
\begin{lstlisting}
\tikzset{blockdef/.style={%
{Straight Barb[harpoon, reversed, right, length=0.2cm]}-{Straight Barb[harpoon, reversed, left, length=0.2cm]},
blue, %densely dotted,
}}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\def\coord(#1){coordinate(#1)}
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]45:#1}](#1){}}
\begin{circuitikz}[american, ]
\draw (0,0) node[nmos,](Q1){};
\draw (Q1.center) node[right]{\killdepth{Q1}};
\draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
\draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
\draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
\draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
\draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
\draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
%
\path (vo1) -- ++(3,0) \coord(bjt);
%
\draw (bjt) node[npn, ](Q2){};
\draw (Q2.center) node[right]{\killdepth{Q2}};
\draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
\draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
\draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
\draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
%
\path (vo2) ++(1.5,0) \coord(load);
\draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
\draw [densely dashed] (vo2) -- (load);
%
\draw [densely dashed] (vo1) -- (vi2);
%
\draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 1} (vo1|- tmp);
\draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 2} (vo2|- tmp);
\end{circuitikz}
\end{lstlisting}
\tikzset{blockdef/.style={%
{Straight Barb[harpoon, reversed, right, length=0.2cm]}-{Straight Barb[harpoon, reversed, left, length=0.2cm]},
blue, %densely dotted,
}}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\def\coord(#1){coordinate(#1)}
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]45:#1}](#1){}}
\begin{circuitikz}[american, ]
\draw (0,0) node[nmos,](Q1){};
\draw (Q1.center) node[right]{\killdepth{Q1}};
\draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
\draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
\draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
\draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
\draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
\draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
%
\path (vo1) -- ++(3,0) \coord(bjt);
%
\draw (bjt) node[npn, ](Q2){};
\draw (Q2.center) node[right]{\killdepth{Q2}};
\draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
\draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
\draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
\draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
%
\path (vo2) ++(1.5,0) \coord(load);
\draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
\draw [densely dashed] (vo2) -- (load);
%
\draw [densely dashed] (vo1) -- (vi2);
%
\draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 1} (vo1|- tmp);
\draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 2} (vo2|- tmp);
\end{circuitikz}
Finally, if you like a more compact drawing, you can add the options (for example):
\begin{lstlisting}
\begin{circuitikz}[american, scale=0.8] % this will scale only the coordinates
\ctikzset{resistors/scale=0.7, capacitors/scale=0.6}
...
\end{circuitikz}
\end{lstlisting}
and you will obtain the following diagram with the exact same code (I just removed the second \verb|\coord| definition to hide the coordinates markings).
\ctikzset{resistors/scale=0.7, capacitors/scale=0.6}
\def\coord(#1){coordinate(#1)}
\begin{circuitikz}[american, scale=0.8]
\draw (0,0) node[nmos,](Q1){};
\draw (Q1.center) node[right]{\killdepth{Q1}};
\draw (Q1.S) to[R, l2^=$R_S$ and \SI{5}{k\ohm}] ++(0,-3) node[vee](VEE){$V_{EE}=\SI{-10}{V}$}; %define VEE level
\draw (Q1.S) to[short] ++(2,0) to[C=$C_1$] ++(0,-1.5) node[ground](GND){};
\draw (Q1.G) to[short] ++(-1,0) \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}] (in |- GND) node[ground]{};
\draw (in) to[C, l_=$C_2$,*-o] ++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
\draw (Q1.D) to[R, l2_=$R_D$ and \SI{10}{k\ohm}] ++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
\draw (Q1.D) to[short, -o] ++(1,0) node[right](vo1){$v_{o1}$};
%
\path (vo1) -- ++(3,0) \coord(bjt);
%
\draw (bjt) node[npn, ](Q2){};
\draw (Q2.center) node[right]{\killdepth{Q2}};
\draw (Q2.B) to[short, -o] ++(-0.5,0) node[left](vi2){$v_{12}$};
\draw (Q2.E) to[R,l2^=$R_E$ and \SI{9.3}{k\ohm}] (Q2.E |- VEE) node[vee]{};
\draw (Q2.E) to[short, -o] ++(1,0) node[right](vo2){$v_{o2}$};
\draw (Q2.C) to[short] (Q2.C |- VCC) node[vcc]{};
%
\path (vo2) ++(1.5,0) \coord(load);
\draw (load) to[C=$C_3$] ++(1,0) \coord(tmp) to[R=$R_L$] (tmp |- GND) node[ground]{};
\draw [densely dashed] (vo2) -- (load);
%
\draw [densely dashed] (vo1) -- (vi2);
%
\draw [blockdef](vi1|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 1} (vo1|- tmp);
\draw [blockdef] (vi2|-VEE) ++(0,-2) \coord(tmp)
-- node[midway, fill=white]{bloque 2} (vo2|- tmp);
\end{circuitikz}
\endgroup
\section{The components}
Components in \Circuitikz{} come in two forms: path-style, to be used in \texttt{to} path specifications, and node-style, which will be instantiated by a \texttt{node} specification.
\subsection{Path-style components}
The path-style components are used as shown below:
\begin{lstlisting}
\begin{circuitikz}
\draw (0,0) to[#1=#2, #options] (2,0);
\end{circuitikz}
\end{lstlisting}
where \verb|#1| is the name of the component, \verb|#2| is an (optional) label, and \verb|options| are optional labels, annotations, style specifier that will be explained in the rest of the manual.
Transistors and some other node-style components can also be placed using the syntax for bipoles. See section~\ref{sec:transasbip}.
Most path-style components can be used as a node-style components; to access them, you add a \texttt{shape} to the main name of component (for example, \texttt{diodeshape}). Such a ``node name'' is specified in the description of each component.
\subsubsection{Anchors}
Normally, path-style components do not need anchors, although they have them just in case you need them. You have the basic ``geographical'' anchors (bipoles are defined horizontally and then rotated as needed):
\begin{center}
\begin{circuitikz}[
]
\draw (0,0) to[resistor, name=R] ++(2,0);
\path (R.center) \showcoord(center)<-90:0.3>;
\path (R.left) \showcoord(left)<135:0.3>;
\path (R.right) \showcoord(right)<45:0.3>;
\draw (5,0) to[resistor, name=R] ++(2,0);
\foreach \n/\a/\d in {north/90/0.3, north east/45/0.3, east/0/0.5,
south east/-45/0.3, south/-90/0.3, south west/-135/0.3,
west/180/0.5, north west/135/0.3}
\path (R.\n) \showcoord(\n)<\a:\d>;
\draw (10,-1) to[resistor, name=R] ++(0,2);
\foreach \n/\a/\d in {n/135/0.3, e/45/0.3,
s/-45/0.3, w/-135/0.3}
\path (R.\n) \showcoord(\n)<\a:\d>;
\end{circuitikz}
\end{center}
In the case of bipoles, also shortened geographical anchors exists. In the description, it will be shown when a bipole has additional anchors. To use the anchors, just give a name to the bipole element.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[potentiometer, name=P, mirror] ++(0,2);
\draw (P.wiper) to[L] ++(2,0);
\end{circuitikz}
\end{LTXexample}
Alternatively, that you can use the shape form, and then use the \texttt{left} and \texttt{right} anchors to do your connections.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[potentiometershape, rotate=-90](P){};
\draw (P.wiper) to[L] ++(2,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{Customization}
\label{sec:components-size}
Pretty much all Circui\TikZ\ relies heavily on \texttt{pgfkeys} for value handling and configuration. Indeed, at the beginning of \texttt{circuitikz.sty} and in the file \texttt{pfgcirc.define.tex} a series of key definitions can be found that modify all the graphical characteristics of the package.
All can be varied using the \verb!\ctikzset! command, anywhere in the code.
Note that the details of the parameters that are not described in the manual can change in the future, so be ready to use a fixed version of the package (the ones with the specific number, like \verb|circuitikz-0.9.3|) if you dig into them.
\paragraph{Components size}\label{sec:pgfcircRlen}
Perhaps the most important parameter is \texttt{bipoles/length} (default \SI{1.4}{cm}), which
can be interpreted as the length of a resistor (including reasonable connections): all other lengths are relative to this value. For instance:
\begin{LTXexample}[pos=t,varwidth=true]
\ctikzset{bipoles/length=1.4cm}
\begin{circuitikz}[scale=1.2]\draw
(0,0) node[anchor=east] {B}
to[short, o-*] (1,0)
to[R=20<\ohm>, *-*] (1,2)
to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
to[cI=$\frac{\si{\siemens}}{5} v_x$, *-*] (4,0) -- (3,0)
to[R=5<\ohm>, *-*] (3,2)
(3,0) -- (1,0)
(1,2) to[short, -o] (0,2) node[anchor=east]{A}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\ctikzset{bipoles/length=.8cm}
\begin{circuitikz}[scale=1.2]\draw
(0,0) node[anchor=east] {B}
to[short, o-*] (1,0)
to[R=20<\ohm>, *-*] (1,2)
to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
to[cI=$\frac{\siemens}{5} v_x$, *-*] (4,0) -- (3,0)
to[R=5<\ohm>, *-*] (3,2)
(3,0) -- (1,0)
(1,2) to[short, -o] (0,2) node[anchor=east]{A}
;\end{circuitikz}
\end{LTXexample}
The changes on \texttt{bipoles/length} should, however, be globally applied to every path, because they affect every element --- including the poles. So you can have artifacts like these:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[
bigR/.style={R, bipoles/length=3cm}
]
\draw (0,3) to [bigR, o-o] ++(4,0);
\draw (0,1.5) to [bigR, o-o] ++(4,0)
to[R, o-o] ++(2,0); % will fail here
\draw (0,0) to [R, o-o] ++(4,0);
\end{circuitikz}
\end{LTXexample}
Several groups of components, on the other hand, have a special \texttt{scale} parameter that can be used safely in this case (starting with 0.9.4 --- more groups of components will be added going forward); the key to use will be explained in the specific description of the components. For example, in the case of resistors you have \texttt{resistors/scale} available:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[
bigR/.style={R, resistors/scale=1.8}
]
\draw (0,3) to [bigR, o-o] ++(4,0);
\draw (0,1.5) to [bigR, o-o] ++(4,0)
to[R, o-o] ++(2,0); % ok now
\draw (0,0) to [R, o-o] ++(4,0);
\end{circuitikz}
\end{LTXexample}
\paragraph{Thickness of the lines}\label{sec:legacy-thickness} (globally)
The best way to alter the thickness of components is using styling, see section~\ref{sec:styling-thickness}. Alternatively, you can use ``legacy'' classes like \texttt{bipole}, \texttt{tripoles} and so on ---
for example changing the parameter \texttt{bipoles/thickness} (default 2). The number is relative to the thickness of the normal lines leading to the component.
\begin{LTXexample}[varwidth=true]
\ctikzset{bipoles/thickness=1}
\tikz \draw (0,0) to[C=1<\farad>] (2,0); \par
\ctikzset{bipoles/thickness=4}
\tikz \draw (0,0) to[C=1<\farad>] (2,0);
\end{LTXexample}
\paragraph{Shape of the components} (on a per-component-class basis)
The shape of the components are adjustable with a lot of parameters; in this manual we will comment the main ones, but you can look into the source files specified above to find more.
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) to[R=1<\ohm>] (2,0); \par
\ctikzset{bipoles/resistor/height=.6}
\tikz \draw (0,0) to[R=1<\ohm>] (2,0);
\end{LTXexample}
It is recommended to use the styling parameters to change the shapes; they are not so fine grained (for example, you can change the width of resistor, not the height at the moment), but they are more stable and coherent across your circuit.
\subsubsection{Descriptions}
The typical entry in the component list will be like this:
\begin{groupdesc}
\circuitdescbip{resistor}{resistor, american style}{R, american resistor}
\circuitdescbip[potentiometer]{pR}{potentiometer, american style}{pR, american potentiometer}( wiper/0/0.3 )
\end{groupdesc}
where you have all the needed information about the bipole, with also no-standard anchors. If the component can be filled it will be specified in the description. In addition, as an example, the component shown will be filled with the option \texttt{fill=cyan!30!white}:
\begin{groupdesc}
\circuitdescbip*{ammeter}{Ammeter}{}
\end{groupdesc}
The \emph{Class} of the component (see section~\ref{sec:styling}) is printed at the end of the description.
\subsection{Node-style components}
Node-style components (monopoles, multipoles) can be drawn at a specified point with this syntax, where \verb!#1! is the name of the component:
\begin{lstlisting}
\begin{circuitikz}
\draw (0,0) node[#1,#2] (#3) {#4};
\end{circuitikz}
\end{lstlisting}
\noindent
Explanation of the parameters:\\
\texttt{\#1}: component name\footnote{For using bipoles as nodes, the name of the node is \texttt{\#1shape}.} (mandatory)\\
\texttt{\#2}: list of comma separated options (optional)\\
\texttt{\#3}: name of an anchor (optional)\\
\texttt{\#4}: text written to the text anchor of the component (optional)\\
Most path-style components can be used as a node-style components; to access them, you add a \texttt{shape} to the main name of component (for example, \texttt{diodeshape}). Such a ``node name'' is specified in the description of each component.
\begin{framed}
\noindent \textbf{Notice:} Nodes must have curly brackets at the end, even when empty. An optional anchor (\texttt{\#3}) can be defined within round brackets to be addressed again later on. And please don't forget the semicolon to terminate the \texttt{\textbackslash draw} command.
\end{framed}
\begin{framed}
\noindent\textbf{Also notice:} If using the \verb!\tikzexternalize! feature, as of Ti\emph{k}z 2.1 all pictures must end with \verb!\end{tikzpicture}!. Thus you \emph{cannot} use the \verb!circuitikz! environment.
\noindent Which is ok: just use the environment \verb!tikzpicture!: everything will work there just fine.
\end{framed}
\subsubsection{Mirroring and flipping}
Mirroring and flipping of node components is obtained by using the \TikZ\ keys \texttt{xscale} and \texttt{yscale}. Notice that this parameters affect also text labels, so they need to be un-scaled by hand.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,3) node[op amp]{OA1};
\draw (3,3) node[op amp, xscale=-1]{OA2};
\draw (0,0) node[op amp]{OA3};
\draw (3,0) node[op amp, xscale=-1]{%
\scalebox{-1}[1]{OA4}};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Anchors}
Node components anchors are variable across the various kind of components, so they will described better after each category is presented in the manual.
\subsubsection{Descriptions}
The typical entry in the component list will be like this:
\begin{groupdesc}
\circuitdesc{cute spdt down arrow}{Cute spdt down with arrow}{}
\circuitdesc{npn}{\scshape npn}{}( B/180/0.2,C/0/0.2,E/0/0.2 )
\end{groupdesc}
All the shapes defined by Circui\TikZ. These are all \texttt{pgf} nodes, so they are usable in both \texttt{pgf} and \TikZ.
If the component can be filled it will be specified in the description. In addition, as an example, the component shown will be filled with the option \texttt{fill=cyan!30!white}:
\begin{groupdesc}
\circuitdesc*{plain amp}{Plain amplifier}{}( out/45/0.3 )
\end{groupdesc}
Sometime, components will expose internal (sub-)shapes that can be accessed with the syntax \texttt{\textsl{<node name>}-\textsl{<internal node name>}} (a dash is separating the node name and the internal node name); that will be shown in the description as a blue ``anchor'':
\begin{groupdesc}
\circuitdesc{rotaryswitch}{Rotary switch}{}(in/-180/0.2, cin/145/0.2, center/-90/0.2, mid/0/0.4, out 1/0/0.2,
cout 1/180/0.2)[out 1.n/90/0.2, out 4.w/0/0.3]
\end{groupdesc}
The \emph{Class} of the component (see section~\ref{sec:styling}) is printed at the end of the description.
\subsection{Styling circuits and components}\label{sec:relative-size}\label{sec:styling}
You can change the visual appearance of a circuit by using a circuit style different from the default. For styling the circuit, the concept of \emph{class} of a component is key: almost every component has a class, and a style change will affect all the components of that class.
\begingroup % protect from style change the rest of the manual
Let's see the effect over a simple circuit\footnote{This is a just an example, the circuit is not intended to be functional.}.
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\newcommand\bjtname[1]{($(#1.C)!0.5!(#1.E)$) node[anchor=west]{\killdepth{#1}} }
\begin{lstlisting}[basicstyle=\scriptsize\ttfamily]
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\newcommand\bjtname[1]{($(#1.C)!0.5!(#1.E)$) node[anchor=west]{\killdepth{#1}} }
\begin{circuitikz}[american, cute inductors]
\node [op amp](A1){\texttt{OA1}};
\draw (A1.-) to[short] ++(0,1) coordinate(tmp) to[R, l_=$R$] (tmp -| A1.out) to[short] (A1.out);
\draw (tmp) to[short] ++(0,1) coordinate(tmp) to[C=$C$] (tmp -| A1.out) to[short] (A1.out);
\draw (A1.+) to [battery2, invert] ++(0,-2.5) node[ground](GND){};
\draw (A1.-) to [L=$L$] ++(-2,0) coordinate(tmp) to[sV, l=$v_s$, fill=yellow] (tmp |-GND) node[ground]{};
\draw (A1.out) to[R=$R_s$] ++(2,0) coordinate(bb) to[I, l_=$I_B$, invert] ++(0,2) node[vcc](VCC){};
\draw (bb) to[D, l=$D$, *-] ++(0,-2) coordinate(bb1) to[R=$R_m$] ++(0,-2) node[vee](VEE){};
\draw (bb) --++(1,0) node[npn, anchor=B](Q1){} \bjtname{Q1};
\draw (bb1) --++(1,0) node[pnp, anchor=B](Q2){} \bjtname{Q2};
\draw (Q1.E) -- (Q2.E) ($(Q1.E)!0.5!(Q2.E)$) to [short, *-o, name=S] ++(2.5,0)
node[right]{$v_{o_Q}$};
\draw (S.s) to[european resistor, l=$Z_L$, *-] (S.s|-GND) node[ground]{};
\draw (Q1.C) -- (Q1.C|-VCC) node[vcc]{\SI{5}{V}};
\draw (Q2.C) -- (Q2.C|-VEE) node[vee]{\SI{-5}{V}};
\end{circuitikz}
\end{lstlisting}
This code, with the default parameters, will render like the following image.
\long\def\tmpcirc#1#2{% Define the circuit to reuse it
% \begin{center}
\begin{circuitikz}[american, cute inductors, #1]
#2
\node [op amp](A1){\texttt{OA1}};
\draw (A1.-) to[short] ++(0,1) coordinate(tmp) to[R, l_=$R$] (tmp -| A1.out) to[short] (A1.out);
\draw (tmp) to[short] ++(0,1) coordinate(tmp) to[C=$C$] (tmp -| A1.out) to[short] (A1.out);
\draw (A1.+) to [battery2, invert, l=$v_{io}$] ++(0,-2.5) node[ground](GND){};
\draw (A1.-) to [L=$L$] ++(-2,0) coordinate(tmp) to[sV, l=$v_s$, fill=yellow] (tmp |-GND) node[ground]{};
\draw (A1.out) to[R=$R_s$] ++(2,0) coordinate(bb) to[I, l_=$I_B$, invert] ++(0,2) node[vcc](VCC){};
\draw (bb) to[D, l=$D$, *-] ++(0,-2) coordinate(bb1) to[R=$R_m$] ++(0,-2) node[vee](VEE){};
\draw (bb) --++(1,0) node[npn, anchor=B](Q1){} \bjtname{Q1};
\draw (bb1) --++(1,0) node[pnp, anchor=B](Q2){} \bjtname{Q2};
\draw (Q1.E) -- (Q2.E) ($(Q1.E)!0.5!(Q2.E)$) to [short, *-o, name=S] ++(2.5,0)
node[right]{$v_{o_Q}$};
\draw (S.s) to[european resistor, l=$Z_L$, *-] (S.s|-GND) node[ground]{};
\draw (Q1.C) -- (Q1.C|-VCC) node[vcc]{\SI{5}{V}};
\draw (Q2.C) -- (Q2.C|-VEE) node[vee]{\SI{-5}{V}};
\end{circuitikz}%
% \end{center}
}
\tmpcirc{}{}
\subsubsection{Relative size}\label{sec:styling-scale}
Component size can be changed globally (see section~\ref{sec:pgfcircRlen}), or you can change their relative size by scaling a family of components by setting the key \texttt{\emph{class}/scale}; for example, you can change the size of all the diodes in your circuit by setting \texttt{diodes/scale} to something different from the default \texttt{1.0}.
Remember that if you use a global scale (be sure to read section~\ref{sec:bugs}!) you change the coordinate only, so using \texttt{scale=0.8} in the environment options you have:
\tmpcirc{scale=0.8}{}
If you want to scale all the circuit, you have to use also \texttt{transform shape}:
\tmpcirc{scale=0.8, transform shape}{}
Using relative sizes as described in section~\ref{sec:pgfcircRlen} enables your style for the circuit. For example, setting:
\begin{lstlisting}
\ctikzset{resistors/scale=0.8, % smaller R
capacitors/scale=0.7, % even smaller C
diodes/scale=0.6, % small diodes
transistors/scale=1.3} % bigger BJTs
\end{lstlisting}
Will result in a (much more readable in Romano's opinion) circuit:
\tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3}}
\textbf{Warning:} relative scaling is meant to work for a reasonable range of stretching and shortening, so try to keep your scale parameter in the \texttt{0.5} to~\texttt{2.0} range (more or less). Bigger or smaller value can result in awkward shapes.
\subsubsection{Fill color}\label{sec:styling-fillcolor}
You can also set a default fill color for the components. You can use the keys \texttt{\emph{class}/fill} (which defaults to \texttt{none}, no fill, i.e. transparent component) for all fillable components in the library.
If you add to the previous styles the following commands:
\begin{lstlisting}
\ctikzset{
amplifiers/fill=cyan,
sources/fill=green,
diodes/fill=red,
resistors/fill=violet,
}
\end{lstlisting}
you will have the following circuit (note that the first generator is \emph{explicitly} set to be yellow,
so if will not be colored green!):
\tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3,%
amplifiers/fill=cyan, sources/fill=green, diodes/fill=red, resistors/fill=violet,}}
Please use this option with caution. Although two-color circuits can be nice, using more than that can become rapidly unbearable.
Old textbooks used the two-color style quite extensively, filling with a kind of light blue like \texttt{blue!30!white} ``closed'' components, but that was largely to hinder black-and-white photocopying\dots
\subsubsection{Line thickness}\label{sec:styling-thickness}
You can change the line thickness for any class of component in an independent way. The default standard thickness of components is defined on a loose ``legacy'' category (like \texttt{bipoles}, \texttt{tripoles} and so on, see section~\ref{sec:legacy-thickness}); to override that you set the key \texttt{\emph{class}/thickness} to any number. The default is \texttt{none}, which means that the old way of selecting thickness is used.
For example, \emph{amplifiers} have the legacy class of \texttt{tripoles}, as well as transistors and tubes.By default they are drawn with thickness 2 (relative to the base linewidth). To change them to be thicker, you can for example add to the previous style
\begin{lstlisting}
\ctikzset{amplifier/thickness=4}
\end{lstlisting}
\tmpcirc{scale=0.8, transform shape}{\ctikzset{resistors/scale=0.8, capacitors/scale=0.7, diodes/scale=0.6, transistors/scale=1.3,%
amplifiers/fill=cyan, sources/fill=green, diodes/fill=red, resistors/fill=violet,
amplifiers/thickness=4}}
\textbf{Caveat:} not every component has a ``class'', so you have to play with the available ones (it's specified in the component description) and with the absolute values to have the circuit following your taste. A bit of experimentation will create a kind of \emph{style options} that you could use in all your documents.
\subsubsection{Style files}
When using styles, it is possible to use \emph{style files} (see section~\ref{sec:writingstylefiles}), that then you can load with the command \verb|\ctikzloadstyle|. For example, in the distribution you have a number of style files: \texttt{legacy}, \texttt{romano}, \texttt{example}. When you load a style name \texttt{\emph{name}}, you will have available a style called \texttt{\emph{name} circuit style} that you can apply to your circuits.
The last style loaded is not enacted --- you have to explicitly do it if you want the style used by default, by putting for example in the preamble:
\begin{lstlisting}[numbers=none]
\ctikzloadstyle{romano}
\tikzset{romano circuit style}
\end{lstlisting}
Please notice that the style is at \TikZ{} level, not \Circuitikz --- that let's you use it in the top option of the circuit, like:
\begin{lstlisting}[numbers=none]
\begin{circuitikz}[legacy circuit style,
..., ]
...
\end{circuitikz}
\end{lstlisting}
If you just want to use one style, you can load and activate it in one command with
\begin{lstlisting}[numbers=none]
\ctikzsetstyle{romano}
\end{lstlisting}
The \texttt{example} style file will simply make the amplifiers filled with light blue:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[op amp]{OA1};
\end{circuitikz}
\ctikzloadstyle{example}
\begin{circuitikz}[example circuit style]
\draw (0,0) node[op amp]{OA1};
\end{circuitikz}
\end{LTXexample}
\ctikzloadstyle{legacy}
\ctikzloadstyle{romano}
The styles \texttt{legacy} is a style that set (most) of the style parameters to the default, and \texttt{romano} is a style used by one of the authors; you can use these styles as is or you can use them to learn to how to write new file style following the instructions in section~\ref{sec:writingstylefiles}. In the next diagrams, the left hand one is using the \texttt{romano circuit style} and the rigth hand one the legacy style.
\fbox{\tmpcirc{scale=0.6, transform shape, romano circuit style}{}}
\fbox{\tmpcirc{scale=0.6, transform shape, legacy circuit style}{}}
\endgroup % restore state before example of sizing
\subsubsection{Style files: how to write them}\label{sec:writingstylefiles}
The best option is to start from \texttt{ctikzstyle-legacy.tex} and edit your style file from it. Then you just put it in your input path and that's all. If you want, you can contribute your style file to the project.
Basically, to write the style \texttt{example}, you edit a file named \texttt{ctikzstyle-romano.tex} with will define and enact Ti\emph{k}Z style with name \texttt{example circuit style}; basically it has to be something along this:
\lstinputlisting[frame=single, framesep=10pt, basicstyle=\small\ttfamily]{ctikzstyle-example.tex}
This kind of style will \emph{add} to the existing style. If you want to have a style that \emph{substitute} the current style, you should do like this:
\begin{lstlisting}[frame=single, framesep=10pt, basicstyle=\small\ttfamily]
\ctikzloadstyle{legacy}% start from a know state
\tikzset{romano circuit style/.style={%
legacy circuit style, % load the legacy style
\circuitikzbasekey/.cd,%
% Resistors
resistors/scale=0.8,
[...]
\end{lstlisting}
\subsection{Grounds and supply voltages}
\subsubsection{Grounds}
For the grounds, the \texttt{center} anchor is put on the connecting point of the symbol, so that you can use them directly in a \texttt{path} specification.
\begin{groupdesc}
\circuitdesc{ground}{Ground}{}( center/0/0.3 )
\circuitdesc{tlground}{Tailless ground}{}( center/0/0.3 )
\circuitdesc{rground}{Reference ground}{}
\circuitdesc*{sground}{Signal ground}{}
\circuitdesc{tground}{Thicker tailless reference ground}{}
\circuitdesc{nground}{Noiseless ground}{}
\circuitdesc*{pground}{Protective ground}{}
\circuitdesc{cground}{Chassis ground\footnotemark}{}
\footnotetext{These last three were contributed by Luigi «Liverpool»}
\circuitdesc{eground}{European style ground}{}
\circuitdesc{eground2}{European style ground, version 2\footnotemark}{}
\footnotetext{These last two were contributed by \texttt{@fotesan}}
\end{groupdesc}
\paragraph{Grounds anchors}
Anchors for grounds are a bit strange, given that they have the \texttt{center} spot at the same location than \texttt{north} and all the ground will develop ``going down'':
\showanchors[baseline]{ground, scale=1.5}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4)
\showanchors[baseline]{ground, scale=1.5}{}(left/135/0.2, right/45/0.2, center/-180/0.2)
\paragraph{Grounds customization}
You can change the scale of these components (all the ground symbols together) by setting the key \texttt{grounds/scale} (default \texttt{1.0}).
\subsubsection{Power supplies}
\begin{groupdesc}
\circuitdesc{vcc}{VCC/VDD}{}
\circuitdesc{vee}{VEE/VSS}{}
\end{groupdesc}
The power supplies are normally drawn with the arrows shown in the list above.
\paragraph{Power supply anchors}
They are similar to grounds anchors, and the geographical anchors are correct only for the default arrow.
\showanchors[baseline]{vcc, scale=1.5}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4)
\showanchors[baseline]{vcc, scale=1.5}{}(left/135/0.2, right/45/0.2, center/-180/0.2)
\paragraph{Power supplies customization}
You can change the scale of the power supplies by setting the key \texttt{power supplies/scale} (default \texttt{1.0}).
Given that the power supply symbols are basically arrows, you can change them using all the options of the \texttt{arrows.meta} package (see the Ti\emph{k}Z manual for details) by changing the keys \texttt{monopoles/vcc/arrow} and \texttt{monopoles/vee/arrow} (the default for both is \texttt{legacy}, which will use the old code for drawing them).
Note that the anchors are at the start of the connecting lines, and that geographical anchors are just approximation if you change the arrow symbol!
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\def\coord(#1){\showcoord(#1)<0:0.3>}
\draw (0,0)
node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
node[vee](vee){VEE} \coord(vee);
\ctikzset{monopoles/vcc/arrow={Stealth[red, width=6pt, length=9pt]}}
\ctikzset{monopoles/vee/arrow={Latex[blue]}}
\draw (0,-2)
node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
node[vee](vee){VEE} \coord(vee);
\end{circuitikz}
\end{LTXexample}
However, arrows in \TikZ{} are in the same class with the line thickness, so they do not scale with neither the class \texttt{power supplies} scale nor the global scale parameter (you should use \texttt{transform canvas={scale\dots}} for this).
If you want that the arrows behave like the legacy symbols (which are shapes), \emph{only in the arrow definitions}, you can use the special length parameter \verb|\scaledwidth|\footnote{Thanks to @Schrödinger's cat on \href{https://tex.stackexchange.com/a/506249/38080}{\TeX{} stackexchange site}} in the arrow definition, which correspond to the width of the legacy \texttt{vcc} or \texttt{vee}. Compare the effects on the following circuit.
\begin{LTXexample}[pos=t, basicstyle=\small\ttfamily]
\ctikzset{%
monopoles/vcc/arrow={Triangle[width=0.8*\scaledwidth, length=\scaledwidth]},
monopoles/vee/arrow={Triangle[width=6pt, length=8pt]},
}
\begin{circuitikz}[baseline=(vo.center)]
\node [ocirc](TW) at (0,0) {};
\draw (TW.east) -- ++(1,0) node[midway, above]{$v_i$} node[op amp, anchor=-](A1){};
\draw (A1.up) -- ++(0, 0.3) node[vcc]{\SI{+10}{V}};
\draw (A1.down) -- ++(0,-0.3) node[vee]{\SI{-10}{V}};
\draw (A1.+) -- ++(-0.5,0) to[battery2, invert, l_=\SI{2}{V}] ++(0,-1) node[ground]{};
\draw (A1.out) to[short, -o] ++(0.5,0) node[above](vo){$v_o$};
\end{circuitikz} \qquad
\begin{circuitikz}[baseline=(vo.center), scale=0.6, transform shape]
\node [ocirc](TW) at (0,0) {};
\draw (TW.east) -- ++(1,0) node[midway, above]{$v_i$} node[op amp, anchor=-](A1){};
\draw (A1.up) -- ++(0, 0.3) node[vcc]{\SI{+10}{V}};
\draw (A1.down) -- ++(0,-0.3) node[vee]{\SI{-10}{V}};
\draw (A1.+) -- ++(-0.5,0) to[battery2, invert, l_=\SI{2}{V}] ++(0,-1) node[ground]{};
\draw (A1.out) to[short, -o] ++(0.5,0) node[above](vo){$v_o$};
\end{circuitikz}
\end{LTXexample}
\subsection{Resistive bipoles}
\begin{groupdesc}
\circuitdescbip{short}{Short circuit}{}
\circuitdescbip{open}{Open circuit}{}
\circuitdescbip*{generic}{Generic (symmetric) bipole}{}
\circuitdescbip*{tgeneric}{Tunable generic bipole}{}
\circuitdescbip*{ageneric}{Generic asymmetric bipole}{}
\circuitdescbip*{memristor}{Memristor}{Mr}
\end{groupdesc}
If \texttt{americanresistors} option is active (or the style \texttt{[american resistors]} is used; this is the default for the package), the resistors are displayed as follows:
\begin{groupdesc}
\ctikzset{resistor=american}
\circuitdescbip[resistor]{R}{Resistor}{american resistor}
\circuitdescbip[vresistor]{vR}{Variable resistor}{variable american resistor}
\circuitdescbip[potentiometer]{pR}{Potentiometer}{american potentiometer}( wiper/0/0.3 )
\circuitdescbip[resistivesens]{sR}{Resisitive sensor}{american resisitive sensor}( label/0/0.3 )
\end{groupdesc}
If instead \texttt{europeanresistors} option is active (or the style \texttt{[european resistors]} is used), the resistors, variable resistors and potentiometers are displayed as follows:
\begin{groupdesc}
\ctikzset{resistor=european}
\circuitdescbip*[generic]{R}{Resistor}{european resistor}
\circuitdescbip*[tgeneric]{vR}{Variable resistor}{variable european resistor}
\circuitdescbip*[genericpotentiometer]{pR}{Potentiometer}{european potentiometer}( wiper/0/0.3 )
\circuitdescbip*[thermistor]{sR}{Resistive sensor}{european resistive sensor}( label/0/0.3 )
\ctikzset{resistor=american} % reset default
\end{groupdesc}
Other miscellaneous resistor-like devices:
\begin{groupdesc}
\circuitdescbip*{varistor}{Varistor}{}
\circuitdescbip*[photoresistor]{phR}{Photoresistor}{photoresistor}
\circuitdescbip*[thermistor]{thR}{Thermistor}{thermistor}
\circuitdescbip*[thermistorptc]{thRp}{PTC thermistor}{thermistor ptc}
\circuitdescbip*[thermistorntc]{thRn}{NTC thermistor}{thermistor ntc}
\end{groupdesc}
\subsubsection{Potentiometers: wiper position}
Since version \texttt{0.9.5}, you can control the position of the wiper in potentiometers using the key \texttt{wiper pos}, which is a number in the range $[0,1]$. The default middle position is \texttt{wiper pos=0.5}.
\begin{LTXexample}[varwidth, basicstyle=\small\ttfamily]
\begin{circuitikz}[american]
\ctikzset{resistors/width=1.5, resistors/zigs=9}
\draw (0,0) to[pR, name=A] ++(0,-4);
\draw (1.5,0) to[pR, wiper pos=0.3, name=B] ++(0,-4);
\ctikzset{european resistors}
\draw (3,0) to[pR, wiper pos=0.8, name=C] ++(0,-4);
\foreach \i in {A, B, C}
\node[right] at (\i.wiper) {\i};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Generic sensors anchors}\label{sec:sensors-anchors}
Generic sensors have an extra anchor named \texttt{label} to help position the type of dependence, if needed:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,2) to[sR, l=$R$, name=mySR] ++(3,0);
\node [font=\tiny, right] at(mySR.label) {-t\si{\degree}};
\draw (0,0) to[sL, l=$L$, name=mySL] ++(3,0);
\node [draw, circle, inner sep=2pt] at(mySL.label) {};
\draw (0,-2) to[sC, l=$C$, name=mySC] ++(3,0);
\node [font=\tiny, below right, inner sep=0pt] at(mySC.label) {+H\si{\%}};
\end{circuitikz}
\end{LTXexample}
The anchor is positioned just on the corner of the segmented line crossing the component.
\subsubsection{Resistive components customization}
You can change the scale of these components (all the resistive bipoles together) by setting the key \texttt{resistors/scale} (default \texttt{1.0}). Similarly, you can change the widths by setting \texttt{resistors/width} (default \texttt{0.8}).
You can change the width of these components (all the resistive bipoles together) by setting the key \texttt{resistors/width} to something different from the default \texttt{0.8}.
For the american style resistors, you can change the number of ``zig-zags'' by setting the key
\texttt{resistors/zigs} (default value \texttt{3}).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[
longpot/.style = {pR, resistors/scale=0.75,
resistors/width=1.6, resistors/zigs=6}]
\draw (0,1.5) to[R, l=$R$] ++(4,0);
\draw (0,0) to[longpot, l=$P$] ++(4,0);
\ctikzset{resistors/scale=1.5}
\draw (0,-1.5) to[R, l=$R$] ++(4,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Capacitors and inductors: dynamical bipoles}
\subsubsection{Capacitors}
\begin{groupdesc}
\circuitdescbip{capacitor}{Capacitor}{C}
\circuitdescbip[ccapacitor]{curved capacitor}{Curved (polarized) capacitor}{cC}
\circuitdescbip*{ecapacitor}{Electrolytic capacitor}{eC,elko}
\circuitdescbip[vcapacitor]{variable capacitor}{Variable capacitor}{vC}
\circuitdescbip[capacitivesens]{capacitive sensor}{Capacitive sensor}{sC}(label/0/0.3)
\circuitdescbip*{piezoelectric}{Piezoelectric Element}{PZ}
\end{groupdesc}
There is also the (deprecated\footnote{Thanks to \href{https://tex.stackexchange.com/questions/509594/polar-capacitor-orientation-in-circuitikz-seems-wrong}{Anshul Singhv for noticing}.} --- its polarity is not coherent with the rest of the components) \texttt{polar capacitor}:
\begin{groupdesc}
\circuitdescbip[pcapacitor]{polar capacitor}{Polar capacitor}{pC}
\end{groupdesc}
\subsubsection{Capacitive sensors anchors}
For capacitive sensors, see section~\ref{sec:sensors-anchors}.
\subsubsection{Capacitors customizations}
You can change the scale of the capacitors by setting the key \texttt{capacitors/scale} to something different from the default \texttt{1.0}.
\subsubsection{Inductors}
If the \texttt{cuteinductors} option is active (default behaviour), or the style \texttt{[cute inductors]} is used, the inductors are displayed as follows:
\begin{groupdesc}
\ctikzset{inductor=cute}
\circuitdescbip[cuteinductor]{L}{Inductor}{cute inductor}(midtap/90/0.1)
\circuitdescbip[cutechoke]{cute choke}{Choke}{}
\circuitdescbip[vcuteinductor]{vL}{Variable inductor}{variable cute inductor}
\circuitdescbip[scuteinductor]{sL}{Inductive sensor}{cute inductive sensor}( label/0/0.3 )
\end{groupdesc}
If the \texttt{americaninductors} option is active (or the style \texttt{[american inductors]} is used), the inductors are displayed as follows:
\begin{groupdesc}
\ctikzset{inductor=american}
\circuitdescbip[americaninductor]{L}{Inductor}{american inductor}(midtap/90/0.3)
\circuitdescbip[vamericaninductor]{vL}{Variable inductor}{variable american inductor}
\circuitdescbip[samericaninductor]{sL}{Inductive sensor}{american inductive sensor}( label/0/0.3 )
\end{groupdesc}
Finally, if the \texttt{europeaninductors} option is active (or the style \texttt{[european inductors]} is used), the inductors are displayed as follows:
\begin{groupdesc}
\ctikzset{inductor=european}
\circuitdescbip[fullgeneric]{L}{Inductor}{european inductor}(midtap/90/0.1)
\circuitdescbip[tfullgeneric]{vL}{Variable inductor}{variable european inductor}
\circuitdescbip[sfullgeneric]{sL}{Inductive sensor}{european inductive sensor}( label/0/0.3 )
\ctikzset{inductor=cute} % back to default
\end{groupdesc}
\subsubsection{Inductors customizations}\label{sec:tweak-l}
You can change the scale of the inductors by setting the key \texttt{inductors/scale} to something different from the default \texttt{1.0}.
You can change the width of these components (all the inductors together, unless you use style or scoping) by setting the key \texttt{inductors/width} to something different from the default, which is \texttt{0.8} for american and european inductors, and \texttt{0.6} for cute inductors.
Moreover, you can change the number of ``coils'' drawn by setting the key
\texttt{inductors/coils} (default value \texttt{5} for cute inductors and \texttt{4} for american ones).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[
longL/.style = {cute choke, inductors/scale=0.75,
inductors/width=1.6, inductors/coils=9}]
\draw (0,1.5) to[L, l=$L$] ++(4,0);
\draw (0,0) to[longL, l=$L$] ++(4,0);
\ctikzset{inductors/scale=1.5, inductor=american}
\draw (0,-1.5) to[L, l=$L$] ++(4,0);
\end{circuitikz}
\end{LTXexample}
Chokes (which comes only in the \texttt{cute} style) can have single and double lines, and can have the line thickness adjust (the value is relative to the thickness of the inductor).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[cute choke] ++(3,0);
\draw (0,-1) to[cute choke, twolineschoke] ++(3,0);
\ctikzset{bipoles/cutechoke/cthick=2, twolineschoke}
\draw (0,-2) to[cute choke] ++(3,0);
\draw (0,-3) to[cute choke, onelinechoke] ++(3,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{Inductors anchors}
For inductive sensors, see section~\ref{sec:sensors-anchors}.
Inductors have an additional anchor, called \texttt{midtap}, that connects to the center of the coil ``wire''. Notice that this anchor could be on one side or the other of the component, depending on the number of loops of the element; if you need a fixed position, you can use the geographical anchors.
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{circuitikz}[
loops/.style={circuitikz/inductors/coils=#1}]
\ctikzset{cute inductors}
\draw (0,2) to[L, loops=5, name=A] ++(2,0)
to[L, loops=6, name=B] ++(2,0);
\ctikzset{american inductors}
\draw (0,0) to[L, loops=5, name=C] ++(2,0)
to[L, loops=6, name=D] ++(2,0);
\foreach \i in {A, B, C, D}
\node[circle, fill=red, inner sep=1pt] at (\i.midtap){};
\end{circuitikz}
\end{LTXexample}
\subsection{Diodes and such}
There are three basic styles for diodes: \texttt{empty} (fillable in color), \texttt{full} (completely filled with the draw color) and \texttt{stroke} (empty, but with a line across them).
You can switch between the styles setting the key \texttt{diode} (for example \verb|\ctikzset{diode=full}| or \texttt{empty} or \texttt{stroke}, or with the styles \texttt{full diodes}, \texttt{empty diodes} and \texttt{stroke diodes}.
To use the default element, simply use the name shown for the empty diodes without the final ``o'' --- that is \texttt{D}, \texttt{sD}, and so on. The names shown in the following tables will draw the specified diode independently on the style chosen (that is, \texttt{leD*} is always a full LED diode).
\begin{framed}
The package options \texttt{fulldiode}, \texttt{strokediode}, and \texttt{emptydiode} (and the styles \texttt{[full diodes]}, \texttt{[stroke diodes]}, and \texttt{[empty diodes]}) define which shape will be used by abbreviated commands such that \texttt{D}, \texttt{sD}, \texttt{zD}, \texttt{zzD}, \texttt{tD}, \texttt{pD}, \texttt{leD}, \texttt{VC}, \texttt{Ty},\texttt{Tr} (no stroke symbol available!).
\end{framed}
\begin{groupdesc}
\circuitdescbip*[emptydiode] {empty diode}{Empty diode}{Do}
\circuitdescbip*[emptysdiode]{empty Schottky diode}{Empty Schottky diode}{sDo}
\circuitdescbip*[emptyzdiode]{empty Zener diode}{Empty Zener diode}{zDo}
\circuitdescbip*[emptyzzdiode]{empty ZZener diode}{Empty ZZener diode}{zzDo}
\circuitdescbip*[emptytdiode]{empty tunnel diode}{Empty tunnel diode}{tDo}
\circuitdescbip*[emptypdiode]{empty photodiode}{Empty photodiode}{pDo}
\circuitdescbip*[emptylediode]{empty led}{Empty led}{leDo}
\circuitdescbip*[emptyvarcap]{empty varcap}{Empty varcap}{VCo}
\circuitdescbip*[emptybidirectionaldiode]{empty bidirectionaldiode}{Empty bidirectionaldiode}{biDo}
\circuitdescbip[fulldiode] {full diode}{Full diode}{D*}
\circuitdescbip[fullsdiode]{full Schottky diode}{Full Schottky diode}{sD*}
\circuitdescbip[fullzdiode]{full Zener diode}{Full Zener diode}{zD*}
\circuitdescbip[fullzzdiode]{full ZZener diode}{Full ZZener diode}{zzD*}
\circuitdescbip[fulltdiode]{full tunnel diode}{Full tunnel diode}{tD*}
\circuitdescbip[fullpdiode]{full photodiode}{Full photodiode}{pD*}
\circuitdescbip[fulllediode]{full led}{Full led}{leD*}
\circuitdescbip[fullvarcap]{full varcap}{Full varcap}{VC*}
\circuitdescbip[fullbidirectionaldiode]{full bidirectionaldiode}{Full bidirectionaldiode}{biD*}
\end{groupdesc}
These shapes have no exact node-style counterpart, because the stroke line is built upon the empty variants:
\begin{groupdesc}
\circuitdescbip*[emptydiode] {stroke diode}{Stroke diode}{D-}
\circuitdescbip*[emptysdiode]{stroke Schottky diode}{Stroke Schottky diode}{sD-}
\circuitdescbip*[emptyzdiode]{stroke Zener diode}{Stroke Zener diode}{zD-}
\circuitdescbip*[emptyzzdiode]{stroke ZZener diode}{Stroke ZZener diode}{zzD-}
\circuitdescbip*[emptytdiode]{stroke tunnel diode}{Stroke tunnel diode}{tD-}
\circuitdescbip*[emptypdiode]{stroke photodiode}{Stroke photodiode}{pD-}
\circuitdescbip*[emptylediode]{stroke led}{Stroke led}{leD-}
\circuitdescbip*[emptyvarcap]{stroke varcap}{Stroke varcap}{VC-}
\end{groupdesc}
\subsubsection{Tripole-like diodes}\label{sec:othertrip} The following tripoles are entered with the usual command, of the form \texttt{to[Tr, \dots]}.
\begin{groupdesc}
\circuitdescbip*[emptytriac]{triac}{Standard triac (shape depends on package option)}{Tr}( G/0/0.3, anode/-90/0.2, cathode/-90/0.2)
\circuitdescbip*[emptytriac]{empty triac}{Empty triac}{Tro}( gate/0/0.3 )
\circuitdescbip[fulltriac]{full triac}{Full triac}{Tr*}
\circuitdescbip*[emptythyristor]{thyristor}{Standard thyristor (shape depends on package option)}{Ty}( G/0/0.3, anode/-90/0.2, cathode/-90/0.2)
\circuitdescbip*[emptythyristor]{empty thyristor}{Empty thyristor}{Tyo}
\circuitdescbip[fullthyristor]{full thyristor}{Full thyristor}{Ty*}
\circuitdescbip*[emptythyristor]{stroke thyristor}{Stroke thyristor}{Ty-}
\end{groupdesc}
\subsubsection{Triacs anchors}
When inserting a thrystor, a triac or a potentiometer, one needs to refer to the third node-gate (\texttt{gate} or \texttt{G}) for the former two; wiper (\texttt{wiper} or \texttt{W}) for the latter one. This is done by giving a name to the bipole:
\label{bipole-naming}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) to[Tr, n=TRI] (2,0)
to[pR, n=POT] (4,0);
\draw[dashed] (TRI.G) -| (POT.wiper)
;\end{circuitikz}
\end{LTXexample}
\subsubsection{Diode customizations}\label{sec:tweak-d}
You can change the scale of the diodes by setting the key \texttt{diodes/scale} to something different from the default \texttt{1.0}. In Romano's opinion, diodes are somewhat big with the default style of the package, so a setting like \verb|\ctikzset{diode/scale=0.6}| is recommended.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,1) to[D, l=$D$] ++(2,0)
node[npn, anchor=B]{};
\ctikzset{diodes/scale=0.6}
\draw (0,-1) to[D, l=$D$] ++(2,0)
node[npn, anchor=B]{};
\end{circuitikz}
\end{LTXexample}
\subsection{Sources and generators}
Notice that source and generators are divided in three classes that can be styled independently: traditional battery symbols (class \texttt{batteries}), independent generators (class \texttt{sources}) and dependent generators (class \texttt{csources}). This is because they are often treated differently, and so you can choose to, for example, fill the dependent sources but not the independent ones.
\subsubsection{Batteries}
\begin{groupdesc}
\circuitdescbip{battery}{Battery}{}
\circuitdescbip{battery1}{Single battery cell}{}
\circuitdescbip{battery2}{Single battery cell}{}
\end{groupdesc}
\subsubsection{Stationary sources}
\begin{groupdesc}
\circuitdescbip*[vsource]{european voltage source}{Voltage source (european style)}{}
\circuitdescbip*[vsourceC]{cute european voltage source}{Voltage source (cute european style)}{vsourceC, ceV}
\circuitdescbip*[vsourceAM]{american voltage source}{Voltage source (american style)}{}
\circuitdescbip*[isource]{european current source}{Current source (european style)}{}
\circuitdescbip*[isourceC]{cute european current source}{Current source (cute european style)}{isourceC, ceI}
\circuitdescbip*[isourceAM]{american current source}{Current source (american style)}{}
\end{groupdesc}
\begin{framed}
If (default behaviour) \texttt{europeancurrents} option is active (or the style \texttt{[european currents]} is used), the shorthands \texttt{current source}, \texttt{isource}, and \texttt{I} are equivalent to \texttt{european current source}. Otherwise, if \texttt{americancurrents} option is active (or the style \texttt{[american currents]} is used) they are equivalent to \texttt{american current source}.
Similarly, if (default behaviour) \texttt{europeanvoltages} option is active (or the style \texttt{[european voltages]} is used), the shorthands \texttt{voltage source}, \texttt{vsource}, and \texttt{V} are equivalent to \texttt{european voltage source}. Otherwise, if \texttt{americanvoltages} option is active (or the style \texttt{[american voltages]} is used) they are equivalent to \texttt{american voltage source}.
\end{framed}
\subsubsection{Sinusoidal sources}\label{sec:sinusoidal-vi} These two are basically the same symbol; to distinguish among them, you have to add a label, which will be a voltage or a current.
\begin{groupdesc}
\circuitdescbip*[vsourcesin]{sinusoidal voltage source}{Sinusoidal voltage source}{vsourcesin, sV}
\circuitdescbip*[isourcesin]{sinusoidal current source}{Sinusoidal current source}{isourcesin, sI}
\end{groupdesc}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,1) to[sV=$V$] ++(3,0);
\draw (0,0) to[sI=$I$] ++(3,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{Controlled sources}
\begin{groupdesc}
\circuitdescbip*[cvsource]{european controlled voltage source}{Controlled voltage source (european style)}{}
\circuitdescbip*[cvsourceC]{cute european controlled voltage source}{Voltage source (cute european style)}{cvsourceC, cceV}
\circuitdescbip*[cvsourceAM]{american controlled voltage source}{Controlled voltage source (american style)}{}
\circuitdescbip*[cisource]{european controlled current source}{Controlled current source (european style)}{}
\circuitdescbip*[cisourceC]{cute european controlled current source}{Current source (cute european style)}{cisourceC, cceI}
\circuitdescbip*[cisourceAM]{american controlled current source}{Controlled current source (american style)}{}
\circuitdescbip*[ecsource]{empty controlled source}{Empty controlled source}{ecsource}
\end{groupdesc}
\begin{framed}
If (default behaviour) \texttt{europeancurrents} option is active (or the style \texttt{[european currents]} is used), the shorthands \texttt{controlled current source}, \texttt{cisource}, and \texttt{cI} are equivalent to \texttt{european controlled current source}. Otherwise, if \texttt{americancurrents} option is active (or the style \texttt{[american currents]} is used) they are equivalent to \texttt{american controlled current source}.
Similarly, if (default behaviour) \texttt{europeanvoltages} option is active (or the style \texttt{[european voltages]} is used), the shorthands \texttt{controlled voltage source}, \texttt{cvsource}, and \texttt{cV} are equivalent to \texttt{european controlled voltage source}. Otherwise, if \texttt{americanvoltages} option is active (or the style \texttt{[american voltages]} is used) they are equivalent to \texttt{american controlled voltage source}.
\end{framed}
The following two behave like the corresponding independent sources, see section~\ref{sec:sinusoidal-vi}.
\begin{groupdesc}
\circuitdescbip*[cvsourcesin]{controlled sinusoidal voltage source}{Controlled sinusoidal voltage source}{controlled vsourcesin, cvsourcesin, csV}
\circuitdescbip*[cisourcesin]{controlled sinusoidal current source}{Controlled sinusoidal current source}{controlled isourcesin, cisourcesin, csI}
\end{groupdesc}
\subsubsection{Noise sources}
In this case, the ``direction'' of the source is undefined. Noise sources are filled in gray by default, but if you choose the dashed style, they become fillable.
\begin{groupdesc}
\circuitdescbip[vsourceN]{noise voltage source}{Sinusoidal voltage source}{vsourceN, nV}
\circuitdescbip[isourceN]{noise current source}{Sinusoidal current source}{isourceN, nI}
\end{groupdesc}
You can change the fill color with the key \texttt{circuitikz/bipoles/noise sources/fillcolor}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw(0,0) to [nV, l=$e_n$] ++(2,0);
\draw(0,-2) to [nI, l=$i_n$] ++(2,0);
\begin{scope}[circuitikz/bipoles/noise sources/fillcolor=red!50]
\draw(3,0) to [nV, l=$e_n$] ++(2,0);
\draw(3,-2) to [nI, l=$i_n$] ++(2,0);
\end{scope}
\end{circuitikz}
\end{LTXexample}
If you prefer a patterned noise generator (similar to the one you draw by hand) you can use the fake color \texttt{dashed}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw(0,0) to [nV, l=$e_n$] ++(2,0);
\draw(0,-2) to [nI, l=$i_n$] ++(2,0);
\begin{scope}[circuitikz/bipoles/noise sources/fillcolor=dashed]
\draw(3,0) to [nV, l=$e_n$] ++(2,0);
\draw(3,-2) to [nI, l=$i_n$] ++(2,0);
\end{scope}
\end{circuitikz}
\end{LTXexample}
Notice that if you choose the dashed style, the noise sources are fillable:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{bipoles/noise sources/fillcolor=dashed}
\draw(0,0) to [nV, l=$e_n$] ++(2,0);
\draw(0,-2) to [nI, l=$i_n$] ++(2,0);
\begin{scope}
\draw(3,0) to [nV, l=$e_n$, fill=yellow!50!red] ++(2,0);
\draw(3,-2) to [nI, l=$i_n$, fill=blue!50!white] ++(2,0);
\end{scope}
\end{circuitikz}
\end{LTXexample}
\subsubsection{Special sources}
\begin{groupdesc}
\circuitdescbip*[vsourcesquare]{square voltage source}{Square voltage source}{vsourcesquare, sqV}
\circuitdescbip*{vsourcetri}{Triangle voltage source}{tV}
\circuitdescbip*{esource}{Empty voltage source}{}
\circuitdescbip*{pvsource}{Photovoltaic-voltage source}{}
\circuitdescbip*[oosource]{ioosource}{Double Zero style current source}{}
\circuitdescbip*[oosource]{voosource}{Double Zero style voltage source}{}
\end{groupdesc}
\subsubsection{DC sources}
\begin{groupdesc}
\circuitdescbip*{dcvsource}{DC voltage source}{}
\circuitdescbip*{dcisource}{DC current source}{}
\end{groupdesc}
The size of the broken part of the DC current source is configurable by changing the value of \texttt{bipoles/dcisource/angle} (default \texttt{80}); values must be between 0 (no circle at all, probably not useful) and 90 (full circle, again not useful).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[dcvsource] ++(2,0)
to [dcisource, fill=yellow] ++(2,0) ;
\ctikzset{bipoles/dcisource/angle=45}
\draw (0,-2) to[dcvsource] ++(2,0)
to [dcisource, fill=yellow] ++(2,0) ;
\end{circuitikz}
\end{LTXexample}
\subsubsection{Sources customizations}\label{sec:tweak-sources}
You can change the scale of the batteries by setting the key \texttt{batteries/scale}, for the controlled (dependent) sources with \texttt{csources/scale}, and for all the other independent sources and generators with \texttt{sources/scale}, to something different from the default \texttt{1.0}.
\subsection{Instruments}
\begin{groupdesc}
\circuitdescbip*{ammeter}{Ammeter}{}
\circuitdescbip*{voltmeter}{Voltmeter}{}
\circuitdescbip*{ohmmeter}{Ohmmeter}{}
\circuitdescbip*{rmeter}{Round meter (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\circuitdescbip*{rmeterwa}{Round meter with arrow (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\circuitdescbip*{smeter}{Square meter (use \texttt{t=...} for the symbol)}{}(left/135/0.2, right/45/0.2, center/-90/0.3, in 1/-135/.5, in 2/-45/.5)
\circuitdescbip*{qiprobe}{QUCS-style current probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\circuitdescbip*{qvprobe}{QUCS-style voltage probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\circuitdescbip*{qpprobe}{QUCS-style power probe}{}(left/135/0.2, right/45/0.2, center/-90/0.3, v+/-135/.5, v-/-45/.5)
\circuitdescbip*[oscope]{oscope}{Oscilloscope\footnotemark}{}(left/135/0.2, right/45/0.2,
in 1/-135/0.4, in 2/-45/0.4)
\footnotetext{Suggested by \texttt{@nobrl} on GitHub}
\circuitdescbip{iloop}{Current loop (symbolic)}{}(left/135/0.2, right/45/0.2, center/-90/0.3, i/30/0.4)
\circuitdescbip{iloop2}{Current loop (real)}{}(left/135/0.2, right/-45/0.2, center/-90/0.3, i+/135/0.4, i-/45/0.4)
\end{groupdesc}
\subsubsection{Instruments customizations}\label{sec:tweak-instruments}
You can change the scale of all the instruments (including the current loops) by setting the key \texttt{instruments/scale} to something different from the default \texttt{1.0}.
\subsubsection{Rotation-invariant elements}
The \texttt{oscope} element will not rotate the ``graph'' shown with the component:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\foreach \a in {0,45,...,350} {
\draw (0,0) to[oscope] (\a:3);
}
\end{circuitikz}
\end{LTXexample}
The \texttt{rmeter}, \texttt{rmaterwa}, and \texttt{smeter} have the same behavior.
\subsubsection{Instruments as node elements}
The node-style usage of the \texttt{oscope} is also interesting, using the additional \texttt{in 1} and \texttt{in 2} anchors; notice that in this case you can use the text content of the node to put labels above it.
Moreover, you can change the size of the oscilloscope by changing \texttt{bipoles/oscope/width} and \texttt{bipoles/oscope/height} keys (which both default to 0.6).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,1)
to[oscope=$C_1$, fill=green!20!gray, name=O1] ++(2,0);
\path (O1.right)
node[ground, scale=0.5, below right=4pt]{};
\ctikzset{bipoles/oscope/width=1.0}
\draw (1,-1)
node[oscopeshape, fill=yellow!20!orange](O2){$C_2$};
\draw (O2.in 2) to[short, *-] ++(0,-0.5) node[ground]{};
\draw (O2.in 1) to[short, *-] ++(0,-0.5)
-- ++(-1,0) node[currarrow, xscale=-1]{};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Measuring voltage and currents, multiple ways}
This is the classical (legacy) option, with the \texttt{voltmeter} and \texttt{ammeter}. The problem is that elements are intrinsically horizontal, so they look funny if put in vertically.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [ammeter] ++(0,-2) node[ground]{};
\draw (1,0) to[voltmeter] ++(0,-2)
node[ground]{};
\end{circuitikz}
\end{LTXexample}
So the solution is often changing the structure to keep the meters in horizontal position.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [ammeter] ++(2,0) --
++(0,-1) node[ground]{};
\draw (1,0) -- (1,1) to[voltmeter]
++(2,0) node[ground]{};
\end{circuitikz}
\end{LTXexample}
Since version 0.9.0 you have more options for the measuring instruments. You can use the generic \texttt{rmeterwa} (round meter with arrow), to which you can specify the internal symbol with the option \texttt{t=...} (and is fillable).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [rmeterwa, t=A, i=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[rmeterwa, t=V, v=$v$] ++(0,-2)
node[ground]{};
\end{circuitikz}
\end{LTXexample}
This kind of component will keep the symbol horizontal, whatever the orientation:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [rmeterwa, t=A, i=$i$] ++(2,0) --
++(0,-1) node[ground]{};
\draw (1,0) -- (1,1) to[rmeterwa, t=V, v^=$v$]
++(2,0) node[ground]{};
\end{circuitikz}
\end{LTXexample}
The plain \texttt{rmeter} is the same, without the measuring arrow:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [rmeter, t=A, i=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[rmeter, t=V, v=$v$] ++(0,-2)
node[ground]{};
\end{circuitikz}
\end{LTXexample}
If you prefer it, you have the option to use square meters, in order to have more visual difference from generators:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [smeter, t=A, i=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[smeter, t=V, v=$v$] ++(0,-2)
node[ground]{};
\end{circuitikz}
\end{LTXexample}
Another possibility is to use QUCS\footnote{QUCS is an open source circuit simulator: \url{http://qucs.sourceforge.net/}}-style probes, which have the nice property of explictly showing the type of connection (in series or parallel) of the meter:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [qiprobe, l=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[qvprobe, l=$v$] ++(0,-2)
node[ground]{};
\end{circuitikz}
\end{LTXexample}
If you want to explicitly show a power measurement, you can use the power probe \texttt{qpprobe} and using the additional anchors \texttt{v+} and \texttt{v-} :
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[short,-*] ++(1,0) coordinate(b)
to[R] ++(2,0) to [qpprobe, l=$i$, a=$v$, name=P]
++(0,-2.5) node[ground](GND){};
\draw (P.v-) -| ++(-0.5,-1) coordinate(a)
to [short, -*] (a-|GND);
\draw (P.v+) -| (b);
\end{circuitikz}
\end{LTXexample}
The final possibility is to use oscilloscopes. For example:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(3,0)
to [iloop, mirror, name=I] ++(0,-2)
node[ground] (GND){};
\draw (1,0) to[oscope, v=$v$] ++(0,-2)
node[ground]{};
\draw (I.i) -- ++(-0.5,0) node[oscopeshape, anchor=right, name=O]{};
\draw (O.south) -- (O.south |- GND) node[ground]{};
\end{circuitikz}
\end{LTXexample}
Or, if you want a more physical structure for the measurement setup:
\begin{LTXexample}[varwidth=true, pos=b]
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(3,0) to [iloop2, name=I] ++(0,-2)
node[ground] (GND){};
\ctikzset{bipoles/oscope/width=1.6}\ctikzset{bipoles/oscope/height=1.2}
\node [oscopeshape, fill=green!10](O) at (6,2){};
\node [bnc, xscale=-1, anchor=zero](bnc1) at (O.in 1){};
\node [bnc, , anchor=zero, rotate=-90](bnc2) at (O.in 2){};
\draw [-latexslim] (bnc1.hot) -| (1,0);
\draw (bnc2.hot) |- (I.i+);
\draw (I.i-) node[ground, scale=0.5]{};
\end{circuitikz}
\end{LTXexample}
\subsection{Mechanical Analogy}
\begin{groupdesc}
\circuitdescbip*{damper}{Mechanical Damping}{}
\circuitdescbip{spring}{Mechanical Stiffness}{}
\circuitdescbip*{viscoe}{Mechanical viscoelastic element\footnotemark}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\footnotetext{Suggested by @Alex in \url{https://tex.stackexchange.com/q/484268/38080}}
\circuitdescbip*{mass}{Mechanical Mass}{}
\end{groupdesc}
\subsubsection{Mechanical elements customizations}\label{sec:tweak-mechanicals}
You can change the scale of all the mechanical elements by setting the key \texttt{mechanicals/scale} to something different from the default \texttt{1.0}.
\subsection{Miscellaneous bipoles}
Here you'll find bipoles that are not easily grouped in the categories above.
\begin{groupdesc}
\circuitdescbip{thermocouple}{Thermocouple}{}
\circuitdescbip*{fuse}{Fuse}{}
\circuitdescbip*{afuse}{Asymmetric fuse}{asymmetric fuse}
\circuitdescbip{squid}{Squid}{}
\circuitdescbip{barrier}{Barrier}{}
\end{groupdesc}
\begin{groupdesc}
\circuitdescbip*{european gas filled surge arrester}{European gas filled surge arrester}{}
\circuitdescbip*{american gas filled surge arrester}{American gas filled surge arrester}{}
\end{groupdesc}
\begin{framed}
If (default behaviour) \texttt{europeangfsurgearrester} option is active (or the style \texttt{[european gas filled surge arrester]} is used), the shorthands \texttt{gas filled surge arrester} and \texttt{gf surge arrester} are equivalent to the european version of the component.
If otherwise \texttt{americangfsurgearrester} option is active (or the style \texttt{[american gas filled surge arrester]} is used), the shorthands the shorthands \texttt{gas filled surge arrester} and \texttt{gf surge arrester} are equivalent to the american version of the component.
\end{framed}
\begin{groupdesc}
\circuitdescbip*{lamp}{Lamp}{}
\circuitdescbip*{bulb}{Bulb}{}
\circuitdescbip*{loudspeaker}{loudspeaker}{}( north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4, south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
\circuitdescbip*{mic}{mic}{}( north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4, south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
\end{groupdesc}
You can use microphones and loudspeakers with \texttt{waves} (see section~\ref{sec:RF}) too:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[mic, name=M] ++(0,2)
to[amp, t=$A$] ++(2,0)
to[loudspeaker, name=L] ++(0,-2)
to[short, -*] (0,0) node[ground]{};
\node [waves, scale=0.7, left=5pt]
at(M.north) {};
\node [waves, scale=0.7, right]
at(L.north) {};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Miscellanous element customization}\label{sec:tweak-misc}
You can change the scale of all the miscellaneous elements by setting the key \texttt{misc/scale} to something different from the default \texttt{1.0}.
\subsection{Crossings}
Path style:
\begin{groupdesc}
\circuitdescbip{crossing}{Jumper style non-contact crossing}{xing}
\end{groupdesc}
Node style:
\begin{groupdesc}
\circuitdesc{jump crossing}{Jumper-style crossing node}{}
\circuitdesc{plain crossing}{Plain style crossing node}{}
\end{groupdesc}
All circuit-drawing standards agree that to show a crossing without electric contact, a simple crossing of the wires suffices; the electrical contact must be explicitly marked with a filled dot.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[]
\draw(1,-1) to[short] (1,1)
(0,0) to[short] (2,0);
\draw(4,-1) to[short] (4,1)
(3,0) to[short] (5,0)
(4,0) node[circ]{};
\end{circuitikz}
\end{LTXexample}
However, sometime it is advisable to mark the non-contact situation more explicitly. To this end, you can use a path-style component called \texttt{crossing}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[]
\draw(1,-1) to[short] (1,1) (0,0) to[crossing] (2,0);
\draw(4,-1) to[short] (4,1) (3,0) to[short] (5,0)
(4,0) node[circ]{};
\end{circuitikz}
\end{LTXexample}
That should suffice most of the time; the only problem is that the crossing jumper will be put in the center of the subpath where the \texttt{to[crossing]} is issued, so sometime a bit of trial and error is needed to position it.
For a more powerful (and elegant) way you can use the crossing nodes:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[]
\node at (1,1)[jump crossing](X){};
\draw (X.west) -- ++(-1,0);
\draw (X.east) to[R] ++(2,0);
\draw (X.north) node[vcc]{};
\draw (X.south) to[C] ++(0,-1.5);
\end{circuitikz}
\end{LTXexample}
Notice that the \texttt{plain crossing} and the \texttt{jump crossing} have a small gap in the straight wire, to enhance the effect of crossing (as a kind of shadow).
The size of the crossing elements can be changed with the key \texttt{bipoles/crossing/size} (default 0.2).
\subsection{Arrows}\label{sec:arrows}
These are pseudo-arrows used in lot of places in the packages (for transistors, flows, currents, and so on).
\begin{groupdesc}
\circuitdesc{currarrow}{Arrows (current and voltage)}{}(center/0/0.2)
\circuitdesc{inputarrow}{Arrow to draw at its tip, useful for block diagrams.}{}(center/0/0.2)
\end{groupdesc}
\subsubsection{Arrows size}\label{sec:currarrow-size}
You can use the parameter \texttt{current arrow scale} to change the size of the arrows in various components and indicators; the normal value is 16, higher numbers give smaller arrows and so on. You need to use \texttt{circuitikz/current arrow scale} if you use it into a node.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i=f] ++(2,0) node[npn, anchor=B]{};
\draw (0,-2) to[R, f=f, current arrow scale=8] ++(2,0)
node[pnp, anchor=B, circuitikz/current arrow scale=8]{};
\draw (0,-4) to[R, f=f, current arrow scale=24] ++(2,0)
node[nigbt, anchor=B]{};
\end{circuitikz}
\end{LTXexample}
Moreover, you have the arrow tip \texttt{latexslim} which is an arrow similar to the old (in deprecated \texttt{arrows} library) \texttt{latex'} element:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\draw [latexslim-latexslim] (0,0) -- (1,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Terminal shapes}\label{sec:terminals}
These are the so-called ``bipole nodes'' shapes, or poles (see section~\ref{sec:bipole-nodes}). These nodes are always filled; the ``open'' versions (starting with an \texttt{o}) are by default filled white, but you can override it with the \texttt{fill} parameter.
\begin{groupdesc}
\circuitdesc{circ}{Connected terminal}{}
\circuitdesc{ocirc}{Unconnected terminal}{}
\circuitdesc{diamondpole}{Diamond-square terminal}{}
\circuitdesc{odiamondpole}{Open diamond-square terminal}{}
\circuitdesc{squarepole}{Square-shape terminal}{}
\circuitdesc{osquarepole}{Open square-shape terminal}{}
\end{groupdesc}
Since version 0.9.0, ``bipole nodes'' shapes have all the standard geographical anchors, so you can do things like these:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american,]
\draw (0,-1) node[draw](R){R};
\draw (R.east) node[ocirc, right]{};
\end{circuitikz}
\end{LTXexample}
The size of the poles is controlled by the key \texttt{nodes width} (default \texttt{0.04}, relative to the basic length).
Be sure to see section~\ref{sec:bipole-nodes} for more usage and configurability.
\subsubsection{BNC connector/terminal}
\begin{groupdesc}
\circuitdesc*{bnc}{BNC connector}{}(left/135/0.6, right/45/0.6, center/-90/0.6, hot/0/0.6, zero/-135/0.6)
\end{groupdesc}
The BNC connector is defined so that you can easily connect it as input or output (but remember that you need to flip the text if you flip the component):
\begin{LTXexample}[varwidth, ]
\begin{circuitikz}
\draw (0,0)
node[bnc](B1){$v_i$} to[R=\SI{50}{\ohm}] ++(3,0)
node[bnc, xscale=-1](B2){\scalebox{-1}[1]{$v_o$}};
\node [ground] at (B1.shield) {};
\node [eground] at (B2.shield){};
\end{circuitikz}
\end{LTXexample}
It also has a \texttt{zero} anchor if you need to rotate it about its real center.
\begin{LTXexample}[varwidth, ]
\begin{circuitikz}
\draw[thin, red] (0,0) -- ++(1,0) (0,-1) -- ++(1,0);
\path (0,0) node[bnc]{} ++(1,0) node[bnc, rotate=-90]{};
\path (0,-1) node[bnc, anchor=zero]{} ++(1,0) node[bnc, anchor=zero, rotate=-90]{};
\end{circuitikz}
\end{LTXexample}
\subsection{Block diagram components}
\noindent Contributed by Stefan Erhardt.
\begin{groupdesc}
\circuitdesc*{mixer}{mixer}{}( 1/180/0.1,2/-90/0.1,3/0/0.1,4/90/0.1 )
\circuitdesc*{adder}{adder}{}( west/180/0.1,south/-90/0.1,east/0/0.1,north/90/0.1 )
\circuitdesc*{oscillator}{oscillator}{}
\circuitdesc*{circulator}{circulator}{}
\circuitdesc*{wilkinson}{wilkinson divider}{}( in/180/0.1, out2/45/0.1, out1/-45/0.1 )
\end{groupdesc}
\begin{groupdesc}
\circuitdescbip*{twoport}{generic two port\footnotemark}{}
\footnotetext{To specify text to be put in the component: \texttt{twoport[t=text]}): \tikz \draw[scale=.5, transform shape] (0,0) to[twoport,>,t=text] (2,0); }
\circuitdescbip*{vco}{vco}{}
\circuitdescbip*{bandpass}{bandpass}{}
\circuitdescbip*{bandstop}{bandstop}{}
\circuitdescbip*{highpass}{highpass}{}
\circuitdescbip*{lowpass}{lowpass}{}
\circuitdescbip*{adc}{A/D converter}{}
\circuitdescbip*{dac}{D/A converter}{}
\circuitdescbip*{dsp}{DSP}{}
\circuitdescbip*{fft}{FFT}{}
\circuitdescbip*{amp}{amplifier}{}
\circuitdescbip*{vamp}{VGA}{}
\circuitdescbip*{piattenuator}{$\pi$ attenuator}{}
\circuitdescbip*{vpiattenuator}{var. $\pi$ attenuator}{}
\circuitdescbip*{tattenuator}{T attenuator}{}
\circuitdescbip*{vtattenuator}{var.\ T attenuator}{}
\circuitdescbip*{phaseshifter}{phase shifter}{}
\circuitdescbip*{vphaseshifter}{var.\ phase shifter}{}
\circuitdescbip*{detector}{detector}{}
\end{groupdesc}
\begin{groupdesc}
\circuitdesc*{fourport}{Generic fourport}{}
\circuitdesc*{coupler}{Coupler}{}
\circuitdesc*{coupler2}{Coupler with rounded arrows}{}
\end{groupdesc}
\subsubsection{Blocks anchors}
The ports of the mixer and adder can be addressed with numbers or \texttt{west}/\texttt{south}/\texttt{east}/\texttt{north}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[mixer] (mix) {}
(mix.1) node[left] {1}
(mix.2) node[below] {2}
(mix.3) node[right] {3}
(mix.4) node[above] {4}
;\end{circuitikz}
\end{LTXexample}
The Wilkinson divider has:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[wilkinson] (w) {\SI{3}{dB}}
(w.in) to[short,-o] ++(-0.5,0)
(w.out1) to[short,-o] ++(0.5,0)
(w.out2) to[short,-o] ++(0.5,0)
(w.in) node[below left] {\texttt{in}}
(w.out1) node[below right] {\texttt{out1}}
(w.out2) node[above right] {\texttt{out2}}
;
\end{circuitikz}
\end{LTXexample}
The couplers have:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[coupler] (c) {\SI{10}{dB}}
(c.1) to[short,-o] ++(-0.5,0)
(c.2) to[short,-o] ++(0.5,0)
(c.3) to[short,-o] ++(0.5,0)
(c.4) to[short,-o] ++(-0.5,0)
(c.1) node[below left] {\texttt{1}}
(c.2) node[below right] {\texttt{2}}
(c.3) node[above right] {\texttt{3}}
(c.4) node[above left] {\texttt{4}}
;
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[coupler2] (c) {\SI{3}{dB}}
(c.1) to[short,-o] ++(-0.5,0)
(c.2) to[short,-o] ++(0.5,0)
(c.3) to[short,-o] ++(0.5,0)
(c.4) to[short,-o] ++(-0.5,0)
(c.1) node[below left] {\texttt{1}}
(c.2) node[below right] {\texttt{2}}
(c.3) node[above right] {\texttt{3}}
(c.4) node[above left] {\texttt{4}}
;
\end{circuitikz}
\end{LTXexample}
\subsubsection{Blocks customization}
You can change the scale of all the block elements by setting the key \texttt{blocks/scale} to something different from the default \texttt{1.0}.
With the option \texttt{>} you can draw an arrow to the input of the block diagram symbols.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) to[short,o-] ++(0.3,0)
to[lowpass,>] ++(2,0)
to[adc,>] ++(2,0)
to[short,-o] ++(0.3,0);
\end{circuitikz}
\end{LTXexample}
\paragraph{Multi ports}
Since inputs and outputs can vary, input arrows can be placed as nodes. Note that you have to rotate the arrow on your own:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[mixer] (m) {}
(m.1) to[short,-o] ++(-1,0)
(m.2) to[short,-o] ++(0,-1)
(m.3) to[short,-o] ++(1,0)
(m.1) node[inputarrow] {}
(m.2) node[inputarrow,rotate=90] {};
\end{circuitikz}
\end{LTXexample}
\paragraph{Labels and custom two-port boxes}
Some two-ports have the option to place a normal label (\texttt{l=}) and a inner label (\texttt{t=}).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{bipoles/amp/width=0.9}
\draw (0,0) to[amp,t=LNA,l_=$F{=}0.9\,$dB,o-o] ++(3,0);
\end{circuitikz}
\end{LTXexample}
\paragraph{Box option}
Some devices have the possibility to add a box around them. The inner symbol scales down to fit inside the box.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[mixer,box,anchor=east] (m) {}
to[amp,box,>,-o] ++(2.5,0)
(m.west) node[inputarrow] {} to[short,-o] ++(-0.8,0)
(m.south) node[inputarrow,rotate=90] {} --
++(0,-0.7) node[oscillator,box,anchor=north] {};
\end{circuitikz}
\end{LTXexample}
\paragraph{Dash optional parts}
To show that a device is optional, you can dash it. The inner symbol will be kept with solid lines.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[amp,l=\SI{10}{dB}] ++(2.5,0);
\draw[dashed] (2.5,0) to[lowpass,l=opt.] ++(2.5,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Transistors}
\begin{groupdesc}
\circuitdesc{nmos}{nmos}{}( G/180/0.2,D/0/0.2,S/0/0.2 )
\circuitdesc{pmos}{pmos}{}
\circuitdesc{hemt}{hemt}{}
\circuitdesc{npn}{npn}{}( B/180/0.2,C/0/0.2,E/0/0.2 )
\circuitdesc{pnp}{pnp}{}
\circuitdesc{npn,photo}{npn}{}( nobase/0/0.4 )
\circuitdesc{pnp,photo}{pnp}{}
\circuitdesc{nigbt}{nigbt}{}
\circuitdesc{pigbt}{pigbt}{}
\circuitdesc{Lnigbt}{Lnigbt}{}
\circuitdesc{Lpigbt}{Lpigbt}{}
\end{groupdesc}
For all transistors a body diode (or freewheeling diode) can automatically be drawn. Just use the global option bodydiode, or for single transistors, the tikz-option bodydiode:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[npn,bodydiode](npn){}++(2,0)node[pnp,bodydiode](npn){};
\draw (0,-2) node[nigbt,bodydiode](npn){}++(2,0)node[pigbt,bodydiode](npn){};
\draw (0,-4) node[nfet,bodydiode](npn){}++(2,0)node[pfet,bodydiode](npn){};
\end{circuitikz}
\end{LTXexample}
The Base/Gate connection of all transistors can be disabled by the options \textit{nogate} or \textit{nobase}, respectively. The Base/Gate anchors are floating, but there is an additional anchor "nogate"/"nobase", which can be used to point to the unconnected base:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (2,0) node[npn,nobase](npn){};
\draw (npn.E) node[below]{E};
\draw (npn.C) node[above]{C};
\draw (npn.B) node[circ]{} node[left]{B};
\draw[dashed,red,-latex] (1,0.5)--(npn.nobase);
\end{circuitikz}
\end{LTXexample}
If the option \texttt{arrowmos} is used (or after the command \verb!\ctikzset{tripoles/mos style/arrows}! is given), this is the output:
\begin{groupdesc}
\ctikzset{tripoles/mos style/arrows}
\circuitdesc{nmos}{nmos}{}
\circuitdesc{pmos}{pmos}{}
\end{groupdesc}
You can go back to the no-arrows mos with \texttt{noarrowmos} locally or with
\texttt{\textbackslash ctikzset\{tripoles/mos style/no arrows\}}.
To draw the PMOS circle non-solid, use the option \texttt{emptycircle} or the command
\\\verb!\ctikzset{tripoles/pmos style/emptycircle}!. To remove the dot completely (only useful if you have \texttt{arrowmos} enabled, otherwise there will be no difference between P-MOS and N-MOS), you can use the option \texttt{nocircle} or \verb|\ctikzset{tripoles/pmos style/nocircle}|.
\begin{groupdesc}
\circuitdesc{pmos,emptycircle}{pmos}{}
\circuitdesc{pmos,nocircle,arrowmos}{pmos}{}
\end{groupdesc}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[
info/.style={left=1cm, blue, text width=5em, align=right},]
\draw (0,1) node{pmos} (2,1) node{nmos};
\draw (0,0) node[info]{default} node[pmos]{} (2,0) node[nmos]{};
\ctikzset{tripoles/mos style/arrows}
\draw (0,-2) node[info]{arrows} node[pmos]{} (2,-2) node[nmos]{};
\ctikzset{tripoles/pmos style/emptycircle}
\draw (0,-4) node[info]{emptycircle} node[pmos]{} (2,-4) node[nmos]{};
\ctikzset{tripoles/pmos style/nocircle}
\draw (0,-6) node[info]{nocircle} node[pmos]{} (2,-6) node[nmos]{};
\ctikzset{tripoles/mos style/no arrows}
\draw (0,-8) node[info, red]{no circle, no arrows, DON'T do it}
node[pmos]{} (2,-8) node[nmos]{};
\end{circuitikz}\end{LTXexample}
\textsc{nfet}s and \textsc{pfet}s have been incorporated based on code provided by Clemens Helfmeier and Theodor Borsche. Use the package options \texttt{fetsolderdot}/\texttt{nofetsolderdot} to enable/disable solderdot at some fet-transistors. Additionally, the solderdot option can be enabled/disabled for single transistors with the option "solderdot" and "nosolderdot", respectm ively.
\begin{groupdesc}
\circuitdesc{nfet}{nfet}{}
\circuitdesc{nigfete}{nigfete}{}
\circuitdesc{nigfete,solderdot}{nigfete}{}
\circuitdesc{nigfetebulk}{nigfetebulk}{}
\circuitdesc{nigfetd}{nigfetd}{}
\circuitdesc{pfet}{pfet}{}
\circuitdesc{pigfete}{pigfete}{}
\circuitdesc{pigfetebulk}{pigfetebulk}{}
\circuitdesc{pigfetd}{pigfetd}{}
\end{groupdesc}
\textsc{njfet} and \textsc{pjfet} have been incorporated based on code provided by Danilo Piazzalunga:
\begin{groupdesc}
\circuitdesc{njfet}{njfet}{}
\circuitdesc{pjfet}{pjfet}{}
\end{groupdesc}
\textsc{isfet}
\begin{groupdesc}
\circuitdesc{isfet}{isfet}{}
\end{groupdesc}
\subsubsection{Transistors anchors}
For \textsc{nmos}, \textsc{pmos}, \textsc{nfet}, \textsc{nigfete}, \textsc{nigfetd}, \textsc{pfet}, \textsc{pigfete}, and \textsc{pigfetd} transistors one has \texttt{base}, \texttt{gate}, \texttt{source} and \texttt{drain} anchors (which can be abbreviated with \texttt{B}, \texttt{G}, \texttt{S} and \texttt{D}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[nmos] (mos) {}
(mos.gate) node[anchor=east] {G}
(mos.drain) node[anchor=south] {D}
(mos.source) node[anchor=north] {S}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pigfete] (pigfete) {}
(pigfete.G) node[anchor=east] {G}
(pigfete.D) node[anchor=north] {D}
(pigfete.S) node[anchor=south] {S}
(pigfete.bulk) node[anchor=west] {Bulk}
;\end{circuitikz}
\end{LTXexample}
Similarly \textsc{njfet} and \textsc{pjfet} have \texttt{gate}, \texttt{source} and \texttt{drain} anchors (which can be abbreviated with \texttt{G}, \texttt{S} and \texttt{D}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pjfet] (pjfet) {}
(pjfet.G) node[anchor=east] {G}
(pjfet.D) node[anchor=north] {D}
(pjfet.S) node[anchor=south] {S}
;\end{circuitikz}
\end{LTXexample}
For \textsc{npn}, \textsc{pnp}, \textsc{nigbt} and \textsc{pigbt} transistors, the anchors are \texttt{base}, \texttt{emitter} and \texttt{collector} anchors (which can be abbreviated with \texttt{B}, \texttt{E} and \texttt{C}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[npn] (npn) {}
(npn.base) node[anchor=east] {B}
(npn.collector) node[anchor=south] {C}
(npn.emitter) node[anchor=north] {E}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pigbt] (pigbt) {}
(pigbt.B) node[anchor=east] {B}
(pigbt.C) node[anchor=north] {C}
(pigbt.E) node[anchor=south] {E}
;\end{circuitikz}
\end{LTXexample}
Here is one composite example (please notice that the \texttt{xscale=-1} style would also reflect the label of the transistors, so here a new node is added and its text is used, instead of that of \texttt{pnp1}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pnp] (pnp2) {2}
(pnp2.B) node[pnp, xscale=-1, anchor=B] (pnp1) {}
(pnp1) node {1}
(pnp1.C) node[npn, anchor=C] (npn1) {}
(pnp2.C) node[npn, xscale=-1, anchor=C] (npn2) {}
(pnp1.E) -- (pnp2.E) (npn1.E) -- (npn2.E)
(pnp1.B) node[circ] {} |- (pnp2.C) node[circ] {}
;\end{circuitikz}
\end{LTXexample}
Notice that the text labels of transistors are somewhat buggy. It is better to se explicit anchors to set transistor's names.
Similarly, transistors like other components can be reflected vertically:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pigfete, yscale=-1] (pigfete) {}
(pigfete.bulk) node[anchor=west] {Bulk}
(pigfete.G) node[anchor=east] {G}
(pigfete.D) node[anchor=south] {D}
(pigfete.S) node[anchor=north] {S}
;\end{circuitikz}
\end{LTXexample}
\subsubsection{Transistor paths}\label{sec:transasbip}
For syntactical convenience transistors can be placed using the normal path notation used for bipoles. The transitor type can be specified by simply adding a ``T'' (for transistor) in front of the node name of the transistor. It will be placed with the base/gate orthogonal to the direction of the path:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[njfet] {1}
(-1,2) to[Tnjfet=2] (1,2)
to[Tnjfet=3, mirror] (3,2);
;\end{circuitikz}
\end{LTXexample}
Access to the gate and/or base nodes can be gained by naming the transistors with the \texttt{n} or \texttt{name} path style:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw[yscale=1.1, xscale=.8]
(2,4.5) -- (0,4.5) to[Tpmos, n=p1] (0,3)
to[Tnmos, n=n1] (0,1.5)
to[Tnmos, n=n2] (0,0) node[ground] {}
(2,4.5) to[Tpmos,n=p2] (2,3) to[short, -*] (0,3)
(p1.G) -- (n1.G) to[short, *-o] ($(n1.G)+(3,0)$)
(n2.G) ++(2,0) node[circ] {} -| (p2.G)
(n2.G) to[short, -o] ($(n2.G)+(3,0)$)
(0,3) to[short, -o] (-1,3)
;\end{circuitikz}
\end{LTXexample}
Transistor paths have the possibility to use the poles syntax (see section~\ref{sec:bipole-nodes}) but they have \textbf{no} voltage, current, flow, annotation options.
The \texttt{name} property is available also for bipoles; this is useful mostly for triac, potentiometer and thyristor (see~\ref{sec:othertrip}).
\subsubsection{Transistors customization}\label{sec:styling-transistors}
The default position of the arrows in transistors is somewhat in the middle of the terminal; if you prefer you can move them to the end with the style key \texttt{transistors/arrow pos=end} (the default value is \texttt{legacy}).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{transistors/arrow pos=end}
\draw (0,0) node[npn, ](npn){};
\draw (2,0) node[pnp, ](npn){};
\draw (0,-2) node[nmos, ](npn){};
\draw (2,-2) node[pmos, ](npn){};
\end{circuitikz}
\end{LTXexample}
You can change the scale of all the transistors by setting the key \texttt{transistors/scale} (default \texttt{1.0}).
The size of the arrows (if any) is controlled by the same parameters as \texttt{currarrow} (see section~\ref{sec:currarrow-size}) and the dots on P-type transistors (if any) are the same as the nodes/poles (see section~\ref{sec:bipole-nodes}).
\subsection{Electronic Tubes}
Electronic tubes, also known as vacuum tubes, control current flow between electrodes. They come in many different flavours.
\small{Contributed by J. op den Brouw (\texttt{J.E.J.opdenBrouw@hhs.nl}).}
\begin{groupdesc}
\circuitdesc*{diodetube}{Tube Diode}{}(anode/90/0.2, cathode/-90/0.2 )
\circuitdesc*{triode}{Triode}{}(anode/90/0.2, cathode/-90/0.2, control/180/0.2 )
\circuitdesc*{tetrode}{Tetrode}{}(anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/170/0.2 )
\circuitdesc*{pentode}{Pentode}{}(anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/180/0.2,suppressor/170/0.2 )
\end{groupdesc}
Some pentodes have the suppressor grid internally connected to the control grid, which saves a pin on the tube's housing.
\begin{groupdesc}
\circuitdesc*{pentode suppressor to cathode}{Pentode with suppressor grid connected to cathode}{}( anode/90/0.2, cathode/-90/0.2, control/190/0.2,screen/180/0.2 )
\end{groupdesc}
Note that the \verb|diodetube| is used as component name to avoid clashes with the semiconductor diode.
Normally, the filament is not drawn. If you want a filament, put the \verb|filament| option in the node description:
\begin{groupdesc}
\circuitdesc*{diodetube,filament}{Tube Diode}{}(anode/90/0.2, filament 1/-135/0.2, filament 2/-45/0.2 )
\end{groupdesc}
Sometimes, you don't want the cathode to be drawn (but you do want the filament). Use the \verb|nocathode| option in the node description:
\begin{groupdesc}
\circuitdesc*{diodetube,filament,nocathode}{Tube Diode}{}(anode/90/0.2 )
\end{groupdesc}
If you want a full cathode to be drawn, use the \verb|fullcathode| option in the node description. You can then use the anchors \verb|cathode 1| and \verb|cathode 2|.
\begin{groupdesc}
\circuitdesc*{diodetube,fullcathode}{Tube Diode}{}(anode/90/0.2, cathode 1/-135/0.2, cathode 2/-45/0.2 )
\end{groupdesc}
\subsubsection{Tubes customization}
The tubes can be scaled using the key \texttt{tubes/scale}, default \texttt{1.0}. In addition, they are
fully configurable, and the attributes are described below:
\begin{tabular}{l | l | l}
Key & Default value & Description\\
\hline
\verb|tubes/scale| & \verb|1| & scale factor \\
\verb|tubes/width| & \verb|1| & relative width \\
\verb|tubes/height| & \verb|1.4| & relative height \\
\verb|tubes/tube radius| & \verb|0.40| & radius of tube circle \\
\verb|tubes/anode distance| & \verb|0.40| & distance from center \\
\verb|tubes/anode width| & \verb|0.40| & width of an anode/plate \\
\verb|tubes/grid protrusion| & \verb|0.25| & distance from center \\
\verb|tubes/grid dashes| & \verb|5| & number of grid dashes \\
\verb|tubes/grid separation| & \verb|0.2| & separation between grids \\
\verb|tubes/grid shift| & \verb|0.0| & y shift of grids from center \\
\verb|tubes/cathode distance| & \verb|0.40| & distance from grid \\
\verb|tubes/cathode width| & \verb|0.40| & width of a cathode \\
\verb|tubes/cathode corners| & \verb|0.06| & corners of the cathode wire \\
\verb|tubes/cathode right extend| & \verb|0.075| & extension at the right side \\
\verb|tubes/filament distance| & \verb|0.1| & distance from cathode \\
\verb|tubes/filament angle| & \verb|15| & angle from the centerpoint \\
\end{tabular}
Conventionally, the model of the tube is indicated at the \verb|east| anchor:
\begin{LTXexample}[varwidth]
\ctikzset{tubes/width=1.4}
\ctikzset{tubes/height=1}
\begin{circuitikz}
\draw (0,0) node[triode] (Tri) {};
\draw (Tri.east) node[right] {12AX7};
\end{circuitikz}
\end{LTXexample}
Example triode amplifier:
\begin{lstlisting}
\begin{circuitikz}
\draw (0,0) node (start) {}
to[sV=$V_i$] ++(0,2+\ctikzvalof{tubes/height})
to[C=$C_i$] ++(2,0) node (Rg) {}
to[R=$R_g$] (Rg |- start)
(Rg) to[short,*-] ++(1,0)
node[triode,anchor=control] (Tri) {} ++(2,0)
(Tri.cathode) to[R=$R_c$,-*] (Tri.cathode |- start)
(Tri.anode) to [R=$R_a$] ++(0,2)
to [short] ++(3.5,0) node(Vatop) {}
to [V<=$V_a$] (Vatop |- start)
to [short] (start)
(Tri.anode) ++(0,0.2) to[C=$C_o$,*-o] ++(2,0)
(Tri.cathode) ++(0,-0.2) to[short,*-] ++(1.5,0) node(Cctop) {}
to[C=$C_c$,-*] (start -| Cctop)
;
\draw[red,thin,dashed] (Tri.north west) rectangle (Tri.south east);
\draw (Tri.east) node[right] {12AX7};
\end{circuitikz}
\end{lstlisting}
\begin{circuitikz}
\draw (0,0) node (start) {}
to[sV=$V_i$] ++(0,2+\ctikzvalof{tubes/height})
to[C=$C_i$] ++(2,0) node (Rg) {}
to[R=$R_g$] (Rg |- start)
(Rg) to[short,*-] ++(1,0)
node[triode,anchor=control] (Tri) {} ++(2,0)
(Tri.cathode) to[R=$R_c$,-*] (Tri.cathode |- start)
(Tri.anode) to [R=$R_a$] ++(0,2)
to [short] ++(3.5,0) node(Vatop) {}
to [V<=$V_a$] (Vatop |- start)
to [short] (start)
(Tri.anode) ++(0,0.2) to[C=$C_o$,*-o] ++(2,0)
(Tri.cathode) ++(0,-0.2) to[short,*-] ++(1.5,0) node(Cctop) {}
to[C=$C_c$,-*] (start -| Cctop)
;
\draw[red,thin,dashed] (Tri.north west) rectangle (Tri.south east);
\draw (Tri.east) node[right] {12AX7};
\end{circuitikz}
The \texttt{magnetron} shape will also scale with \texttt{tubes/scale}.
\begin{groupdesc}
\circuitdesc*{magnetron}{Magnetron}{}( anode/-90/0.2, cathode1/135/0.2,
cathode2/45/0.2, left/180/0.2, right/0/0.2, top/90/0.4 )
\end{groupdesc}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,-2)node[rground](gnd){} to[voltage source,v<={HV}]++(0,3)--++(1,0)to[V,n=DC]++(2,0);
\draw (2,-1) node[magnetron,scale=1](magn){};
\draw (DC.left)++(-0.2,0)to [short,*-] ++(0,-1) to [short] (magn.cathode1);
\draw (DC.right)++(0.2,0)to [short,*-] ++(0,-1) to [short] (magn.cathode2);
\draw (magn.anode) to [short] (magn.anode|-gnd) node[rground]{};
\draw (magn.cathode1)node[above]{$1$};
\draw (magn.cathode2)node[above]{$2$};
\draw[->](magn.east) --++(1,0)node[right]{$RF_{out}$};
\end{circuitikz}
\end{LTXexample}
\subsection{RF components}\label{sec:RF}
For the RF components, similarly to the grounds and supply rails, the \texttt{center} anchor is put on the connecting point of the symbol, so that you can use them directly in a \texttt{path} specification.
Notes that in the transmission and receiving antennas, the ``waves'' are outside the geographical anchors.
\begin{groupdesc}
\circuitdesc*{bareantenna}{Bare Antenna}{A}( top/90/0.1, bottom/180/0.3, left/180/0.3, right/45/0.3, center/0/0.3 )
\circuitdesc*{bareTXantenna}{Bare TX Antenna}{Tx}( top/90/0.1, center/180/0.3, waves/90/0.3 )
\circuitdesc*{bareRXantenna}{Bare RX Antenna}{Rx}( top/90/0.1, center/0/0.3, waves/90/0.3 )
\circuitdesc{waves}{Waves}{}( north/90/0.4, north east/45/0.4, east/-45/0.4, south east/-45/0.4,
south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4,
left/135/0.2, top/45/0.2, right/45/0.2, bottom/-45/0.2 )
\circuitdescbip*{mstline}{Microstrip transmission line\footnotemark}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\circuitdesc*{mslstub}{Microstrip linear stub}{text}(left/135/0.2, right/45/0.2, center/-45/0.3)
\circuitdesc*{msport}{Microstrip port}{T}(left/135/0.2, right/45/0.2, center/-45/0.3)
\circuitdesc*{msrstub}{Microstrip radial stub}{}(left/135/0.2, right/45/0.2, center/-45/0.3)
\footnotetext{This four components were suggested by \texttt{@tcpluess} on GitHub}
\circuitdesc{antenna}{Legacy antenna (with tails)}{}( center/0/0.3 )
\circuitdesc{rxantenna}{Legacy receiving antenna (with tails)}{}
\circuitdesc{txantenna}{Legacy transmitting antenna (with tails)}{}
\circuitdesc*{tlinestub}{Transmission line stub}{}
\circuitdescbip*[tline]{TL}{Transmission line}{transmission line, tline}
\circuitdesc{match}{match}{}
\end{groupdesc}
\subsubsection{RF elements customization}
The RF elements can be scaled using the key \texttt{RF/scale}, default \texttt{1.0}.
\subsubsection{Microstrip customization}
The microstrip linear components' (\texttt{mstline}, \texttt{mslstub}, \texttt{msport}) heights can be changed by setting the parameter \texttt{bipoles/mstline/height} (for the three of them, default 0.3). The widths are specified in \texttt{bipoles/mstline/width} for the first two and by \texttt{monopoles/msport/width} for the port (defaults: 1.2, 0.5).
For the length parameter of the transmission line there is a shortcut in the form of the direct parameter \texttt{mstlinelen}.
\begin{LTXexample}[varwidth=true, pos=t]
\begin{circuitikz}
\draw (0,0) node[msport, right, xscale=-1]{}
to[mstline, -o] ++(3,0) coordinate(there)
to[mstline, mstlinelen=2, l=longer, o-*] ++(4,0)
coordinate(here) -- ++(0.5,0) node[mslstub, fill=yellow]{stub}
(here) -- ++(0,0.5) node[mslstub, rotate=90, mstlinelen=0.5]{short};
\draw (there) to[short, o-] ++(0, 0.5) node[msrstub]{};
\draw (here) -- ++(0, -0.5) node[msrstub, yscale=-1]{};
\end{circuitikz}
\end{LTXexample}
\subsection{Electro-Mechanical Devices}
The internal part of the motor and generator are, by default, filled white (to avoid compatibility problems with older versions of the package).
\begin{groupdesc}
\circuitdesc*{elmech}{Motor}{M}(bottom/-90/0.2, left/180/0.2, right/0/0.2, top/90/0.4, 45/45/0.2)
\circuitdesc*{elmech}{Generator}{G}(block down right/0/0.2, block north east/0/0.2)
\end{groupdesc}
\subsubsection{Electro-Mechanical Devices anchors}
Apart from the standard geographical anchors, \texttt{elmech} has the border anchors (situated on the inner circle) and the following anchors on the ``block'':
\begin{quote}
\begin{circuitikz}
\def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, }]#3:#1}](#1){}}
\node [elmech](T) at(0,0) {A};
\foreach \a/\d/\t in {block north east/0.2/45, block south east/0.2/-45,
block south west/0.2/-135, block north west/0.1/135, 150/0.1/150,
180/0.1/180, 210/0.1/210, 60/0.4/-15, -60/0.4/15}
\path (T.\a) \coordx(\a)[\d:\t]{red};
\node [elmech](T) at(6,0) {B};
\foreach \a/\d/\t in {block up right/0.2/45, block down right/0.2/-45,
block down left/0.2/-135, block up left/0.1/135, north/0.3/90,
south/0.3/-90, east/0.3/0, west/0.3/180}
\path (T.\a) \coordx(\a)[\d:\t]{red};
\end{circuitikz}
\end{quote}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (2,0) node[elmech](motor){M};
\draw (motor.north) |-(0,2) to [R] ++(0,-2) to[dcvsource]++(0,-2) -| (motor.bottom);
\draw[thick,->>](motor.right)--++(1,0)node[midway,above]{$\omega$};
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (2,0) node[elmech](motor){};
\draw (motor.north) |-(0,2) to [R] ++(0,-2) to[dcvsource]++(0,-2) -| (motor.bottom);
\draw[thick,->>](motor.center)--++(1.5,0)node[midway,above]{$\omega$};
\end{circuitikz}
\end{LTXexample}
The symbols can also be used along a path, using the transistor-path-syntax(\texttt{T} in front of the shape name, see section \ref{sec:transasbip}). Don't forget to use parameter $n$ to name the node and get access to the anchors:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to [Telmech=M,n=motor] ++(0,-3) to [Telmech=M] ++(3,0) to [Telmech=G,n=generator] ++(0,3) to [R] (0,0);
\draw[thick,->>](motor.left)--(generator.left)node[midway,above]{$\omega$};
\end{circuitikz}
\end{LTXexample}
\subsection{Double bipoles (transformers)}
Transformers automatically use the inductor shape currently selected. These are the three possibilities:
\begin{groupdesc}
\ctikzset{inductor=cute}
\circuitdesc{transformer}{Transformer (cute inductor)}{}( A1/180/0.1,
A2/180/0.1, B1/0/0.1, B2/0/0.1,
inner dot A1/-135/0.2, inner dot A2/135/0.2, inner dot B1/-45/0.1,
inner dot B2/45/0.1 )
\ctikzset{inductor=american}
\circuitdesc{transformer}{Transformer (american inductor)}{}( %
outer dot A1/180/0.2, outer dot A2/180/0.2,
outer dot B1/0/0.2, outer dot B2/0/0.2 )
\ctikzset{inductor=european}
\circuitdesc{transformer}{Transformer (european inductor)}{}
\circuitdesc*{gyrator}{Gyrator}{}
\end{groupdesc}
Transformers with core are also available:
\begin{groupdesc}
\ctikzset{inductor=cute}
\circuitdesc{transformer core}{Transformer core (cute inductor)}{}
\ctikzset{inductor=american}
\circuitdesc{transformer core}{Transformer core (american inductor)}{}
\ctikzset{inductor=european}
\circuitdesc{transformer core}{Transformer core (european inductor)}{}
\ctikzset{inductor=cute} % reset default
\end{groupdesc}
\subsubsection{Double dipoles anchors}
All the double bipoles/quadrupoles have the four anchors, two for each port.
The first port, to the left, is port \texttt{A}, having the anchors \texttt{A1} (up) and \texttt{A2} (down); same for port \texttt{B}.
They also expose the \texttt{base} anchor, for labelling, and anchors for setting dots or signs to specify polarity.
The set of anchors, to which the standard ``geographical'' \texttt{north}, \texttt{north east}, etc. is here:
\begin{quote}
\begin{circuitikz}[cute inductors,
]
\def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, overlay,}]#3:#1}](#1){}}
\foreach \comp/\pos/\case in {%
transformer/0/0%
,transformer core/4/1%
,gyrator/8/2%
}{
\draw (\pos, 0) node[\comp](T){};
\ifcase\case
\foreach \a/\d/\t in {inner dot A1/0.2/75, inner dot A2/0.2/-75, inner dot B1/0.1/-45, inner dot B2/0.1/45}
\path (T.\a) \coordx(\a)[\d:\t]{red};
\or
\foreach \a/\d/\t in {outer dot A1/0.2/75, outer dot A2/0.2/-75, outer dot B1/0.2/-45, outer dot B2/0.2/45}
\path (T.\a) \coordx(\a)[\d:\t]{blue};
\or
\foreach \a/\t in {A1/120, A2/-120, B1/120, B2/-120, base/-90}
\path (T.\a) \coordx(\a)[0.2:\t]{green!50!black};
\fi
}
\end{circuitikz}
\end{quote}
Also, the standard ``geographical'' \texttt{north}, \texttt{north east}, etc. are defined.
A couple of examples follow:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[transformer] (T) {}
(T.A1) node[anchor=east] {A1}
(T.A2) node[anchor=east] {A2}
(T.B1) node[anchor=west] {B1}
(T.B2) node[anchor=west] {B2}
(T.base) node{K}
(T.inner dot A1) node[circ]{}
(T.inner dot B2) node[circ]{}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[gyrator] (G) {}
(G.A1) node[anchor=east] {A1}
(G.A2) node[anchor=east] {A2}
(G.B1) node[anchor=west] {B1}
(G.B2) node[anchor=west] {B2}
(G.base) node{K}
;\end{circuitikz}
\end{LTXexample}
Moreover, you can access the two internal coils (inductances); if your transformer node is called \texttt{T}, they are named \texttt{T-L1} and \texttt{T-L2}. Notice that the two inductors are rotated (by -90 degrees the first, +90 degrees the second) so you have to be careful with the anchors. Also, the \texttt{midtap} anchor of the inductors can be on the external or internal side depending on the numbers of coils. Finally, the anchors \texttt{L1.a} and \texttt{L1.b} are marking the start and end of the coils.
\begin{quote}
\begin{circuitikz}[american inductors,
]
\def\coordx(#1)[#2:#3]#4{node[circle, #4, draw, inner sep=1pt,pin={[#4, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=#2cm, pin edge={#4, overlay,}]#3:#1}](){}}
\draw (-2,0) (0, 0) node[transformer](T){};
\foreach \a/\d/\t in {L1.midtap/0.2/180, L1.south west/0.2/180, L1.south east/0.2/180,
L2.south/0.2/0, L2.south west/0.2/0, L2.south east/0.2/0}
\path (T-\a) \coordx(T-\a)[\d:\t]{red};
\ctikzset{cute inductors}
\draw (4, 0) node[transformer](T){};
\foreach \a/\d/\t in {L1.a/0.2/-120, L1.b/0.2/120,
L2.midtap/0.5/0, L2.south west/0.2/0, L2.south east/0.2/0}
\path (T-\a) \coordx(T-\a)[\d:\t]{blue};
\node[font=\small\ttfamily,above] at (T.north) {inductors/coils=5};
\draw (8, 0) node[transformer, circuitikz/inductors/coils=6](T){};
\foreach \a/\d/\t in {L2.a/0.2/120, L2.b/0.2/-120,
L2.midtap/0.2/0, L2.south west/0.2/0, L2.south east/0.2/0}
\path (T-\a) \coordx(T-\a)[\d:\t]{red};
\node[font=\small\ttfamily,above] at (T.north) {inductors/coils=6};
\end{circuitikz}
\end{quote}
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{circuitikz}
\draw (0,0) node[ground](GND){} to [sV] ++(0,2) -- ++(1,0)
node[transformer, circuitikz/inductors/coils=6,
anchor=A1](T){};
\draw (T.A2) to[short, -*] (T.A2-|GND);
\draw (T-L2.midtap) to[short, *-o] (T.B1 |- T-L2.midtap);
\node [ocirc] at (T.B1){}; \node [ocirc] at (T.B2){};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Double dipoles customization}
Transformers are in the \texttt{inductors} class (also the gyrator\dots), so they scale with the key \texttt{inductors/scale}.
You can change the aspect of a quadpole using the corresponding parameters \texttt{quadpoles/*/width} and \texttt{quadpoles/*/heigth} (substitute the star for \texttt{transformer}, \texttt{transformer core} or \texttt{gyrator}; default value is \texttt{1.5} for all). You have to be careful to not choose value that overlaps the components!
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{quadpoles/transformer/width=1,
quadpoles/transformer/height=2}
\draw (0,0) node[transformer] (T) {}
(T.base) node{K}
(T.inner dot A1) node[circ]{}
(T.inner dot B2) node[circ]{};
\end{circuitikz}
\end{LTXexample}
Transformers also inherits the \texttt{inductors/scale} (see~\ref{sec:tweak-l}) and similar parameters. It's your responsibility to set the aforementioned parameters if you change the scale or width of inductors.
Another very useful parameter is \texttt{quadpoles/*/inner} (default \texttt{0.4}) that determine which part of the component is the ``vertical'' one. So, setting that parameter to 1 will eliminate the horizontal part of the component (obviously, to maintain the general aspect ratio you need to change the width also):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[transformer] (T) {}
(T.A1) node[anchor=east] {A1}
(T.A2) node[anchor=east] {A2}
(T.B1) node[anchor=west] {B1}
(T.B2) node[anchor=west] {B2}
(T.base) node{K} ;
\ctikzset{quadpoles/transformer/inner=1, quadpoles/transformer/width=0.6}
\draw (0,-3) node[transformer] (P) {}
(P.base) node{T}
(P.inner dot A2) node[ocirc]{}
(P.inner dot B2) node[ocirc]{};
\end{circuitikz}
\end{LTXexample}
This can be useful if you want to put seamlessly something in series with either side of the component; for simplicity, you have a style setting \texttt{quadpoles style} to toggle between the standard shape of double bipoles (called \texttt{inward}, default) and the one without horizontal leads (called \texttt{inline}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{inductor=cute, quadpoles style=inline}
\draw
(0,0) to[R] ++(0,-2)
node[transformer, anchor=A1](T){}
(T.A2) node[ground](GND){}
(T.inner dot A1) node[font=\small\boldmath]{$\oplus$}
(T.inner dot B2) node[]{$+$}
(T.B1) node[above, ocirc]{}
(T.B2) -- (GND);
\end{circuitikz}
\end{LTXexample}
\subsection{Amplifiers}
\begin{groupdesc}
\circuitdesc*{op amp}{Operational amplifier}{}( +/180/0.2, -/180/0.2, out/0/0.2, up/90/0.2, down/-90/0.2 )
\circuitdesc*{en amp}{Operational amplifier compliant to DIN/EN 60617 standard}{}
\circuitdesc*{fd op amp}{Fully differential operational amplifier\footnotemark}{}( out +/0/0.2, out -/0/0.2 )
\footnotetext{Contributed by Kristofer M. Monisit.}
\circuitdesc*{gm amp}{transconductance amplifier}{}
\circuitdesc*{inst amp}{plain instrumentation amplifier}{}( up/90/0.2, down/-90/0.2, refv up/45/0.2, refv down/-45/0.2 )
\circuitdesc*{fd inst amp}{Fully differential instrumentation amplifier}{}
\circuitdesc*{inst amp ra}{instrumentation amplifier with amplification resistance terminals}{}( ra+/180/0.1, ra-/180/0.1 )
\circuitdesc*{plain amp}{Plain amplifier}{}(+/180/0.2, -/180/0.2, out/0/0.2, up/90/0.2)
\circuitdesc*{buffer}{Buffer}{}(in/180/0.2, out/0/0.2)
\end{groupdesc}
\subsubsection{Amplifiers anchors}
The op amp defines the inverting input (\texttt{-}), the non-inverting input (\texttt{+}) and the output (\texttt{out}) anchors:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[op amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {$v_o$}
(opamp.up) --++(0,0.5) node[vcc]{5\,\textnormal{V}}
(opamp.down) --++(0,-0.5) node[vee]{-5\,\textnormal{V}}
;\end{circuitikz}
\end{LTXexample}
There are also two more anchors defined, \texttt{up} and \texttt{down}, for the power supplies:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[op amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {$v_o$}
(opamp.down) node[ground] {}
(opamp.up) ++ (0,.5) node[above] {\SI{12}{\volt}}
-- (opamp.up)
;\end{circuitikz}
\end{LTXexample}
The fully differential op amp defines two outputs:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[fd op amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out +) node[right] {out +}
(opamp.out -) node[right] {out -}
(opamp.down) node[ground] {}
;\end{circuitikz}
\end{LTXexample}
The instrumentation amplifier inst amp defines also references (normally you use the "down", unless you are flipping the component):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[inst amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {out}
(opamp.up) node[vcc]{}
(opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
;\end{circuitikz}
\end{LTXexample}
The fully diffential instrumentation amplifier inst amp defines two outputs:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[fd inst amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out +) node[right] {out +}
(opamp.out -) node[right] {out -}
(opamp.up) node[vcc]{}
(opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
;\end{circuitikz}
\end{LTXexample}
The instrumentation amplifier with resistance terminals (\texttt{inst amp ra}) defines also terminals to add an amplification resistor:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[inst amp ra] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {out}
(opamp.up) node[vcc]{}
(opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
(opamp.ra-) to[R] (opamp.ra+)
;\end{circuitikz}
\end{LTXexample}
\subsubsection{Amplifiers customization}
You can scale the amplifiers using the key \texttt{amplifiers/scale} and setting it to something different from \texttt{1.0}. The font used for symbols will not scale, so it's your responsibility to change it if the need arises.
All these amplifier have the possibility to flip input and output (if needed) polarity. You can change polarity of the input with the
\texttt{noinv input down} (default) or \texttt{noinv input up} key; and the output with \texttt{noinv output up} (default) or \texttt{noinv output down} key:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[fd inst amp,
noinv input up,
noinv output down] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out +) node[right] {out +}
(opamp.out -) node[right] {out -}
(opamp.up) node[vcc]{}
(opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
;\end{circuitikz}
\end{LTXexample}
When you use the \texttt{noinv input/output ...} keys the anchors (\texttt{+}, \texttt{-}, \texttt{out +}, \texttt{out -}) will change with the effective position of the terminals. You have also the anchors \texttt{in up}, \texttt{in down}, \texttt{out up}, \texttt{out down} that will not change with the positive or negative sign.
\paragraph{European-style amplifier customization}
Thanks to the suggestions from David Rouvel (\email{david.rouvel@iphc.cnrs.fr}) there are several possible customization for the European-style amplifiers.
Since 0.9.0, the default appearance of the symbol has changed to be more in line with the standard; notice that to have a bigger triangle by default we should require more packages, and I fear {Con\TeX t} compatibility; but see later on how to change it. Notice that the font used for the symbol is defined in \texttt{tripoles/en amp/font2} and that the font used for the \texttt{+} and \texttt{-} symbols is \texttt{tripoles/en amp/font}.
You can change the distances of the inputs, using \texttt{tripoles/en amp/input height} (default 0.3):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{tripoles/en amp/input height=0.45}
\draw (0,0)node[en amp](E){}
(E.out) node[right] {$v_{\mathrm{out}}$}
(E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$};
\end{circuitikz}
\end{LTXexample}
and of course the key \texttt{noinv input up} is fully functional:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{tripoles/en amp/input height=0.45}
\draw (0,0)node[en amp, noinv input up](E){}
(E.out) node[right] {$v_{\mathrm{out}}$}
(E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$};
\end{circuitikz}
\end{LTXexample}
To flip the amplifier in the horizontal direction, you can use \texttt{xscale=-1} as usual:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{tripoles/en amp/input height=0.45}
\draw (0,0)node[en amp, xscale=-1, noinv input up](E){}
(E.out) node[left] {$v_{\mathrm{out}}$}
(E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$};
\end{circuitikz}
\end{LTXexample}
Notice that the label is fully mirrored, so check below for the generic way to change this.
You can use the new key \texttt{en amp text A} to change the infinity symbol with an A:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0)node[en amp, en amp text A](E){}
(E.out) node[right] {$v_{\mathrm{out}}$}
(E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
\end{LTXexample}
And if you want, you can completely change the text using the key \texttt{en amp text={}}, which by default is \verb|$\mathstrut{\triangleright}\,{\infty}$|:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0)node[en amp, en amp text={%
${\triangleright}$ \small 200}](E){}
(E.out) node[right] {$v_{\mathrm{out}}$}
(E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
\end{LTXexample}
Notice two things here: the first, that \verb|\triangleright| is enclosed in braces to remove the default spacing it has as a binary operator, and that \texttt{en amp text A} is simply a shortcut for
\begin{lstlisting}
en amp text={$\mathstrut{\triangleright}\,\mathrm{A}$}
\end{lstlisting}
To combine flipping with a generic label you just do:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0)node[en amp, xscale=-1, en amp text A](E){}
(E.out) node[left] {$v_{\mathrm{out}}$}
(E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
\end{LTXexample}
But notice that the ``A'' is also flipped by the \texttt{xscale} parameter. So the solution in this case is to use \texttt{scalebox}, like this:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0)node[en amp, xscale=-1, en amp text={%
${\triangleright}$ \scalebox{-1}[1]{\small 200}}](E){}
(E.out) node[left] {$v_{\mathrm{out}}$}
(E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
\end{LTXexample}
\subsection{Switches and buttons}
Switches and button come in to-style (the simple ones and the pushbuttons), and as nodes.
The switches can be scaled with the key \texttt{switches/scale} (default \texttt{1.0}). Notice that scaling the switches will not scale the poles, which are controlled with their own parameters (see section~\ref{sec:terminals}).
\subsubsection{Traditional switches}
These are all of the to-style type:
\begin{groupdesc}
\circuitdescbip[cspst]{switch}{Switch}{spst}
\circuitdescbip[cspst]{closing switch}{Closing switch}{cspst}
\circuitdescbip[ospst]{opening switch}{Opening switch}{ospst}
\circuitdescbip[nos]{normal open switch}{Normally open switch}{nos}
\circuitdescbip[ncs]{normal closed switch}{Normally closed switch}{ncs}
\circuitdescbip[pushbutton]{push button}{Normally open push button}{normally open push button, nopb}
\circuitdescbip[ncpushbutton]{normally closed push button}{Normally closed push button}{ncpb}
\circuitdescbip[toggleswitch]{toggle switch}{Toggle switch}{}
\end{groupdesc}
while this is a node-style component:
\begin{groupdesc}
\circuitdesc{spdt}{spdt}{}( in/180/0.2, out 1/0/0.2, out 2/0/0.2 )
\end{groupdesc}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) node[spdt] (Sw) {}
(Sw.in) node[left] {in}
(Sw.out 1) node[right] {out 1}
(Sw.out 2) node[right] {out 2}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) to[C] (1,0) to[toggle switch , n=Sw] (2.5,0)
-- (2.5,-1) to[battery1] (1.5,-1) to[R] (0,-1) -| (0,0)
(Sw.out 2) -| (2.5, 1) to[R] (0,1) -- (0,0)
;\end{circuitikz}
\end{LTXexample}
\subsubsection{Cute switches}
These switches have been introduced after version 0.9.0, and they come in also in to-style and in node-style, but they are size-matched so that they can be used together in a seamless way.
The path element (to-style) are:
\begin{groupdesc}
\circuitdescbip[cuteclosedswitch]{cute closed switch}{Cute closed switch}{ccsw}(mid/90/0.2, in/-135/0.2, out/-45/0.2)
\circuitdescbip[cuteopenswitch]{cute open switch}{Cute open switch}{cosw}(out/45/0.2)[out.s/-90/0.2]
\circuitdescbip[cuteclosingswitch]{cute closing switch}{Cute closing switch}{ccgsw}
\circuitdescbip[cuteopeningswitch]{cute opening switch}{Cute opening switch}{cogsw}
\end{groupdesc}
while the node-style components are the single-pole, double-throw (\texttt{spdt}) ones:
\begin{groupdesc}
\circuitdesc{cute spdt up}{Cute spdt up}{}( in/180/0.2, out 1/0/0.2, out 2/0/0.2 , mid/0/0.4)
\circuitdesc{cute spdt mid}{Cute spdt mid}{}
\circuitdesc{cute spdt down}{Cute spdt down}{}(mid/0/0.4)
\circuitdesc{cute spdt up arrow}{Cute spdt up with arrow}{}
\circuitdesc{cute spdt mid arrow}{Cute spdt mid with arrow}{}
\circuitdesc{cute spdt down arrow}{Cute spdt down with arrow}{}
\end{groupdesc}
\paragraph{Cute switches anchors}
The nodes-style switches have the following anchors:
\bigskip
\begin{circuitikz}
\def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
\path (0,-1) -- (3,1); %bbox
\draw (0, 0) node[spdt](S){};
\foreach \a/\b in {center/0, in/-135, out 1/45, out 2/-45}
\path (S.\a) \coorda(\a)<\b>;
\draw (3, 0) node[cute spdt up arrow](CS){};
\foreach \a/\b in {center/0, in/-135, out 1/45, out 2/-45, mid/135}
\path (CS.\a) \coorda(\a)<\b>;
\draw (6, 0) node[cute spdt up arrow](CS2){};
\foreach \a/\b in {cin/-135, cout 1/45, cout 2/-45}
\path (CS2.\a) \coorda(\a)<\b>;
\end{circuitikz}
Please notice the position of the normal anchors at the border of the \texttt{ocirc} shape for the cute switches; they are thought to be compatible with an horizontal wire going out.
Additionaly, you have the \texttt{cin}, \texttt{cout 1} y \texttt{cout 2} which are anchors on the center of the contacts.
For more complex situations, the contact nodes are available\footnote{Thanks to \texttt{@marmot} on \href{https://tex.stackexchange.com/a/492599/38080}{tex.stackexchange.com}.} using the syntax \emph{name of the node}\texttt{-in}, \dots\texttt{-out 1} and \dots\texttt{-out 2}, with all their anchors.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[cute spdt up] (S1) {}
(S1.in) node[left] {in}
(S1.out 1) node[right] {out 1};
\draw (0,-2) node[cute spdt up,
/tikz/circuitikz/bipoles/cuteswitch/height=0.8] (S2) {}
(S2.in) node[left] {in}
(S2.out 2) node[right] {out 2};
\draw [red] (S1-in.s) -- (S2-in.n);
\draw [blue] (S1-out 2.s) -- (S2-out 1.n);
\end{circuitikz}
\end{LTXexample}
The \texttt{mid} anchor in the cute switches (both path- and node-style) can be used to combine switches to get more complex configurations:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,1.4) node[cute spdt up](S1){};
\draw (0,0) node[cute spdt up](S2){};
\draw (0,-1) node[cuteclosedswitchshape, yscale=-1](S3){};
\draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
\end{circuitikz}
\end{LTXexample}
\paragraph{Cute switches customization}
You can use the key \texttt{bipoles/cuteswitch/thickness} to decide the thickness of the switch lever.
The units are the diameter of the \texttt{ocirc} connector, and the default is \texttt{1}.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{bipoles/cuteswitch/thickness=0.5}
\draw (0,1.4) node[cute spdt up](S1){};
\draw (0,0) node[cute spdt up](S2){};
\draw (0,-1) node[cuteclosedswitchshape, yscale=-1](S3){};
\draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
\end{circuitikz}
\end{LTXexample}
Finally, the switches are normally drawn using the \texttt{ocirc} shape, but you can change it, as in the following example, with the key \texttt{bipoles/cuteswitch/shape}. Be careful that the shape is used with its defaults (which can lead to strange results), and that the standard anchors will be correct only for \texttt{circ} and \texttt{ocirc} shapes, so you have to use the internal node syntax to connect it.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\begin{scope}
\ctikzset{bipoles/cuteswitch/thickness=0.5,
bipoles/cuteswitch/shape=circ}
\draw (0,2) node[cute spdt up](S1){};
\ctikzset{bipoles/cuteswitch/thickness=0.25,
bipoles/cuteswitch/shape=emptyshape}
\draw (0,0) node[cute spdt up](S2){};
\draw (S2.cin) node[draw, inner sep=2pt]{};
\draw (S2.cout 1) node[draw, inner sep=2pt]{};
\draw (S2.cout 2) node[draw=red, inner sep=2pt]{};
\end{scope}
\draw (0,-2) node[cuteclosedswitchshape, yscale=-1](S3){};
\draw [densely dashed] (S1.mid)--(S2.mid)--(S3.mid);
\end{circuitikz}
\end{LTXexample}
\subsubsection{Rotary switches}
Rotary switches are a kind of generic multipole switches; they are implemented as a strongly customizable element (and a couple of styles to simplify its usage). The basic element is the following one, and it has the same basic anchors of the cute switches, included the access to internal nodes (shown in blue here).
\begin{groupdesc}
\circuitdesc{rotaryswitch}{Rotary switch}{}(in/-180/0.2, cin/145/0.2, center/-90/0.2, mid/0/0.4, out 1/0/0.2,
cout 1/180/0.2)[out 1.n/90/0.2, out 4.w/0/0.3]
\end{groupdesc}
Notice that the name of the shape is \texttt{rotaryswitch}, no spaces.
The default rotary switch component has 5 channels (this is set in the parameter \texttt{multipoles/rotary/channels}), spanning form \SI{-60}{\degree} to \SI{60}{\degree} (parameter \texttt{multipoles/rotary/angle}) and with the wiper at \SI{20}{\degree} (parameter \texttt{multipoles/rotary/wiper}).
Moreover, there are by default no arrows on the wiper; if needed, you can change this default setting the parameter \texttt{multipoles/rotary/arrow} which can assume the values \texttt{none}, \texttt{cw} (clockwise), \texttt{ccw} (counterclockwise) or \texttt{both}.
To simplify the usage of the component, a series of styles are defined: \texttt{rotary switch=\textsl{<channels>} in \textsl{<angle>} wiper \textsl{<wiper angle>}} (notice the space in the name of the style!). Using \texttt{rotary switch} without parameters will generate a default switch.
To add arrows, you can use the styles \texttt{rotary switch -} (no arrow, whatever the default), \texttt{rotary switch <-} (counterclockwise arrow), \texttt{rotary switch ->} (clockwise) and \texttt{rotary switch <->} (both).
Notice that the defaults of the styles are the same as the default values of the parameters, but that if you change globally the defaults using the keys mentioned above, you only change the defaults for the ``bare'' component \texttt{rotaryswitch}, not for the styles.
\begin{LTXexample}[varwidth=true, pos=t, basicstyle=\small\ttfamily]
\begin{circuitikz}
\ctikzset{multipoles/rotary/arrow=both}
\draw (0,0) -- ++(1,0) node[rotary switch <-=8 in 120 wiper 40, anchor=in](A){};
\draw (3,0) -- ++(1,0) node[rotary switch, anchor=in](B){}; % default values
\draw[red] (A.out 4) -| (3,0);
\draw[blue] (A-out 2.n) -- ++(0,0.5) -| (B-out 1.n);
\draw (B.out 3) -- ++(1,0) node[rotary switch -=5 in 90 wiper 15, anchor=in](C){};
\draw (C.out 3) -- ++(1,0) node[rotary switch ->, xscale=-1, anchor=out 3](D){};
\draw[green, dashed] (B.mid) -- ++(-.5,-1) -| (C.mid);
\end{circuitikz}
\end{LTXexample}
\paragraph{Rotary switch anchors}
Rotary switches anchors are basically the same as the cute switches, including access (with the \texttt{\textsl{<node name>}-<anchor name>} notation) to the internal connection nodes. The geographical anchors work as expected, marking the limits of the component.
\showanchors{rotary switch}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, center/-120/0.3)
\qquad
\showanchors{rotary switch=25 in 120 wiper 10}{}(north/90/0.4, north east/45/0.4, east/0/0.4, south east/-45/0.4,
south/-90/0.4, south west/-135/0.4, west/180/0.4, north west/135/0.4, center/-120/0.3)
In addition to the anchors they have in common with the cute switches, the rotary switch has the so called ``angled'' anchors and the ``external square anchors''. \emph{Angled anchors}, called \texttt{aout 1}, \texttt{aout 2} and so forth, are anchors placed on the output poles at the same angle as the imaginary lines coming from the input pole; \emph{square anchors}, called \texttt{sqout 1}\dots, are located on an imaginary square surrounding the rotary switch on the same line.
\bigskip
\begin{circuitikz}
\begin{scope}[scale=2, transform shape]
\clip (-1,-.4) rectangle (1,.6);
\draw (0,0) node[rotary switch=9 in 90 wiper 10](Z){};
\draw [dashed, blue] (Z.cin) -- (Z.sqout 4);
\end{scope}
\path (Z.aout 4) \showcoord(aout 4)<-15:0.4>;
\path (Z.sqout 4) \showcoord(sqout 4)<0:0.4>;
\path (Z.out 3) \showcoord(out 3)<15:0.4>;
\path (Z.cout 3) \showcoord(cout 3)<180:0.4>;
\draw (8,0) node[rotary switch -=31 in 150 wiper 10](D){};
\foreach \i in {1,...,31} \draw (D.sqout \i) -- (D.aout \i);
\foreach \l/\a/\d in {north/90/0.2, north east/45/0.2, east/0/0.2,
south east/-45/0.2, south/-90/0.2, south west/-135/0.2, west/180/0.2, north west/135/0.2,
center/-145/0.7}
\path (D.ext \l) \showcoord(ext \l)<\a:\d>;
\path (D.aout 12) \showcoordb(aout 12)<-5:0.4>;
\path (D.sqout 12) \showcoordb(sqout 12)<0:0.4>;
\draw[blue, densely dotted] (D.ext north west) rectangle (D.ext south east);
\end{circuitikz}
The code for the diagram at the left, above, without the markings for the anchors, is:
\begin{lstlisting}[basicstyle=\small\ttfamily]
\begin{circuitikz}
\draw (8,0) node[rotary switch -=31 in 150 wiper 10](D){};
\foreach \i in {1,...,31} \draw (D.sqout \i) -- (D.aout \i);
\draw[blue, densely dotted] (D.ext north west) rectangle (D.ext south east);
\end{circuitikz}
\end{lstlisting}
One possible application for the angled and the ``on square'' anchors is that you can use them to move radially from the output poles, for example for adding numbers:
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{circuitikz}
\draw (0,0) node[rotary switch=13 in 120 wiper 0](S){};
\foreach \i in {1,...,13} % requires "calc"
\path ($(S.aout \i)!1ex!(S.sqout \i)$)
node[font=\tiny\color{red}]{\i};
\end{circuitikz}
\end{LTXexample}
Finally, notice that the value of width for the rotary switches is taken from the one for the ``cute switches'' which in turn is taken from the width of traditional \texttt{spdt} switch, so that they match (notice that the ``center'' anchor is better centered in the rotary switch, so you have to explicitly align them).
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{circuitikz}
\draw (0,0) node[color=blue, rotary switch=2 in 35 wiper 30,
anchor=in](R){};
\draw (0,-1) node[cute spdt up, anchor=in](C){};
\draw (0,-2) node[color=blue, rotary switch=3 in 35 wiper 30,
anchor=in](R){};
\end{circuitikz}
\end{LTXexample}
\paragraph{Rotary switch customization}
Apart from the basic customization seen above (number of channels, etc.) you can change, as in the cute switches, the shape used by the connection points with the parameter \texttt{multipoles/rotary/shape}, and the thickness of the wiper with \texttt{multipoles/rotary/thickness}. The optional arrow has thickness equal to the standard bipole thickness \texttt{bipoles/thickness} (default 2).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{multipoles/rotary/thickness=0.5}
\draw (0,1.6) node[rotary switch ->, color=blue](S1){};
\ctikzset{multipoles/rotary/shape=circ}
\draw (0,0) node[rotary switch ->](S2){};
\ctikzset{bipoles/thickness=0.5}
\draw (0,-1.6) node[rotary switch ->, color=red](S3){};
\end{circuitikz}
\end{LTXexample}
Finally, the size can be changed using the parameter \texttt{tripoles/spdt/width} (default 0.85).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,2) node[rotary switch ->, color=blue](S1){};
\ctikzset{tripoles/spdt/width=1.6, fill=cyan,
multipoles/rotary/shape=osquarepole}
\draw (0,0) node[rotary switch ->](S2){};
\end{circuitikz}
\end{LTXexample}
\subsection{Logic gates}
Logic gates, with two or more input, are supported. Albeit in principle these components are multipoles, the are considered tripoles here, for historical reasons (when they just had two inputs).
\subsubsection{American Logic gates}
\begin{groupdesc}
\circuitdesc*{american and port}{American \textsc{and} port}{}( in 1/180/0.2, in 2/180/0.2, out/0/0.2 )
\circuitdesc*{american or port}{American \textsc{or} port}{}( bin 1/135/0.2, bin 2/-135/0.2, bout/-45/0.2 )
\circuitdesc*{american nand port}{American \textsc{nand} port}{}
\circuitdesc*{american nor port}{American \textsc{nor} port}{}
\circuitdesc*{american xor port}{American \textsc{xor} port}{}
\circuitdesc*{american xnor port}{American \textsc{xnor} port}{}
\circuitdesc*{american buffer port}{American \textsc{buffer} port}{}
\circuitdesc*{american not port}{American \textsc{not} port}{}
\end{groupdesc}
\subsubsection{European Logic gates}
\begin{groupdesc}
\circuitdesc*{european and port}{European \textsc{and} port}{}( in 1/180/0.2, in 2/180/0.2, out/0/0.2 )
\circuitdesc*{european or port}{European \textsc{or} port}{}( bin 1/135/0.2, bin 2/-135/0.2, bout/-45/0.2 )
\circuitdesc*{european nand port}{European \textsc{nand} port}{}
\circuitdesc*{european nor port}{European \textsc{nor} port}{}
\circuitdesc*{european xor port}{European \textsc{xor} port}{}
\circuitdesc*{european xnor port}{European \textsc{xnor} port}{}
\circuitdesc*{european buffer port}{European \textsc{buffer} port}{}
\circuitdesc*{european not port}{European \textsc{not} port}{}
\end{groupdesc}
\begin{framed}
If (default behaviour) \texttt{americanports} option is active (or the style \texttt{[american ports]} is used), the shorthands \texttt{and port}, \texttt{or port}, \texttt{not port}, \texttt{nand port}, \texttt{not port}, \texttt{xor port}, and \texttt{xnor port} are equivalent to the american version of the respective logic port.
If otherwise \texttt{europeanports} option is active (or the style \texttt{[european ports]} is used), the shorthands \texttt{and port}, \texttt{or port}, \texttt{not port}, \texttt{nand port}, \texttt{not port}, \texttt{xor port}, and \texttt{xnor port} are equivalent to the european version of the respective logic port.
\end{framed}
\subsubsection{Special components}
There is no ``european'' version of these symbols.
\begin{groupdesc}
\circuitdesc*{schmitt}{Non-Inverting \textsc{Schmitttrigger}}{}
\circuitdesc*{invschmitt}{Inverting \textsc{Schmitttrigger}}{}
\end{groupdesc}
\subsubsection{Logic port customization}
Logic port class is called \texttt{logic ports}, so you can scale them all with \texttt{logic ports/scale} (default \texttt{1.0}).
As for most components, you can change the width and height of the ports; the thickness is given by the parameter \texttt{tripoles/thickness} (default 2):
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) node[nand port] {}; \par
\ctikzset{tripoles/american nand port/input height=.2}
\ctikzset{tripoles/american nand port/port width=.4}
\ctikzset{tripoles/thickness=4}
\tikz \draw (0,0) node[nand port] {};
\end{LTXexample}
This is especially useful if you have ports with more than two inputs, which are instantiated
with the parameter \texttt{number inputs} :
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,3) node[american and port] (A) {P1};
\begin{scope}
\ctikzset{tripoles/american or port/height=1.6}
\draw (A.out) -- ++(0.5,0)
node[american or port,
number inputs=5,
anchor=in 1] (B) {P2};
\end{scope}
\draw (0,1.5) node[american or port] (C) {P3};
\draw (C.out) |- (B.in 2);
\end{circuitikz}
\end{LTXexample}
You can tweak the appearance of american ``or'' family (\texttt{or}, \texttt{nor}, \texttt{xor} and \texttt{xnor}) ports, too, with the parameters \texttt{inner} (how much the base circle go ``into'' the shape, default 0.3) and \texttt{angle} (the angle at which the base starts, default 70).
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) node[xnor port] {};
\ctikzset{tripoles/american xnor port/inner=.7}
\ctikzset{tripoles/american xnor port/angle=40}
\tikz \draw (0,0) node[xnor port] {};
\end{LTXexample}
\subsubsection{Logic port anchors}
These are the anchors for logic ports:
\bigskip
\begin{circuitikz} [american]
\def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
\path(-2,1) -- (11,-1);
\draw (0,0) node[and port, number inputs=3](A){IC1} ;
\foreach \a/\d in {left/45, right/45, out/-45, in 1/135, in 2/135, in 3/135}
\path (A.\a) \coorda(\a)<\d>;
\draw (4.5,0) node[and port, number inputs=3](A){IC1};
\foreach \a/\d in {north/90, north west/135, west/180, south west/-135,
south/-90, south east/45, east/45, north east/45}
\path (A.\a) \coorda(\a)<\d>;
\draw (9,0) node[european and port, ](A){} ;
\foreach \a/\d in {left/45, right/45, center/-90}
\path (A.\a) \coorda(\a)<\d>;
\end{circuitikz}
\bigskip
You have also ``border pin anchors'':
\bigskip
\begin{circuitikz} [american]
\def\coorda(#1)<#2>{node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\small, pin distance=0.1cm, pin edge={red, overlay,}]#2:#1}](#1){}}
\path(-2,1) -- (11,-1);
\draw (0,0) node[american and port, number inputs=3](A){IC1} ;
\foreach \a/\d in {bin 1/-135, bin 2/-135, bin 3/-135, bout/-45}
\path (A.\a) \coorda(\a)<\d>;
\draw (4.5,0) node[american or port, number inputs=3](A){IC1};
\foreach \a/\d in {bin 1/-135, bin 2/-135, bin 3/-135, bout/-45}
\path (A.\a) \coorda(\a)<\d>;
\draw (9,0) node[european and port, ](A){} ;
\foreach \a/\d in {bin 1/-135, bin 2/-135, bout/-45}
\path (A.\a) \coorda(\a)<\d>;
\end{circuitikz}
\bigskip
These anchors are especially useful if you want to negate inputs:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,3) node[american and port] (A) {P1};
\node at (A.bin 1) [ocirc, left]{} ;
\begin{scope}
\ctikzset{tripoles/american or port/height=1.6}
\draw (A.out) -- ++(0.5,0) node[american or port,
number inputs=5, anchor=in 1] (B) {P2};
\node at (B.bin 3) [ocirc, left]{} ;
\end{scope}
\draw (0,1.5) node[american or port] (C) {P3};
\node at (C.bin 2) [ocirc, left]{} ;
\draw (C.out) |- (B.in 2);
\end{circuitikz}
\end{LTXexample}
As you can see, the \texttt{center} anchor is (for historic reasons) not in the center at all. You can fix this with the command \verb|\ctikzset{logic ports origin=center}|:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{logic ports origin=center}
\draw (0,0) node[and port] (myand) {}
(myand.in 1) node[anchor=east] {1}
(myand.in 2) node[anchor=east] {2}
(myand.out) node[anchor=west] {3};
\draw[<-] (myand.center) -- ++(1,-1)
node{center};
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
In the case of \textsc{not}, there are only \texttt{in} and \texttt{out} (although for compatibility reasons \texttt{in 1} is still defined and equal to \texttt{in}):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(1,0) node[not port] (not1) {}
(3,0) node[not port] (not2) {}
(0,0) -- (not1.in)
(not2.in) -- (not1.out)
++(0,-1) node[ground] {} to[C] (not1.out)
(not2.out) -| (4,1) -| (0,0)
;\end{circuitikz}
\end{LTXexample}
\subsection{Chips (integrated circuits)}
\texttt{CircuiTikZ} supports two types of variable-pin chips: DIP (Dual-in-Line Package) and QFP (Quad-Flat Package).
\begin{groupdesc}
\circuitdesc*{dipchip}{Dual-in-Line Package chip}{}
\circuitdesc*{qfpchip}{Quad-Flat Package chip}{}
\end{groupdesc}
\subsubsection{DIP and QFP chips customization}
You can scale chips with the key \texttt{chips/scale}. As ever, that will \textbf{not} scale text size of the labels, when they are printed.
You can customize the DIP chip with the key \texttt{multipoles/dipchip/width} (with a default of \texttt{1.2}) and the key \texttt{multipoles/dipchip/pin spacing} (default \texttt{0.4}) that are expressed in fraction of basic lengths (see section~\ref{sec:components-size}).
The height of the chip will be equal to half the numbers of pins multiplied by the spacing, plus one spacing for the borders.
For the QFP chips, you can only chose the pin spacing with \texttt{multipoles/qfpchip/pin spacing} key.
The pins of the chip can be ``hidden'' (that is, just a spot in the border, optionally marked with a number) or ``stick out'' with a thin lead by setting \texttt{multipoles/external pins width} greater than 0 (default value is \texttt{0.2}, so you'll have leads as shown above).
Moreover, you can transform the thin lead into a pad by setting the key \texttt{multipoles/external pad fraction} to something different form 0 (default is \texttt{0}); the value expresses the fraction of the pin spacing space that the pad will use on both sides of the pin.
The number of pins is settable with the key \texttt{num pins}.
\textbf{Please notice} that the number of pins \textbf{must} be \emph{even} for \texttt{dipchip}s and \emph{multiple of 4} for \texttt{qfpchip}s, otherwise havoc will ensue.
You can, if you want, avoid printing the numbers of the pin with \texttt{hide numbers} (default \texttt{show numbers}) if you prefer positioning them yourself (see the next section for the anchors you can use).
The font used for the pins is adjustable with the key \texttt{multipoles/font} (default \verb|\tiny|)
For special use you can suppress the orientation mark with the key \texttt{no topmark} (default \texttt{topmark}).
The line thickness of the main shape is controlled by \texttt{multipoles/thickness} (default 2) and the one of the external pins/pads with \texttt{multipoles/external pins thickness} (default 1).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{multipoles/thickness=4}
\ctikzset{multipoles/external pins thickness=2}
\draw (0,0) node[dipchip,
num pins=12,
hide numbers,
external pins width=0.3,
external pad fraction=4 ](C){IC1};
\draw (C.pin 1) -- ++(-0.5,0) to[R]
++(0,-3) node[ground]{};
\node [right, font=\tiny]
at (C.bpin 1) {RST};
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[dipchip,
num pins=8,
external pins width=0.0](C){IC1};
\draw (C.pin 1) -- ++(-0.5,0) to[R]
++(0,-1.5) node[ground]{};
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{multipoles/font={\color{red}\tiny}}
\draw (0,0) node[qfpchip,
num pins=16,
external pad fraction=6](C){IC1};
\draw (C.pin 1) -- ++(-0.5,0) to[R]
++(0,-2) node[ground]{};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Chips anchors}
Chips have anchors on pins and global anchors for the main shape.
The pin anchors to be used to connect wires to the chip are called \texttt{pin 1}, \texttt{pin 2} , \dots, with just one space between \texttt{pin} and the number.
Border pin anchors (\texttt{bpin 1}\dots) are always on the box border, and can be used to add numbers or whatever markings are needed.
Obviously, in case of \texttt{multipoles/external pins width} equal to zero, border and normal pin anchors will coincide.
Additionally, you have geometrical anchors on the chip ``box'', see the following figure. The nodes are available with the full name (like \texttt{north}) and with the short abbreviations \texttt{n}, \texttt{nw}, \texttt{w}\dots. The \texttt{dot} anchor is useful to add a personalized marker if you use the \texttt{no topmark} key.
\begin{quote}
\bigskip
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=0.2cm, fill=white, fill opacity=0.5, text opacity=1, pin edge={red, overlay,}]75:#1}](#1){}}
\def\coordd(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\scriptsize, pin distance=0.2cm, fill=white, fill opacity=0.5, text opacity=1,pin edge={red, overlay,}]-45:#1}](#1){}}
\begin{circuitikz}[american, ]
\ctikzset{multipoles/dipchip/pin spacing=0.7}
\draw (0,0) node[dipchip,
external pins width=0.4,
external pad fraction=4](C){IC1};
\foreach \p in {1,...,8}
\path (C.pin \p) \coord(pin \p)
(C.bpin \p) \coordd(bpin \p);
% second chip
\draw (C.pin 7) to[R] ++(3,0)
node[dipchip,anchor=pin 2](D){IC2};
\foreach \p in {center, nw, ne, se, sw, north, south, west, east}
\path (D.\p) \coord(\p);
\path (D.text) \coordd(text);
% third chip
\draw (D.pin 7) ++(2,0)
node[dipchip,anchor=pin 2, no topmark](E){};
\foreach \p in {center, n, w, e, s, dot}
\path (E.\p) \coord(\p);
\end{circuitikz}
\end{quote}
\subsubsection{Chips rotation}
You can rotate chips, and normally the pin numbers are kept straight (option \texttt{straight numbers}, which is the default), but you can rotate them if you like with \texttt{rotated numbers}.
Notice that the main label has to be (counter-) rotated manually in this case.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[dipchip,
rotate=90]{%
\rotatebox{-90}{IC2}};
\draw (3,0) node[qfpchip,
rotated numbers,
rotate=45]{IC3};
\end{circuitikz}
\end{LTXexample}
\subsubsection{Chip special usage}
You can use chips to have special, personalized blocks.
Look at the following example, which is easily put into a macro.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{multipoles/thickness=3}
\ctikzset{multipoles/dipchip/width=2}
\draw (0,0) node[dipchip,
num pins=10, hide numbers, no topmark,
external pins width=0](C){Block};
\node [right, font=\tiny] at (C.bpin 1) {RST};
\node [right, font=\tiny] at (C.bpin 2) {IN1};
\node [right, font=\tiny] at (C.bpin 4) {/IN2};
\node [left, font=\tiny] at (C.bpin 8) {OUT};
\draw (C.bpin 2) -- ++(-0.5,0) coordinate(extpin);
\node [ocirc, anchor=0](notin2) at (C.bpin 4) {};
\draw (notin2.180) -- (C.bpin 4 -| extpin);
\draw (C.bpin 8) to[short,-o] ++(0.5,0);
\draw (C.bpin 5) ++(0,0.1) -- ++(0.1,-0.1)
node[right, font=\tiny]{CLK} -- ++(-0.1,-0.1);
\draw (C.n) -- ++(0,1) node[vcc]{};
\draw (C.s) -- ++(0,-1) node[ground]{};
\end{circuitikz}\end{LTXexample}
\subsection{Seven segment displays}
\begin{groupdesc}
\circuitdesc*{bare7seg}{Seven segment display}{}
\end{groupdesc}
The seven segment display lets you show values as if they were displayed in a classical seven segment display.\footnote{This component has been loosely inspired by the package \texttt{SevenSeg} by Germain Gondor, 2009, see \href{http://www.texample.net/tikz/examples/seven-segment-display/}{\TeX{}example.net}.}
The main ``bare'' component is the one shown above, but for simplicity a couple of style interfaces are defined:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) node[seven segment val=A dot off box on]{};
\draw (1,0) node[seven segment val=- dot none box on]{};
\draw (0,-2) node[seven segment bits=1001001 dot empty box on]{};
\draw (1,-2) node[seven segment bits=0011101 dot none box off]{};
\end{circuitikz}
\end{LTXexample}
There are two main configuration methods. The first one is \texttt{seven segment val}, which will take an hexadecimal number or value and display it: the possible values are \texttt{0,...,15}, plus \texttt{A, B, C, D, E, F} (or lowercase) and the symbol \texttt{-} (minus).
The other interface is \texttt{seven segment bits}, where you specify seven bits saying which segment must be on (please never specify a different number of bits, it will throw a very obscure error); you can see in the anchors the name of each segment.
The option \texttt{dot} specifies if you want a decimal dot or not. The key \texttt{none} will remove the dot and the space it would take; \texttt{empty} will not show the dot at all but reserve the space, and \texttt{on} or \texttt{off} will show the dot in the corresponding state.
The option \texttt{box} (can be \texttt{on} or \texttt{off}) simply toggles the drawing of the external box. You can separate it from the display with the key \texttt{seven seg/box sep} (default \texttt{1pt}), and it will use the thickness specified in \texttt{multipoles/thickness} (The same as the chips).
You can use these option with the ``bare'' object \texttt{bare7seg} and the keys \texttt{seven seg/bits} (default \texttt{0000000}), \texttt{seven seg/dot} (default \texttt{none}) and \texttt{seven seg/box} (default \texttt{off}); there is no option equivalent to the \texttt{val} interface.
\subsubsection{Seven segments anchors}
These are the anchors for the seven segment displays; notice that when the \texttt{dot} parameter is not \texttt{none}, the cell is a bit wider at the right side.
\begingroup
\ctikzset{seven seg/color off=gray, multipoles/thickness=1}
\showanchors{bare7seg}{}(north/90/0.4, north east/45/0.4, east/0/0.4,
south east/-45/0.4, south/-90/0.4, south west/-135/0.4, west/180/0.4,
north west/135/0.4, center/-140/0.5)
\ctikzset{seven seg/dot=off}
\ctikzset{seven seg/box=on}
\showanchors{bare7seg}{}(north/90/0.4, north east/45/0.4, east/0/0.4,
south east/-45/0.4, south/-90/0.4, center/-140/0.5)
\ctikzset{seven seg/box=off}
\showanchors{bare7seg}{}(a/90/0.4, b/45/0.4, c/0/0.4, d/-90/0.4,
e/-129/0.4, f/145/0.4, g/190/0.4, dot/-45/0.2)
\endgroup
\subsubsection{Seven segments customization}
You can scale the seven segment display with the key \texttt{displays/scale}. This will scale the size of the digit, but not the absolute sizes shown below --- if you want them to scale, yo have to do it manually.
You can change several parameters to adjust the displays:
\begin{lstlisting}[basicstyle=\small\ttfamily]
\ctikzset{seven seg/width/.initial=0.4}% relative to \pgf@circ@Rlen (scalable)
\ctikzset{seven seg/thickness/.initial=4pt}% segment thickness (not scaled)
\ctikzset{seven seg/segment sep/.initial=0.2pt}% gap between segments (not scaled)
\ctikzset{seven seg/box sep/.initial=1pt}% external box gap (not scaled)
\ctikzset{seven seg/color on/.initial=red}% color for segment "on"
\ctikzset{seven seg/color off/.initial=gray!20!white} % ...and "off"
\end{lstlisting}
A couple of examples are shown below.
\begin{LTXexample}[varwidth=true, pos=b, basicstyle=\small\ttfamily]
\begin{circuitikz}[scale=0.5]
\ctikzset{seven seg/width=0.2, seven seg/thickness=2pt}
\foreach \i in {0,...,15} \path (\i,0)
node[seven segment val=\i dot on box off]{};
\ctikzset{seven seg/color on=black}
\foreach \i in {0,...,15} \path (\i,-1.5)
node[seven segment val=\i dot off box off, fill=gray!30!white]{};
\ctikzset{seven seg/color on=green, seven seg/color off=yellow!30}
\foreach \i in {0,...,15} \path[color=red] (\i,-3)
node[seven segment val=\i dot none box on, xslant=0.2]{};
\end{circuitikz}
\end{LTXexample}
\section{Labels and similar annotations}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, l=$R_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R=$R_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, v=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
Long names/styles for the bipoles can be used:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}\draw
(0,0) to[resistor=1<\kilo\ohm>] (2,0)
;\end{circuitikz}
\end{LTXexample}
\subsection{Labels and Annotations}
\label{sec:labels-and-annotations}
Since Version 0.7, beside the original label (l) option, there is a new option to place a second label, called annotation (a) at each bipole. Up to now this is a beta-test and there can be problems. For example, up to now this option is not compatible with the concurrent use of voltage labels.
The position of (a) and (l) labels can be adjusted with \_ and \^, respectively.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, l=$R_1$,a=1<\kilo\ohm>] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, l_=$R_1$,a^=1<\kilo\ohm>] (2,0);
\end{circuitikz}
\end{LTXexample}
\textbf{Caveat:} notice that the way in which \texttt{circuitikz} processes the options, there will be problems if the label (or annotation, voltage, or current) contains one of the characters $=$ (equal) or $,$ (comma), giving unexpected errors and wrong output.
These two characters must be protected to the option parser using an \verb|\mbox| command, or redefining the characters with a \TeX\ \verb|\def|:
\begin{LTXexample}[varwidth=true]
\def\eq{=}
\begin{circuitikz}
% the following will fail:
% \draw (0,0) to[R, l={$R=3}] (3,0);
\draw (0,0) to[R, l=\mbox{$R=3$}] (3,0);
\draw (0,0) to[R, l=$R\eq3$] (0,3);
\draw (3,3) to[R, l=\mbox{$R,3$}] (3,0);
% this works, but it has wrong spacing
\draw (0,3) to[R, l=$R{=}3$] (3,3);
\end{circuitikz}
\end{LTXexample}
\noindent The default orientation of labels is controlled by the options \texttt{smartlabels}, \texttt{rotatelabels} and \texttt{straightlabels} (or the corresponding \texttt{label/align} keys). Here are examples to see the differences:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{label/align = straight}
\def\DIR{0,45,90,135,180,-90,-45,-135}
\foreach \i in \DIR {
\draw (0,0) to[R=\i, *-o] (\i:2.5);
}
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{label/align = rotate}
\def\DIR{0,45,90,135,180,-90,-45,-135}
\foreach \i in \DIR {
\draw (0,0) to[R=\i, *-o] (\i:2.5);
}
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\ctikzset{label/align = smart}
\def\DIR{0,45,90,135,180,-90,-45,-135}
\foreach \i in \DIR {
\draw (0,0) to[R=\i, *-o] (\i:2.5);
}
\end{circuitikz}
\end{LTXexample}
You also can use stacked (two lines) labels. The example should be self-explanatory: the two lines are specified as \texttt{l2=}\emph{line1}\texttt{ and }\emph{line2}. You can use the keys \texttt{l2 halign} to control horizontal position (\texttt{l}eft, \texttt{c}enter, \texttt{r}ight) and \texttt{l2 valign} to control the vertical one (\texttt{b}ottom, \texttt{c}center, \texttt{t}op).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[ american, ]
%
% default is l2 halign=l, l2 valign=c
%
\draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, , l2 valign=t] (2,0);
\draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, , ] (0,2);
\draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=b] (-2,0);
\draw (0,0) to[R, l2_=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=r, l2 valign=c] (0, -2);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[ american, ]
\draw (0,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=b] (2,0);
\draw (0,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, ] (0,2);
\draw (0,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, , l2 valign=t] (-2,0);
\draw (0,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=t](0, -3);
\end{circuitikz}
\end{LTXexample}
\subsection{Currents and voltages}\label{curr-and-volt}
The default direction/sign for currents and voltages in the components is, unfortunately, not standard, and can change across country and sometime across different authors.
This unfortunate situation created a bit of confusion in \texttt{circuitikz} across the versions, with several incompatible changes starting from version 0.5.
From version 0.9.0 onward, the maintainers agreed a new policy for the directions of bipoles' voltages and currents, depending on 4 different possible options:
\begin{itemize}
\item \texttt{oldvoltagedirection}, or the key style \texttt{voltage dir=old}: Use old way of voltage direction having a difference between european and american direction, with wrong default labelling for batteries (it was the default before version 0.5);
\item \texttt{nooldvoltagedirection}, or the key style \texttt{voltage dir=noold}: The standard from version 0.5 onward, utilize the (German?) standard of voltage arrows in the direction of electric fields (without fixing batteries);
\item \texttt{RPvoltages} (meaning Rising Potential voltages), or the key style \texttt{voltage dir=RP}: the arrow is in direction of rising potential, like in \texttt{oldvoltagedirection}, but batteries and current sources are fixed so that they follow the passive/active standard: the default direction of \texttt{v} and \texttt{i} are chosen so that, when both values are positive:
\begin{itemize}
\item in passive component, the element is \emph{dissipating power};
\item in active components (generators), the element is \emph{generating power}.
\end{itemize}
\item \texttt{EFvoltages} (meaning Electric Field voltages), or the key style \texttt{voltage dir=EF}: the arrow is in direction of the electric field, like in \texttt{nooldvoltagedirection}, but batteries are fixed;
\end{itemize}
Notice that the four styles are designed to be used at the environment level: that is, you should use them at the start of your environment as in \verb|\begin{circuitikz}[voltage dir=old] ...| and not as a key for single components, in which case the behaviour is not guaranteed.
The standard direction of currents, flows and voltages are changed by these options; notice that the default drops in case of passive and active elements is normally different. Take care that in the case of \texttt{noold} and \texttt{EFvoltages} also the currents can switch directions. It is much easier to understand the several behaviors by looking at the following examples, that have been generated by the code:
\begin{lstlisting}
\foreach\element in {R, C, D, battery2, V, I, sV, cV, cI}{%
\noindent\ttfamily
\begin{tabular}{p{2cm}}
\element \\ american \\[15pt]
\element \\ european \\
\end{tabular}
\foreach\mode in {old, noold, RP, EF} {
\begin{tabular}{@{}l@{}}
\multicolumn{1}{c}{voltage dir} \\
\multicolumn{1}{c}{dir=\mode} \\[4pt]
\begin{tikzpicture}[
american, voltage dir=\mode,
]
\draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
\end{tikzpicture}\\
\begin{tikzpicture}[
european, voltage dir=\mode,
]
\draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
\end{tikzpicture}
\end{tabular}
\medskip
}
\par
}
\end{lstlisting}
\foreach\element in {R, C, D, battery2, V, I, sV, cV, cI}{%
\noindent\ttfamily
\begin{tabular}{p{2cm}}
\element \\ american \\[15pt]
\element \\ european \\
\end{tabular}
\foreach\mode in {old, noold, RP, EF} {
\begin{tabular}{@{}l@{}}
\multicolumn{1}{c}{voltage dir} \\
\multicolumn{1}{c}{dir=\mode} \\[4pt]
\begin{tikzpicture}[
american, voltage dir=\mode,
]
\draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
\end{tikzpicture}\\
\begin{tikzpicture}[
european, voltage dir=\mode,
]
\draw (0,0) to[\element, *-o, v=$v_1$, i=$i_1$, ] (2.5,0);
\end{tikzpicture}
\end{tabular}
\medskip
}
\par
}
Obviously, you normally use just one between current and flows, but anyway you can
change direction of the voltages,
currents and flows using the complete keys \verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|,
as shown in the following examples.
This manual has been typeset with the option \texttt{\chosenvoltoption}.
\subsection{Currents}
Inline (along the wire) currents are selected with \verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|, and various simplification; the default position and direction is obtained with the key \verb|i=...|.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i^>=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i_>=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i^<=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i_<=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i>^=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i>_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i<^=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i<_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
Also:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i<=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i>=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i^=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V<=10V, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[V=10V,invert, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[dcisource=1A, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[dcisource=1A,invert, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Flows}\label{flows}
As an alternative for the current arrows, you can also use the following flows. They can also be used to indicate thermal or power flows. The syntax is pretty the same as for currents.
\textit{This is a new beta feature since version 0.8.3; therefore, please provide bug reports or hints to optimize this feature regarding placement and appearance! This means that the appearance may change in the future!}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f<=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f_=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f_>=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f<^=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f<_=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, f>_=$i_1$] (3,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Voltages}
See introduction note at Currents (chapter \ref{curr-and-volt}, page \pageref{curr-and-volt})!
\subsubsection{European style} The default, with arrows. Use option \texttt{europeanvoltage} or style \verb![european voltages]!.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v_>=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v_<=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V<=10V, i_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I=1A, v_=$u_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I<=1A, v_=$u_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I,l=1A, v_=$u_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{American style}
Use option \texttt{americanvoltage} or set \verb![american voltages]!.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[R, v_>=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[R, v_<=$v_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[I=1A, v_=$u_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\draw (0,0) to[I<=1A, v_=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{Voltage position} It is possible to move away the arrows and the plus or minus signs with the key \texttt{voltages shift} (default value is \texttt{0}, which gives the standard position):
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[]
\draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0);
\draw (0,-1) to[R, v=$v_1$, i=$i_1$,
voltage shift=0.5] (2,-1);
\draw (0,-2) to[R, v=$v_1$, i=$i_1$,
voltage shift=1.0, ] (2,-2);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages, voltage shift=0.5]
\draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
Notes that \texttt{american voltage} also affects batteries.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[voltage shift=0.5]
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages, voltage shift=0.5]
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsubsection{American voltages customization}
Since 0.9.0, you can change the font\footnote{There where a bug before, noticed by the user \texttt{dzereb} on \href{https://tex.stackexchange.com/questions/487683/odd-minus-style-when-drawing-american-voltage}{tex.stackexchange.com} which made the symbols using different fonts in a basically random way. In the same page, user \texttt{campa} found the problem. Thanks!} used by the \texttt{american voltages} style, by setting to something different from nothing the key \texttt{voltage/american font} (default: nothing, using the current font) style:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\begin{scope}
\ctikzset{voltage/american font=\tiny\boldmath}
\draw (0,0) to[R,v=$V_S$] ++(2,0);
\end{scope}
\draw (0,-2) to[R,v=$V_S$] ++(2,0);
\end{circuitikz}
\end{LTXexample}
Also, if you want to change the symbols (sometime just the $+$ sign is drawn, for example, or for highlighting something),
using the keys \texttt{voltage/american plus} and \texttt{voltage/american minus} (default \verb|$+$| and \verb|$-$|).
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american]
\ctikzset{voltage/american font=\scriptsize\boldmath}
\ctikzset{voltage/american plus=\textcolor{red}{$\oplus$}}
\ctikzset{voltage/american minus=\textcolor{blue}{$\ominus$}}
\draw (0,0) to[R,v_>=$V_S$] ++(2,0);
\draw (0,-2) to[R,v_<=$V_S$] ++(2,0);
\end{circuitikz}
\end{LTXexample}
This could be especially useful if you define a style, to use like this:
\begin{LTXexample}[varwidth=true]
\tikzset{red plus/.style={
circuitikz/voltage/american plus=\textcolor{red}{$+$},
}}
\begin{circuitikz}[american]
\draw (0,0) to[R,v_>=$V_S$, red plus] ++(2,0);
\draw (0,-2) to[R,v_<=$V_S$] ++(2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Global properties of voltages and currents}
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) to[R, v=1<\volt>] (2,0); \par
\ctikzset{voltage/distance from node=.1}
\tikz \draw (0,0) to[R, v=1<\volt>] (2,0);
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) to[C, i=$\imath$] (2,0); \par
\ctikzset{current/distance = .2}
\tikz \draw (0,0) to[C, i=$\imath$] (2,0);
\end{LTXexample}
However, you can override the properties \texttt{voltage/distance from node} (how distant from the initial and final points of the path the arrow starts and ends) and \texttt{voltage/bump b} (how high the bump of the arrow is --- how curved it is)\footnote{Prior to 0.9.4 you had also \texttt{voltage/european label distance} (how distant from the bipole the voltage label will be) but this is deprecated, and the european-style label is printed near the bump)} on a per-component basis, in order to fine-tune the voltages:
\begin{LTXexample}[varwidth=true]
\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0)
to[C, v=2<\volt>] (3,0); \par
\ctikzset{bipoles/capacitor/voltage/distance from node/.initial=.7}
\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0)
to[C, v=2<\volt>] (3,0); \par
\end{LTXexample}
Note the \texttt{.initial}; you have to create such key the first time you use it.
\subsection{Changing the style of labels and text ornaments}
Since version \texttt{0.9.5}, it is possible to change the style of bipole text ornaments (labels, annotations, voltages etc) by using the appropriate styles or keys.
The basic style applied to the text are defined in the \texttt{/tikz/circuitikz} key directory and applied to every node that contains the text; you can also change them locally by using the \texttt{tikz} direct keys in local scopes.
For example, you can make all annotations small by using:
\begin{lstlisting}[numbers=none]
\ctikzset{bipole annotation style/.style={font=\small}}
\end{lstlisting}
And the change (override) the setting in one specific bipole using:
\begin{lstlisting}[numbers=none]
...to[bipole annotation style={color=red}, R, a={Red note}]...
\end{lstlisting}
where the annotation will be in normal font (it has been reset!) and red, or append to the style:
\begin{lstlisting}[numbers=none]
...to[bipole annotation append style={color=red}, R, a={Red small note}]...
\end{lstlisting}
\textbf{Caveat:} you have to put the style changing key at the start of the \texttt{to} arguments to have any effect\footnote{No, I do not know why. Hints and fixes are welcome.}.
The available styles and commands are \texttt{bipole label style}, \texttt{bipole annotation style}, \texttt{bipole voltage style}, \texttt{bipole current style}, and \texttt{bipole flow style}. The following example shows a bit of everything.
\begin{LTXexample}[pos=t, basicstyle=\small\ttfamily ]
\begin{circuitikz}[american]
\ctikzset{bipole annotation style/.style={font=\tiny}}
\ctikzset{bipole current style/.style={font=\small\sffamily}}
\draw (0,0) to [bipole annotation append style={fill=yellow}, R=L1, a=A1] ++(3,0)
to [bipole label style={fill=cyan}, R, l2_=L2 and 2L, a^=A2] ++(3,0);
\draw (7,0) to [bipole voltage style={color=blue},
bipole flow style={fill=green, outer sep=5pt},
R=R1, v=V1, i=I1, f>^=F1] ++(3,0)
to [bipole current append style={color=red}, R, v<=V2, i^=I2, f>^=F2] ++(3,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Labels in special components}
For some components label, current and voltage behave as one would expect:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[I, i=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[cI=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[sI=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[csI=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
The following results from using the option \texttt{americancurrent} or using the style \texttt{[american currents]}.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american currents]
\draw (0,0) to[I=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american currents]
\draw (0,0) to[I, i=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american currents]
\draw (0,0) to[cI=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american currents]
\draw (0,0) to[sI=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american currents]
\draw (0,0) to[csI=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
The same holds for voltage sources:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[V, v=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[cV=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[sV=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[csV=$k\cdot a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
The following results from using the option \texttt{americanvoltage} or the style \texttt{[american voltages]}.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[V=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[V, v=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[cV=$k v_e$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[sV=$a_1$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[american voltages]
\draw (0,0) to[csV=$k v_e$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Integration with {\ttfamily siunitx}}
If the option {\ttfamily siunitx} is active (and \emph{not} in \ConTeXt), then the following are equivalent:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, l=1<\kilo\ohm>] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, l=$\SI{1}{\kilo\ohm}$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i=1<\milli\ampere>] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, i=$\SI{1}{\milli\ampere}$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, v=1<\volt>] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, v=$\SI{1}{\volt}$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Accessing labels text nodes}
Since 0.9.5, you can access all the labels nodes\footnote{The access to \texttt{label}s and \texttt{annotation}s was present before, but not documented.} using special node names. So, if you use \texttt{name} to give a name to the bipole node, you can access also the following nodes: \texttt{namelabel} (notice: no space nor any other symbol between \texttt{name} and \texttt{label}!), \texttt{nameannotation}, \texttt{namevoltage}, \texttt{namecurrent} and \texttt{nameflow}.
\begin{LTXexample}[varwidth=true,
pos=t, basicstyle=\small\ttfamily
]
\newcommand{\marknode}[2][45]{%
\node[circle, draw, red, inner sep=1pt,
pin={[red, font=\tiny]#1:#2}] at (#2.center) {};
}
\begin{circuitikz}[ american]
\draw (0,0) to [R=L1, a=A1, name=L1] ++(3,0)
to [R, l2_=L2 and 2L, a^=A2, name=L2] ++(3,0);
\marknode{L1} \marknode{L1label} \marknode[0]{L1annotation}
\marknode{L2} \marknode[0]{L2label} \marknode{L2annotation}
\draw[blue] (L2label.south west) rectangle (L2label.north east);
\draw (6.1,0) to [R=R1, v=V1, i=I1, f>^=F1, name=R1] ++(3,0)
to [R, v<=V2, i^=I2, f>^=F2, name=R2] ++(3,0);
\marknode[0]{R1voltage} \marknode[0]{R2voltage} \marknode[90]{R1current}
\marknode[90]{R2current} \marknode{R1flow} \marknode{R2flow}
\end{circuitikz}
\end{LTXexample}
\section{Using bipoles in circuits}
\subsection{Nodes (also called poles)}\label{sec:bipole-nodes}
You can add nodes to the bipoles, positioned at the coordinates surrounding the component. The general style to use is \texttt{bipole nodes=\{start\}\{stop\}}, where \texttt{start} and \texttt{stop} are the nodes --- to be chosen between \texttt{none}, \texttt{circ}, \texttt{ocirc}, \texttt{squarepole}, \texttt{osquarepole}, \texttt{diamondpole}, \texttt{odiamondpole} and \texttt{rectfill}\footnote{You can use other shapes too, but at your own risk\dots Moreover, notice that \texttt{none} is not really a node, just a special word used to say ``do not put any node here''.} (see section~\ref{sec:terminals}).
\begin{LTXexample}[varwidth=true,
basicstyle=\small\ttfamily
]
\begin{circuitikz}
\ctikzset{bipoles/length=.5cm, nodes width=0.1}%small components, big nodes
\foreach \a/\p [evaluate=\a as \b using (\a+180)] in
{-90/none, -60/circ, -30/ocirc, 0/diamondpole, 30/odiamondpole, 60/squarepole, 90/osquarepole}
\draw (0,0) to[R, bipole nodes={none}{\p}] ++(\a:1.5) node[font=\tiny, anchor=\b]{\p};
\end{circuitikz}
\end{LTXexample}
These bipole nodes are added after the path is drawn, as every node in Ti\emph{k}Z --- this is the reason why they are always filled (with the main color the normal nodes, with white the open ones), in order to ``hide'' the wire below. You can override the fill color if you want; but notice that if you draw things in two different paths, you will have ``strange'' results; notice that in the second line of resistors the second wire is starting from the center of the white \texttt{ocirc} of the previous path.
\begin{LTXexample}[varwidth=true,
pos=t, basicstyle=\small\ttfamily
]
\begin{circuitikz}
\draw (0,0) to[R, *-o] ++(2,0) to[R, -d] ++(2,0)
to[R, bipole nodes={diamondpole}{odiamondpole, fill=red}] ++(2,0);
\draw (0,-1) to[R, *-o] ++(2,0) ;
\draw (2,-1) to[R, -d] ++(2,0) to[R, bipole nodes={none}{squarepole}] ++(2,0);
\end{circuitikz}
\end{LTXexample}
You can define shortcuts for the \texttt{bipole nodes} you use most; for example if you want a shortcut for a bipole with open square node in red in the right side you can:
\begin{LTXexample}[varwidth=true,
basicstyle=\small\ttfamily
]
\begin{circuitikz}
\ctikzset{-s/.style = {bipole nodes={none}{osquarepole, fill=red}}}
\draw (0,0) to[R, -s] ++(2,0);
\end{circuitikz}
\end{LTXexample}
There are several predefined shorthand as the above; in the following pages you can see all of them.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, o-o] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, -o] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, o-] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, *-*] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, -*] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, *-] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, d-d] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, -d] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, d-] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, o-*] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, *-o] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, o-d] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, d-o] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, *-d] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R, d-*] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Mirroring and Inverting}
Bipole paths can also mirrored and inverted (or reverted) to change the drawing direction.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[pD] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[pD, mirror] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[pD, invert] (2,0);
\end{circuitikz}
\end{LTXexample}
Placing labels, currents and voltages works also, please note, that mirroring and inverting does not influence the positioning of labels and voltages. Labels are by default above/right of the bipole and voltages below/left, respectively.
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[ospst=T, i=$i_1$, v=$v$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[ospst=T, mirror, i=$i_1$, v=$v$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[ospst=T, invert, i=$i_1$, v=$v$] (2,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[ospst=T,mirror,invert, i=$i_1$, v=$v$] (2,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Putting them together}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[R=1<\kilo\ohm>,
i>_=1<\milli\ampere>, o-*] (3,0);
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[varwidth=true]
\begin{circuitikz}
\draw (0,0) to[D*, v=$v_D$,
i=1<\milli\ampere>, o-*] (3,0);
\end{circuitikz}
\end{LTXexample}
\subsection{Line joins between Path Components}
\label{sec:line-joins}
Line joins should be calculated correctly - if they are on the same path, and the path is not closed. For example, the following path is not closed correctly (\textit{--cycle} does not work here!):
\begin{LTXexample}[varwidth=true]
\begin{tikzpicture}[line width=3pt,european]
\draw (0,0) to[R]++(2,0)to[R]++(0,2)
--++(-2,0)to[R]++(0,-2);
\draw[red,line width=1pt] circle(2mm);
\end{tikzpicture}
\end{LTXexample}
To correct the line ending, there are support shapes to fill the missing rectangle. They can be used like the support shapes (*,o,d) using a dot (.) on one or both ends of a component (have a look at the last resistor in this example:
\begin{LTXexample}[varwidth=true]
\begin{tikzpicture}[line width=3pt,european]
\draw (0,0) to[R]++(2,0)to[R]++(0,2)
--++(-2,0)to[R,-.]++(0,-2);
\draw[red,line width=1pt] circle(2mm);
\end{tikzpicture}
\end{LTXexample}
\section{Colors}
\subsection{Shape colors}
The color of the components is stored in the key \verb!\circuitikzbasekey/color!. Circui\TikZ\ tries to follow the color set in \TikZ, although sometimes it fails. If you change color in the picture, please do not use just the color name as a style, like \verb![red]!, but rather assign the style \verb![color=red]!.
Compare for instance
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw[red]
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
and
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw[color=red]
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
One can of course change the color \emph{in medias res}:
\begin{LTXexample}[pos=t, varwidth=true]
\begin{circuitikz} \draw
(0,0) node[pnp, color=blue] (pnp2) {}
(pnp2.B) node[pnp, xscale=-1, anchor=B, color=brown] (pnp1) {}
(pnp1.C) node[npn, anchor=C, color=green] (npn1) {}
(pnp2.C) node[npn, xscale=-1, anchor=C, color=magenta] (npn2) {}
(pnp1.E) -- (pnp2.E) (npn1.E) -- (npn2.E)
(pnp1.B) node[circ] {} |- (pnp2.C) node[circ] {}
;\end{circuitikz}
\end{LTXexample}
The all-in-one stream of bipoles poses some challanges, as only the actual body of the bipole, and not the connecting lines, will be rendered in the specified color. Also, please notice the curly braces around the \texttt{to}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0) to[V=1<\volt>] (0,2)
{ to[R=1<\ohm>, color=red] (2,2) }
to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
\end{LTXexample}
Which, for some bipoles, can be frustrating:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,0){to[V=1<\volt>, color=red] (0,2) }
to[R=1<\ohm>] (2,2)
to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
\end{LTXexample}
The only way out is to specify different paths:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw[color=red]
(0,0) to[V=1<\volt>, color=red] (0,2);
\draw (0,2) to[R=1<\ohm>] (2,2)
to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
\end{LTXexample}
And yes: this is a bug and \emph{not} a feature\ldots
\subsection{Fill colors}
Since version 0.9.0, you can also fill most shapes with a color (the manual specifies which ones are fillable or not). The syntax is quite intuitive:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,2) node[and port, fill=yellow] (myand1) {}
(0,0) node[and port, fill=cyan] (myand2) {}
(2,1) node[xnor port,fill=red!30!white] (myxnor) {}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
This fill color will override any color defined by the style (see section~\ref{sec:styling-fillcolor}). If you want to override a style fill color with no-fill for a specific component, you need to override the style --- it's a bit unfortunate but it should be an exceptional thing anyway:
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{circuitikz}
\ctikzset{logic ports/fill=cyan!30!white}
\draw[red] (-0.5,3) -- (-0.5, -1);
\draw[red] (1.5,3) -- (1.5, -1);
\draw
(0,2) node[and port, ] (myand1) {}
(0,0) node[and port, fill=cyan] (myand2) {}
(2,1) node[xnor port, circuitikz/logic ports/fill=none] (myxnor) {}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
You can combine shape colors with fill colors, too, but you should use the \texttt{draw} color option style for this:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw[color=red]
(0,2) node[and port, fill=yellow] (myand1) {1}
(0,0) node[and port, fill=cyan] (myand2) {2}
(2,1) node[xnor port,fill=red!30!white] (myxnor) {3}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
This is because, as you can see from the following example in port \texttt{2}, you can't specify both a fill and a color in the node (yes, it's a bug too, but it's quite complex to solve given the current circuit\TikZ{} architecture).
A workaround is shown in port \texttt{3}:
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
(0,2) node[and port, color=black] (myand1) {1}
(0,0) node[and port, color=blue, fill=cyan] (myand2) {2}
(2,1) {[color=blue] node[xnor port, fill=cyan] (myxnor) {3}}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
;\end{circuitikz}
\end{LTXexample}
Notice also that the connection point are always filled, although the color \emph{tries} to follow the color of the filling of the component:
\begin{LTXexample}[varwidth=true, pos=t]
\begin{circuitikz}
\fill[cyan] (0,3.0) rectangle (7,7);
\draw [fill=yellow, ] (4,4) to [D,o-o] ++(0,2) to[D*, fill=yellow] ++(2,0)
to[D*] ++(0,-2) to[D, fill=red, o-o] ++(-2,0);
\draw (1,4) node[ocirc]{} -- ++(1,0) node[ocirc]{};
\draw (1,4.5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0);
\draw[fill=yellow] (1,5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0);
\draw (1,5.5) to[short, fill=red, o-o] ++(1,0) to[short, -o] ++(1,0);
\end{circuitikz}
\end{LTXexample}
\section{FAQ}
\noindent Q: When using \verb!\tikzexternalize! I get the following error:
\begin{verbatim}
! Emergency stop.
\end{verbatim}
\noindent A: The \TikZ\ manual states:
\begin{quotation}
Furthermore, the library assumes that all \LaTeX\ pictures are ended
with \\\verb!\end{tikzpicture}!.
\end{quotation}
Just substitute every occurrence of the environment \verb!circuitikz! with \verb!tikzpicture!. They are actually pretty much the same.
\bigskip
\noindent Q: How do I draw the voltage between two nodes?
\noindent A: Between any two nodes there is an open circuit!
\begin{LTXexample}[varwidth=true]
\begin{circuitikz} \draw
node[ocirc] (A) at (0,0) {}
node[ocirc] (B) at (2,1) {}
(A) to[open, v=$v$] (B)
;\end{circuitikz}
\end{LTXexample}
\bigskip
\noindent Q: I cannot write \verb!to[R = $R_1=12V$]! nor \verb!to[ospst = open, 3s]!: I get errors.
\noindent A: It is a limitation of the parser.
Use \verb|\def{\eq}{=}| \verb!to[R = $R_1\eq 12V$]! and \verb!to[ospst = open{,} 3s]! instead; see caveat in section~\ref{sec:labels-and-annotations}.
\bigskip
\noindent Q: I tried to change the direction of the $y$ axis with \texttt{yscale=-1}, but the circuit is completely messed up.
\noindent A: Yes, it's a known bug (or misfeature, or limitation). See section~\ref{sec:bugs}. Don't do that.
\bigskip
\noindent Q: I tried to put a diode in a \texttt{pic}, but it's coming out badly rotated.
\noindent A: Yes, it's a known bug (or misfeature, or limitation). See section~\ref{sec:bugs}. \Circuitikz{} is not compatible with \texttt{pic}s at this point.
\section{Defining new components}
\begin{quote}
Per me si va ne la città dolente,\\
per me si va ne l'etterno dolore,\\
per me si va tra la perduta gente.\\
\dots\\
Lasciate ogne speranza, voi ch'intrate.%
\footnote{\url{https://classicsincontext.wordpress.com/2010/02/28/canto-iii-per-me-si-va-ne-la-citta-dolente/}}
\end{quote}
\textbf{Big fat warning}: this material is reserved to \TeX-hackers; do not delve into this if you have no familiarity with (at least) a bit of core \TeX{} programming and to the basic \TikZ{} layer. You have been warned.
\subsection{Suggested setup}
The suggested way to start working on a new component is to use the utilities of the \Circuitikz{} manual for checking and testing your device. Basically, find (or download) the source code of the last version of \Circuitikz{} and find the file \texttt{ctikzmanutils.sty}; copy it in your directory and prepare a file like this:
\begin{lstlisting}
\documentclass[a4paper, titlepage]{article}
\usepackage{a4wide} %smaller borders
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\parindent=0pt
\parskip=4pt plus 6pt minus 2pt
\usepackage[siunitx, RPvoltages]{circuitikz}
\usepackage{ctikzmanutils}
\makeatletter
%% Test things here
% defines
% components
% paths
\makeatother
\begin{document}
\circuitdescbip*{damper}{Mechanical damping}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\geolrcoord{dampershape, fill=yellow}
\begin{LTXexample}[varwidth]
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
to[damper] ++(2,0);
\end{circuitikz}
\end{LTXexample}
\end{document}
\end{lstlisting}
This will compile to something like this (in this case, we are using a couple of existing components to check everything is ok):
\circuitdescbip*{damper}{Mechanical damping}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\geolrcoord{dampershape, fill=yellow}
\begin{LTXexample}[varwidth]
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
to[damper] ++(2,0);
\end{circuitikz}
\end{LTXexample}
The command \verb|circuitdescbip*| is used to show the component description (you can check the definition and the usage looking at \texttt{ctikzmanutils.sty} file, and the \verb|\geolrcoord| is used to show the main anchors (geographical plus \texttt{left} and \texttt{right}) of the component.
From now on, you can add the new commands for the component between the \verb|\makeatletter| and \verb|\makeatother| commands and, modifying the example, check the results.
\subsection{Path-style component}
Let's define for example a path style component, like the one suggested by the user \texttt{@alex} on \href{https://tex.stackexchange.com/questions/484268/combined-spring-damper-in-circuitikz}{\TeX{} stackexchange site}. The component will be a mix of the \texttt{damper} and the \texttt{spring} components already present.
The first step is to check if we can use the definition already existing for similar elements (for coherence of size) or if we need to define new ones; for this you have to check the file \texttt{pgfcirc.defines.tex}: we find
\begin{lstlisting}
\ctikzset{bipoles/spring/height/.initial=.5}
\ctikzset{bipoles/spring/width/.initial=.5}
\ctikzset{bipoles/damper/height/.initial=.35}
\ctikzset{bipoles/damper/length/.initial=.3}
\ctikzset{bipoles/damper/width/.initial=.4}
\end{lstlisting}
We will use them; at this stage you can decide to add other parameters if you need them. (Notice, however, than although flexibility is good, these parameters should be described in the manual, otherwise they're as good as a fixed number in the code).
To define the new component we will look into \texttt{pgfcircbipoles.tex} and we will copy, for example, the definition of the damper into our code, just changing the name:
\begin{lstlisting}
%% mechanical resistor - damper
\pgfcircdeclarebipolescaled{mechanicals}
{} % extra anchors
{\ctikzvalof{bipoles/damper/height}} % depth (under the path line)
{viscoe} % name
{\ctikzvalof{bipoles/damper/height}} % height (above the path line)
{\ctikzvalof{bipoles/damper/width}} % width
{
\pgfpathrectanglecorners{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgf@circ@maybefill
% line into the damper
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
\pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
{\pgf@circ@res@zero}}
\pgfusepath{stroke}
% damper box
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfsetrectcap
\pgfsetmiterjoin
\pgfusepath{stroke}
% damper vertical element
\pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
{.8\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
{.8\pgf@circ@res@up}}
\pgfsetbuttcap
\pgfusepath{stroke}
}
\end{lstlisting}
This command will define a shape that is named \texttt{viscoeshape}, with all the correct geographical anchors based on the depth, height and width defined in the parameters of \verb|\pgfcircdeclarebipolescaled|. Moreover, the element is assigned to the class \texttt{mechanicals} for styling.
To be coherent with the styling, you should use (when needed) the length \verb|\pgf@circ@scaled@Rlen| as the ``basic'' length for drawing, using the fill functions defined at the start of \texttt{pgfcirc.defines.tex} to fill and stroke --- so that the operation will follow the style parameters and, finally, use the macro \verb|\pgf@circ@setlinewidth| to set the line thickness /the first argument is the ``legacy'' class, if you do not want to assign one you can use the pseudo-legacy class \texttt{none}.
The anchors for the bipole (which then set the lengths \verb|\pgf@circ@res@left|) are already scaled for your use. You can use these lenghts (which defines, normally, the geographical anchors of the element) to draw your shapes.
This is not sufficient for using the element in a \texttt{to[]} path command; you need to ``activate'' it with (this commands are normally in \texttt{pgfcircpath.tex}):
\begin{lstlisting}
\def\pgf@circ@viscoe@path#1{\pgf@circ@bipole@path{viscoe}{#1}}
\compattikzset{viscoe/.style = {\circuitikzbasekey,
/tikz/to path=\pgf@circ@dviscoe@path, l=#1}}
\end{lstlisting}
And now you can show it with:
\begin{lstlisting}
\circuitdescbip*{viscoe}{Mechanical viscoelastic element}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\geolrcoord{viscoeshape, fill=yellow}
\begin{LTXexample}[varwidth]
\begin{circuitikz}
\draw (0,0) to[spring] ++(2,0)
to[viscoe] ++(2,0);
\end{circuitikz}
\end{LTXexample}
\end{lstlisting}
Obviously, at first you you just have a component that is the same as the one you copied with another name. It is now just a matter of modifying it so that it has the desired shape; in the example above you can already see the new symbol after the changes.
When doing the drawing, the \verb|\pgfcircdeclarebipole| will setup the lengths \verb|\pgf@circ@res@right|
and \verb|\pgf@circ@res@up| as the $x$-$y$ coordinates of the upper right corner, and
\verb|\pgf@circ@res@left| and \verb|\pgf@circ@res@down| as the $x$-$y$ coordinates of the lower left corner of your shape. The \texttt{center} coordinate is usually at $(0pt, 0pt)$.
Looking at the implementation of the \texttt{spring} element, a possible implementation is changing the lines between lines~12 and~16 with:
\begin{lstlisting}
% spring into the damper
\pgfscope
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
\pgfsetcornersarced{\pgfpoint{.25\pgf@circ@res@up}{.25\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.75\pgf@circ@res@left}{.75\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.5\pgf@circ@res@left}{-.75\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.25\pgf@circ@res@left}{.75\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{-.75\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{.75\pgf@circ@res@up}}
\pgfusepath{stroke}
\endpgfscope
\end{lstlisting}
which leads to:
\circuitdescbip*{viscoe}{Mechanical viscoelastic element}{}(left/135/0.2, right/45/0.2, center/-90/0.3)
\geolrcoord{viscoeshape, fill=yellow}
\begin{LTXexample}[varwidth]
\begin{circuitikz}
\draw (0,0) to[spring] ++(2,0)
to[viscoe] ++(2,0);
\end{circuitikz}
\end{LTXexample}
As a final note, notice that the \texttt{viscoe} element is already added to the standard package.
\subsection{Node-style component}
Adding a node-style component is much more straightforward. Just define it by following examples in, for example, \texttt{pgfcirctripoles.tex} or the other files; be careful that you should define all the geographical anchors of the shape if you want that the \TikZ{} positioning options (like \texttt{left}, \texttt{above}, etc.) behave correctly with your component.
To have a scalable component, for example in the \texttt{transistors} class, you should use something like
\begin{lstlisting}
\savedmacro{\ctikzclass}{\edef\ctikzclass{transistors}}
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
\end{lstlisting}
at the start of anchors and macros definition, and use (for example, the exact code will change greatly depending on your component):
\begin{lstlisting}
\savedanchor\northeast{% upper right
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
\pgf@y=\pgf@circ@scaled@Rlen
\pgf@y=0.5\pgf@y
\pgf@x=0.3\pgf@y
}
\end{lstlisting}
in all the \texttt{savedanchors}.
Then, in the drawing part, you should start with:
\begin{lstlisting}
\pgf@circ@scaled@Rlen=\scaledRlen
\end{lstlisting}
and then use \verb|\pgf@circ@scaled@Rlen| (or the anchors) as default lengths while you draw it.
\subsubsection{Finishing your work}
Once you have a satisfactory element, you should
\begin{itemize}
\item Clean up your code;
\item write a piece of documentation explaining its use, with an example;
\item Propose the element for inclusion in the GitHub page of the project (you will have to license this as explained in that page, of course).
\end{itemize}
The best way of contributing is forking the project, adding your component in the correct files, modifying the manual and creating a pull request for the developers to merge. Anyway, if this is a problem, just open an issue and someone (when they have time\dots) will answer.
\section{Examples}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1.4]\draw
(0,0) to[C, l=10<\micro\farad>] (0,2) -- (0,3)
to[R, l=2.2<\kilo\ohm>] (4,3) -- (4,2)
to[L, l=12<\milli\henry>, i=$i_1$,v=b] (4,0) -- (0,0)
(4,2) { to[D*, *-*, color=red] (2,0) }
(0,2) to[R, l=1<\kilo\ohm>, *-] (2,2)
to[cV, i=1,v=$\SI{.3}{\kilo\ohm}\, i_1$] (4,2)
(2,0) to[I, i=1<\milli\ampere>, -*] (2,2)
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1.2]\draw
(0,0) node[ground] {}
to[V=$e(t)$, *-*] (0,2) to[C=4<\nano\farad>] (2,2)
to[R, l_=.25<\kilo\ohm>, *-*] (2,0)
(2,2) to[R=1<\kilo\ohm>] (4,2)
to[C, l_=2<\nano\farad>, *-*] (4,0)
(5,0) to[I, i_=$a(t)$, -*] (5,2) -- (4,2)
(0,0) -- (5,0)
(0,2) -- (0,3) to[L, l=2<\milli\henry>] (5,3) -- (5,2)
{[anchor=south east] (0,2) node {1} (2,2) node {2} (4,2) node {3}}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1.2]\draw
(0,0) node[anchor=east] {B}
to[short, o-*] (1,0)
to[R=20<\ohm>, *-*] (1,2)
to[R=10<\ohm>, v=$v_x$] (3,2) -- (4,2)
to[cI=$\frac{\siemens}{5} v_x$, *-*] (4,0) -- (3,0)
to[R=5<\ohm>, *-*] (3,2)
(3,0) -- (1,0)
(1,2) to[short, -o] (0,2) node[anchor=east]{A}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1]\draw
(0,0) node[transformer] (T) {}
(T.B2) to[pD] ($(T.B2)+(2,0)$) -| (3.5, -1)
(T.B1) to[pD] ($(T.B1)+(2,0)$) -| (3.5, -1)
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1]\draw
(5,.5) node [op amp] (opamp) {}
(0,0) node [left] {$U_{we}$} to [R, l=$R_d$, o-*] (2,0)
to [R, l=$R_d$, *-*] (opamp.+)
to [C, l_=$C_{d2}$, *-] ($(opamp.+)+(0,-2)$) node [ground] {}
(opamp.out) |- (3.5,2) to [C, l_=$C_{d1}$, *-] (2,2) to [short] (2,0)
(opamp.-) -| (3.5,2)
(opamp.out) to [short, *-o] (7,.5) node [right] {$U_{wy}$}
;\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1.2, american]\draw
(0,2) to[I=1<\milli\ampere>] (2,2)
to[R, l_=2<\kilo\ohm>, *-*] (0,0)
to[R, l_=2<\kilo\ohm>] (2,0)
to[V, v_=2<\volt>] (2,2)
to[cspst, l=$t_0$] (4,2) -- (4,1.5)
to [generic, i=$i_1$, v=$v_1$] (4,-.5) -- (4,-1.5)
(0,2) -- (0,-1.5) to[V, v_=4<\volt>] (2,-1.5)
to [R, l=1<\kilo\ohm>] (4,-1.5);
\begin{scope}[xshift=6.5cm, yshift=.5cm]
\draw [->] (-2,0) -- (2.5,0) node[anchor=west] {$v_1/\volt$};
\draw [->] (0,-2) -- (0,2) node[anchor=west] {$i_1/\SI{}{\milli\ampere}$} ;
\draw (-1,0) node[anchor=north] {-2} (1,0) node[anchor=south] {2}
(0,1) node[anchor=west] {4} (0,-1) node[anchor=east] {-4}
(2,0) node[anchor=north west] {4}
(-1.5,0) node[anchor=south east] {-3};
\draw [thick] (-2,-1) -- (-1,1) -- (1,-1) -- (2,0) -- (2.5,.5);
\draw [dotted] (-1,1) -- (-1,0) (1,-1) -- (1,0)
(-1,1) -- (0,1) (1,-1) -- (0,-1);
\end{scope}
\end{circuitikz}
\end{LTXexample}
\begin{LTXexample}[pos=t,varwidth=true]
\begin{circuitikz}[scale=1]
\ctikzset{bipoles/detector/width=.35}
\ctikzset{quadpoles/coupler/width=1}
\ctikzset{quadpoles/coupler/height=1}
\ctikzset{tripoles/wilkinson/width=1}
\ctikzset{tripoles/wilkinson/height=1}
%\draw[help lines,red,thin,dotted] (0,-5) grid (5,5);
\draw
(-2,0) node[wilkinson](w1){}
(2,0) node[coupler] (c1) {}
(0,2) node[coupler,rotate=90] (c2) {}
(0,-2) node[coupler,rotate=90] (c3) {}
(w1.out1) .. controls ++(0.8,0) and ++(0,0.8) .. (c3.3)
(w1.out2) .. controls ++(0.8,0) and ++(0,-0.8) .. (c2.4)
(c1.1) .. controls ++(-0.8,0) and ++(0,0.8) .. (c3.2)
(c1.4) .. controls ++(-0.8,0) and ++(0,-0.8) .. (c2.1)
(w1.in) to[short,-o] ++(-1,0)
(w1.in) node[left=30] {LO}
(c1.2) node[match,yscale=1] {}
(c1.3) to[short,-o] ++(1,0)
(c1.3) node[right=30] {RF}
(c2.3) to[detector,-o] ++(0,1.5)
(c2.2) to[detector,-o] ++(0,1.5)
(c3.1) to[detector,-o] ++(0,-1.5)
(c3.4) to[detector,-o] ++(0,-1.5)
;
\end{circuitikz}
\end{LTXexample}
\begin{tabular}{l}\label{ex:compatibility}
\IfFileExists{compatibility.pdf}
{\fbox{\includegraphics{compatibility.pdf}}}
\\
\begin{lstlisting}
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{positioning}
\usepackage[compatibility]{circuitikzgit}
\ctikzset{bipoles/length=.9cm}
\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,0) to [resistor={name=R}] (0,2)
to[diode={name=D}] (3,2);
\draw (0,0) to[*R=$R_1$] (1.5,0) to[*Tnpn] (3,0)
to[*D](3,2);
\end{tikzpicture}
\end{document}
\end{lstlisting}
\end{tabular}
% % changelog.tex will be updated by makefile from CHANGELOG.md
\section{Changelog and Release Notes}
\IfFileExists{changelog.tex}
{\sloppy\input{changelog.tex}}
{The file changelog.tex was not found, run 'make changelog' at toplevel to generate it with pandoc from CHANGELOG.md}
\printindex
\end{document}
|