Tikz Circuit
Tikz Circuit
CircuiTikZ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Massimo A. Redaelli
[email protected]
Stefan Lindner
[email protected]
Stefan Erhardt
[email protected]
Romano Giannetti
[email protected]
CircuiTikZ
version 1.4.2 (2021/07/26)
1 Introduction 8
1.1 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Loading the package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Installing a new version of the package. . . . . . . . . . . . . . . . . . . . . . . . . 9
1.5 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Incompatible packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.7 Known bugs and limitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.8 Scale factors inaccuracies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.9 Incompabilities between version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.10 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.11 Package options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Tutorials 16
2.1 Getting started with CircuiTikZ: a current shunt . . . . . . . . . . . . . . . . . . . 16
2.2 A non-inverting op-amp amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.1 Reusing the circuit: the easy way . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 A transistor-based amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4 A logic circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1
3.3.5 Style files: how to write them . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4 Subcircuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.4.1 Subcircuit definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.4.2 Using the subcircuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.2.1 Scaling, flipping and rotating subcircuits . . . . . . . . . . . . . . 45
3.4.3 Parameters in subcircuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2
4.5.5 Noise sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.5.6 Special sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.5.7 DC sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.5.8 Sources customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.5.8.1 Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.5.8.2 Waveform symbols. . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.5.8.3 Polarity symbols. . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.5.8.4 Three-phase symbols. . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.6 Instruments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.6.1 Instruments customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.6.1.1 Oscilloscope waveform. . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.2 Rotation-invariant elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.3 Instruments as node elements . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.6.4 Measuring voltage and currents, multiple ways . . . . . . . . . . . . . . . . 73
4.7 Mechanical Analogy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.7.1 Mechanical elements customizations . . . . . . . . . . . . . . . . . . . . . . 76
4.8 Miscellaneous bipoles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.8.1 Miscellanous element customization . . . . . . . . . . . . . . . . . . . . . . 77
4.9 Multiple wires (buses) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.10 Crossings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.11 Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.11.1 Arrows size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.11.2 Generic Tunable Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.12 Terminal shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.12.1 BNC connector/terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.13 Block diagram components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.13.1 Blocks anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.13.2 Blocks customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.13.2.1 Multi ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.13.2.2 Labels and custom two-port boxes . . . . . . . . . . . . . . . . . . 87
4.13.2.3 Box option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.13.2.4 Dash optional parts . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.14 Transistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.14.1 Standard bipolar transistors . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.14.2 Multi-terminal bipolar transistors . . . . . . . . . . . . . . . . . . . . . . . . 89
4.14.3 Field-effect transistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.14.4 Transistor texts (labels) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.14.5 Transistors customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.14.5.1 Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.14.5.2 Arrows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.14.5.3 Circles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3
4.14.5.4 Body diodes and similar things. . . . . . . . . . . . . . . . . . . . 94
4.14.5.5 Schottky transistors. . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.14.5.6 Ferroelectric transistors . . . . . . . . . . . . . . . . . . . . . . . . 96
4.14.5.7 IGBT outer base. . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.14.5.8 UJT transistors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.14.5.9 Base/Gate terminal. . . . . . . . . . . . . . . . . . . . . . . . . . . 97
4.14.5.10 Bulk terminals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
4.14.5.11 Simplified symbols for depletion-mode MOSFETs . . . . . . . . . 98
4.14.5.12 Gate/Base gap coloring. . . . . . . . . . . . . . . . . . . . . . . . . 99
4.14.6 Multiple terminal transistors customization . . . . . . . . . . . . . . . . . . 100
4.14.7 Transistor circle customization . . . . . . . . . . . . . . . . . . . . . . . . . 100
4.14.7.1 Position and size. . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
4.14.7.2 Line and color. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.14.8 Transistors anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.14.9 Transistor paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
4.15 Electronic Tubes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
4.15.1 Tubes customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.15.2 Other tubes-like components . . . . . . . . . . . . . . . . . . . . . . . . . . 108
4.15.2.1 Dynode customization. . . . . . . . . . . . . . . . . . . . . . . . . 109
4.16 RF components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.16.1 RF elements customization . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.16.2 Microstrip customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.17 Electro-Mechanical Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
4.17.1 Electro-Mechanical Devices anchors . . . . . . . . . . . . . . . . . . . . . . 112
4.18 Double bipoles (transformers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.18.1 Double dipoles anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.18.2 Double dipoles customization . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.18.3 Styling transformer’s coils independently . . . . . . . . . . . . . . . . . . . . 116
4.19 Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
4.19.1 Amplifiers anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
4.19.2 Amplifiers customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
4.19.2.1 European-style amplifier customization . . . . . . . . . . . . . . . 123
4.19.3 Designing your own amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.20 Switches and buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.20.1 Traditional switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.20.2 Cute switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.20.2.1 Cute switches anchors . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.20.2.2 Cute switches customization . . . . . . . . . . . . . . . . . . . . . 127
4.20.3 Rotary switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
4.20.3.1 Rotary switch anchors . . . . . . . . . . . . . . . . . . . . . . . . . 129
4.20.3.2 Rotary switch customization . . . . . . . . . . . . . . . . . . . . . 130
4
4.20.4 Switch arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
4.20.4.1 Rotary switch arrows. . . . . . . . . . . . . . . . . . . . . . . . . . 131
4.21 Logic gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
4.21.1 American Logic gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
4.21.2 IEEE logic gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
4.21.3 European Logic gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
4.21.4 Path-style logic ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
4.21.5 American ports usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.21.5.1 American logic port customization . . . . . . . . . . . . . . . . . . 136
4.21.5.2 American logic port anchors . . . . . . . . . . . . . . . . . . . . . 138
4.21.6 IEEE logic gates usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4.21.6.1 Stacking and aligning IEEE standard gates. . . . . . . . . . . . . . 141
4.21.6.2 IEEE standard ports customization . . . . . . . . . . . . . . . . . 142
4.21.6.3 IEEE standard ports anchors . . . . . . . . . . . . . . . . . . . . . 143
4.21.6.4 Transmission gate symbols. . . . . . . . . . . . . . . . . . . . . . . 143
4.21.7 European logic port usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
4.21.7.1 European logic port customization . . . . . . . . . . . . . . . . . . 144
4.21.7.2 European logic port anchors . . . . . . . . . . . . . . . . . . . . . 144
4.22 Flip-flops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
4.22.1 Custom flip-flops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.22.2 Flip-flops anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
4.22.3 Flip-flops customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.23 Multiplexer and de-multiplexer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
4.23.1 Mux-Demux: design your own shape . . . . . . . . . . . . . . . . . . . . . . 151
4.23.2 Mux-Demux customization . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4.23.3 Mux-Demux anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4.23.4 Mux-Demux special usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
4.24 Chips (integrated circuits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
4.24.1 DIP and QFP chips customization . . . . . . . . . . . . . . . . . . . . . . . 154
4.24.2 Chips anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
4.24.3 Chips rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
4.24.4 Chip special usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.25 Seven segment displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.25.1 Seven segments anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4.25.2 Seven segments customization . . . . . . . . . . . . . . . . . . . . . . . . . . 158
5
5 Labels, voltages and currents 160
5.1 Labels and Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.1.1 Label and annotation position. . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.1.1.1 Adjust label and annotation position. . . . . . . . . . . . . . . . . 161
5.1.2 Special symbols in labels and annotations. . . . . . . . . . . . . . . . . . . . 161
5.1.3 Labels and annotation orientation. . . . . . . . . . . . . . . . . . . . . . . . 162
5.1.4 Stacked (two lines) labels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
5.2 Currents and voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
5.2.1 Common properties of voltages and currents . . . . . . . . . . . . . . . . . . 167
5.3 Currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
5.4 Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
5.5 Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
5.5.1 European style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
5.5.2 Straight European style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
5.5.3 American style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
5.5.4 Raised American style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
5.5.5 Voltage position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
5.5.6 American voltages customization . . . . . . . . . . . . . . . . . . . . . . . . 176
5.6 Changing the style of labels, voltages, and other text ornaments . . . . . . . . . . . 176
5.7 Accessing labels text nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
5.8 Advanced voltages, currents and flows . . . . . . . . . . . . . . . . . . . . . . . . . 178
5.8.1 Activating the anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
5.8.2 Auxiliary information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.8.3 Fixed voltage arrows: an example of advanced voltage usage . . . . . . . . 181
5.9 Integration with siunitx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
7 Colors 189
7.1 Shape colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.2 Fill colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
7.2.1 Background colors different from white . . . . . . . . . . . . . . . . . . . . . 192
6
8 FAQ: Frequently asked questions 194
8.1 Using named nodes in circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
8.2 Using dashed (or colored) wires in circuits . . . . . . . . . . . . . . . . . . . . . . . 195
8.3 Errors when externalizing pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
8.4 Labels, voltages and currents woes . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
8.5 Global scaling and rotating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
8.6 Tunable components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
10 Examples 203
10.1 A red diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
10.2 Using the (experimental) siunitx syntax . . . . . . . . . . . . . . . . . . . . . . . 204
10.3 Photodiodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
10.4 A Sallen-Key cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
10.5 Mixing circuits and graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
10.6 RF circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
10.7 A styled low noise input stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
10.8 An example with the compatibility option . . . . . . . . . . . . . . . . . . . . . . 209
10.9 3-phases block schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
7
1 Introduction
Lorenzo and Mirella, 57 years ago, started a trip
that eventually lead to a lot of things — among
them, CircuiTikZ v1.0.
In loving memory — R.G., 2020-02-04
1.1 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.
1.2 License
Copyright © 2007–2021 by Massimo Redaelli, 2013–2021 by Stefan Erhardt, 2015–2021 by Stefan
Lindner, and 2018–2021 by Romano Giannetti. 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.
LATEX ConTEXt1
\usepackage{circuitikz} \usemodule[circuitikz]
TikZ will be automatically loaded; additionally, the TikZ libraries calc, arrows.meta, bending,
and fpu are loaded (the last one is used only on demand).
CircuiTikZ commands are just TikZ commands, so a minimum usage example would be:
R1
\tikz \draw (0,0) to[R=$R_1$] (2,0);
1 ConT
EXt support was added mostly thanks to Mojca Miklavec and Aditya Mahajan.
8
1.4 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 local texmf tree and the name of your distribution
on 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 https://circuitikz.github.io/circuitikz/ of the project, and download the version
you want. You will download a simple (biggish) file, called circuitikzgit.sty.
Now you can just put this file in your local texmf tree, if you have one, or simply adding it into
the same directory where your main file resides, and then use
\usepackage[...options...]{circuitikzgit}
instead of circuitikz. This is also advantageous for “future resilience”; the authors try hard not
to break backward compatibility with new versions, but sometimes, things happen.
1.5 Requirements
• tikz, version ≥ 3.1.5b (it should work with any version from 3.0 and up, but better use a
newer one);
• xstring, not older than 2009/03/13;
This manual has been typeset with CircuiTikZ 1.4.2 (2021/07/26) on TikZ 3.1.9a (2021/05/15).
9
1.7 Known bugs and limitation
CircuiTikZ will not work correctly with global (in the main circuitikz environment, or in
scope environments) negative scale parameters (scale, xscale or yscale), unless transform
shape is also used, and even in this cases the behavior is not guaranteed. Neither it will work
with angle-changing scaling (when xscale is different form yscale) and with the global 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 pic TikZ
feature, so basically don’t put components into pics.
A general solution for this problem is difficult to find; probably the best approach is to use a
scalebox command to scale the circuit instead of relying on internal scaling.
Nevertheless, Schrödinger’s cat found a solution which has been ported to CircuiTikZ: you can
use the key use fpu reciprocal which will patch a standard low-level math routine with a more
precise one.
The use fpu reciprocal key seems to have no side effects, but given that it is patching an
internal interface of TikZ it can break any time, so it is advisable to use it only if and when
needed.
10
• The TikZ fix for to[...] +(x,y) behavior (see 3.1.3) uncovered a bug in the positioning
of the labels in CircuiTikZ that is present since v0.8. So you must upgrade to v1.4.1 or
better if you have TikZ newer than 3.1.8 (and you want/need to use the +(x,y) syntax).
• There have been changes in (internal) parameters for capacitors in v1.4.1; now to change
them you should use the style interface (see 4.3.3).
• CircuiTikZ v1.4.0 introduce the rollback system for the package when using LaTeX; that
(at least in principle) should be completely backward-compatible.
• The path construction in v1.4.0 has been changed a bit (again). The change shouldn’t break
any circuit and correct a behavior that should have been fixed with the v1.2.1 change (see
below).
• Version 1.3.6 fixes several problems with the stacked labels; the most important change is
that now the bracing of arguments is respected as in version 1.3.0 for the other labels. The
special treatment in stacked labels (and only in stacked labels!) for the (still experimental2 )
siunitx compact syntax <...> has been removed: it was completely buggy before, and
silently ignored, now will throw an error.
• Version 1.3.3 fixes the direction of the arrows in tunable elements; before this version,
they were more or less random, now the arrow goes from bottom left to top right. You
have the option to go back to the old behavior with \ctikzset{bipoles/fix tunable
direction=false}. As a compensation for the fuss, now the arrows are configurable. To
learn more, see the FAQ: 8.6.
• Version 1.3.1 removes the warning if you do not specify a voltage direction.
• Version 1.3.0 fixes the buggy stripping of braces from labels and annotations (see 5.1.2).
• After 1.2.7 a big code reorganization (which had the collateral effect of fixing some bug) has
been made; no changes should be visible, but a fallback point at 1.2.7 has been added.
• You must upgrade to v1.2.7 or newer if you use a TikZ 3.1.8 or 3.1.8a (but better upgrade
both packages to the current version). You can check the TikZ version installed using the
macro \pgfversion.
• After v1.2.1: Important: the routine that implements the to[...] component positioning
has been rewritten. That should enhance the line joins in paths, and it’s safer, but it can
potentially change some old behavior.
One of the changes is that the previous routine did the wrong thing if you used (node)
to[...] (you should use an anchor or a coordinate, not a node there — like (node.anchor)
to[...]).
The other one was that in the structure ... to[...] node[pos=something] (coord) the
value of pos was completely wrong (even if you don’t use pos explicitly, remember it’s
pos=0.5 by default).
Additionally, the old code disrupted the TikZ path-fill mechanism, so that you could get
away with using the fill option on paths and having just the components filled, not the
path. That was incorrect, although sometime it was handy (sorry).
See the FAQ at section 8.1 for more information.
• After v1.2.0: voltage arrows, symbols and label positions are calculated with a rewritten
routine. There should be little change, unless you touched internal values…
2 and, really, not advised…
11
• After v1.1.3: from version 1.1.0 to version 1.1.2, the inverted Schmitt buffer in IEEE style
ports was called inv schmitt (with an additional space). The correct name is invschmitt
port (the same as the legacy american port).
• After v1.1.2: the position of american voltages for the open bipoles changed (you can revert
to the old behavior, see section 5.5.5).
• After v0.9.7: the position of the text of transistor nodes has changed; see section 4.14.4.
• 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 0.9.3 snapshot (see below for details).
• After v0.9.0: the parameters tripoles/american or port/aaa, ...bbb, ...ccc and ...ddd
are no longer used and are silently ignored; the same stands for the similarly named param-
eters in nor, xor, and xnor ports.
• After v0.9.0: voltage and current directions/signs (plus and minus signs in case of american
voltages and arrows in case of european voltages) have been rationalized with a couple
of new options (see details in section 5.2). The default case is still the same as v0.8.3, to
avoid potentially wrong circuits, but you would be better off with one of the new voltage
directions (EFvoltages or RPvoltages) for newer circuits.
• 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=).
• Since v0.7: The label behavior at mirrored bipoles has changed, this fixes the voltage drawing,
but perhaps you have to adjust your label positions.
• Since v0.5.1: The parts pfet, pigfete, pigfetebulk, and pigfetd are now mirrored by
default. Please adjust your yscale-option to correct this.
• Since v0.5: New voltage counting direction, there exists an option to use the old behavior.
If you have older projects that show compatibility problems, you have two options:
• 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;
• if you are using LATEX, the distribution has embedded several important old versions: 0.4,
0.6, 0.7, 0.8.3, 0.9.3, 0.9.6, 1.0, 1.1.2 and 1.2.7. To switch to use them, since v1.4.0
you simply use the new LaTeX kernel rollback system, changing your \usepackage invocation
to something like:
\usepackage[]{circuitikz}[=v0.8.3] % or v0.4, v0.6, ...
You can also specify a date instead of a version number: if you write
\usepackage[]{circuitikz}[=2020/02/05]
the rollback system will load the version that was current on February 5th, 2020 (in this
case it will be v1.0 which was released the day before).
If for whatever reasons your kernel is older, you can still use the old method of loading the
package-version package; for example:
\usepackage[]{circuitikz-0.8.3} % or circuitikz-0.4, 0.6...
12
which is an inferior solution because it can fool any package you use that depend on
circuitikz.
Both ways, you have to take care of the options that may have changed between versions
(and sometime syles, if you use them).
• if you are using ConTEXt, only versions 0.8.3, 0.9.3, 0.9.6, 1.0, 1.1.2 and 1.2.7 are
packaged; if can use it with
\usemodule[circuitikz-0.8.3]
1.10 Feedback
The easiest way to contact the authors is via the official Github repository: https://github.com/
circuitikz/circuitikz/issues. For general help question, a lot of nice people is quite active on
https://tex.stackexchange.com/questions/tagged/circuitikz — be sure to read the help
pages for the site and ask!
\begin{circuitikz}
84 V \draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
(2,2) to[V<=84<\volt>] (0,2)
2Ω -- (0,0);
?
\end{circuitikz}
84 V
Feel free to load the package with your own cultural options:
LATEX ConTEXt
\usepackage[american]{circuitikz} \usemodule[circuitikz][american]
+
−
\begin{circuitikz}
84 V \draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) --
(2,2) to[V<=84<\volt>] (0,2)
2Ω -- (0,0);
? \end{circuitikz}
+ −
84 V
13
However, most of the global package options are not available in ConTEXt; in that case you can
always use the appropriate \tikzset{} or \ctikzset{} command after loading the package.
• europeanvoltages: uses arrows to define voltages, and uses european-style voltage sources;
• straightvoltages: uses arrows to define voltages, and and uses straight voltage arrows;
• americanvoltages: uses − and + to define voltages, and uses american-style voltage sources;
• europeaninductors: uses rectangular filled shape for inductors, as per european standards;
• americaninductors: uses “4-bumps” shape for inductors, as per american standards;
• cuteinductors: uses my personal favorite, “pig-tailed” shape for inductors;
• siunitx: integrates with SIunitx package. If labels, currents or voltages are of the form
#1<#2> then what is shown is actually \SI{#1}{#2};
• nosiunitx: labels are not interpreted as above;
• fulldiode: the various diodes are drawn and filled by default, i.e. when using styles such
as diode, D, sD, …Other diode styles can always be forced with e.g. Do, D-, …
• strokediode: the various diodes are drawn and stroke by default, i.e. when using styles
such as diode, D, sD, …Other diode styles can always be forced with e.g. Do, D*, …
• emptydiode: the various diodes are drawn but not filled by default, i.e. when using styles
such as D, sD, …Other diode styles can always be forced with e.g. Do, D-, …
• arrowmos: pmos and nmos have arrows analogous to those of pnp and npn transistors;
• noarrowmos: pmos and nmos do not have arrows analogous to those of pnp and npn tran-
sistors;
14
• fetsolderdot: draw solderdot at bulk-source junction of some transistors;
• compatibility: makes it possibile to load CircuiTikZ and TikZ circuit library together.
• Voltage directions: until v0.8.3, there was an error in the coherence between american and
european voltages styles (see section 5.2) for the batteries. This has been fixed, but to
guarantee backward compatibility and to avoid nasty surprises, the fix is available with new
options:
The old options in the singular (like american voltage) are still available for compatibility, but
are discouraged.
Loading the package with no options is equivalent to the following options: [nofetsolderdot,
europeancurrents, europeanvoltages, americanports, americanresistors,
cuteinductors, europeangfsurgearrester, nosiunitx, noarrowmos, smartlabels,
nocompatibility, centertransistorstext].
15
2 Tutorials
Before even starting with CircuiTikZ you should be sure to have understood the basics of TikZ.
It is higlhly recommended that you read and go through at least the following parts of the TikZ
manual:
• “Tutorial: A Picture for Karl’s Students” (around page 30);
• “Specifying Coordinates” (around page 131)
• “Nodes and their shapes” (around page 220)
…but obviously a good knowledge of TikZ will help you a lot. Remember, a circuit drawn with
CircuiTikZ is nothing more than a tikzpicture with an (albeit powerful and extended) set of
shapes and commodity macros.
Said that, to draw a circuit, you have to load the CircuiTikZ package; this can be done with
\usepackage[siunitx, RPvoltages]{circuitikz}
somewhere in your document preamble. It will load automatically the needed packages if not
already done before.
\begin{circuitikz}[]
\draw (0,0) to[isource] (0,3) -- (2,3)
to[R] (2,0) -- (0,0);
\end{circuitikz}
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 1.11).
Let’s change the style for now (the author of the tutorial, Romano, is European — but he has
always used American-style circuits, so…); and while we’re at it, let’s add the other branch and
some labels.
\begin{circuitikz}[american]
\draw (0,0) to[isource, l=$I_0$] (0,3) -- (2,3)
16
You can use a single path or multiple paths when drawing your circuit, it’s just a question of style
(but be aware that closing paths perfectly could be non-trivial, see section 6.4), and you can use
standard TikZ lines (--, |- or similar) for the wires. Nonetheless, sometime using the CircuiTikZ
specific short component for the wires can be useful, because then we can add labels and poles
at them, like for example in the following circuit, where we add a current (with the key i=...,
see section 5.3) and a connection dot (with the special shortcut -* which adds a circ node at the
end of the connection, see sections 4.12 and 6.1).
I0 \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);
I0 R1 R2 \draw (2,3) -- (4,3)
to[R=$R_2$, i=$i_2$]
(4,0) to[short, -*] (2,0);
i1 i2 \end{circuitikz}
One of the problems with this circuit is that we would like to have the current labels 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 5.2 you can use the
position specifiers <>^_ after the key i:
I0 \begin{circuitikz}[american]
\draw (0,0) to[isource, l=$I_0$] (0,3)
i1 i2
to[short, -*, i=$I_0$] (2,3)
to[R=$R_1$, i>_=$i_1$] (2,0) -- (0,0);
I0 R1 R2 \draw (2,3) -- (4,3)
to[R=$R_2$, i>_=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
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 voltage shift
parameter to make a bit more space for it…
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:
17
I0 \begin{circuitikz}[european, voltage shift=0.5]
\draw (0,0)
i1 i2 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);
I0 V0 R1 R2 \draw (2,3) -- (4,3)
to[R=$R_2$, f>_=$i_2$]
(4,0) to[short, -*] (2,0);
\end{circuitikz}
And finally, this is still TikZ, so that you can freely mix other graphics element to the circuit.
18
2.2 A non-inverting op-amp amplifier
vi
Let’s now try to draw a non-inverting amplifier based +
on op-amps; the canonical implementation can be, for vo
OA1
example, this one from “electronics tutorials”. Obvi-
−
ously, the style and form of drawing a circuit is often
a matter of personal tastes and, maybe even more im- R2
portant, of the details you are focusing on; drawing
a non-inverting amplifier will be different if you are
drawing it to explain how it works or if you are simply R1
using it in a more complex circuit, assuming its op-
eration well known by the reader. Anyway, the final
objective is to have a circuit like the one on the right,
drawn so that it is easy to reuse.
We have to start the drawing from a generic point. Given that the idea is to have a reusable block,
instead of positioning the op-amp and build around it, we will start from the input “pole”:
vi \begin{circuitikz}[]
+ \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
OA1 node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
− ;
\end{circuitikz}
In this snippet, notice that the only absolute coordinate is the first one; that will enable us to
“copy and paste” the circuit in several places, or create a macro for it. We position a text node
above it, and then draw a wire with a pole to a relative (1,0) coordinate: in other word, we move
1 unit to the right drawing a short-circuit, which is the same as a wire. The usage of to[short...]
simplifies the position of the pole, but notice that we could have also written:
\draw (0,0) node[above]{$v_i$} node[ocirc]{} -- ++(1,0) ...
up
- −
Operational amplifier, type: node, fillable (node[op
out
amp]{}). Class: amplifiers.
+ +
down
where we notice the type of the component (it is a node-type component, so we have to use node
to position it) and the available “anchors”: points we can use to position the shape or to connect
to. Not all the anchors are explicitly printed in the description box; you should read further in
the manual and you’ll see a “component anchors” (4.19.1) section with the relevant information.
Anyway, the op-amp must be connected with the + anchor to our input wire, so we say anchor=+
in the option lists; this shifts the whole element so that the named anchor will lie at the current
position of the path. Moreover, normally the shape has the inverting input on the bottom side,
and we want it the other way around, so we use also noinv input up in the keys defining the
node. We could also have flipped the shape with yscale=-1, but in this case we should have
considered the effects on anchors and on the text; see section 3.2.1.
19
Now we can draw the resistors; let’s start with R1 . We will draw it going down vertically from
the - anchor — we have named the node OA so that will be OA.-. We will need to connect the R2
also, so we do the following:
• draw a wire going down, and mark a point where we want the feedback resistor to connect;
• then draw R1 and finally
vi
+
OA1 \begin{circuitikz}[scale=0.8, transform shape]
− \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
(OA.-) -- ++(0,-1) coordinate(FB)
to[R=$R_1$] ++(0,-2) node[ground]{}
R1 ;
\end{circuitikz}
We only miss the feedback resistor now. We will use orthogonal coordinates, writing:
\draw (FB) to[R=$R_2$] (FB -| OA.out) -- (OA.out)
• the coordinates which is on the horizontal of FB and on the vertical of OA.out: the -|
coordinate operation is quite mnemonic;
• then continue drawing to OA.out.
You can use a separate \draw command or just continue the path you were writing; the choice
is just personal preference, but be warned that it can affect the drawing of poles (see section 6.1
about this if you notice strange things).
Finally, we add the output and a couple of nodes:
vi
+ \begin{circuitikz}[scale=0.8, transform shape]
vo
OA1 \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
− node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
R2 (OA.-) -- ++(0,-1) coordinate(FB)
to[R=$R_1$] ++(0,-2) node[ground]{}
(FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
R1 to [short, *-o] ++(1,0) node[above]{$v_o$}
;
\end{circuitikz}
The last step to obtain the final look is to add a bit of styling. We want the op-amp filled with a
light cyan color, and we prefer to have the label aligned with the left side of the device:
20
vi \ctikzset{amplifiers/fill=cyan!20, component text=left}
+
vo \begin{circuitikz}[scale=0.8, transform shape]
OA1
− \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
R2
(OA.-) -- ++(0,-1) coordinate(FB)
to[R=$R_1$] ++(0,-2) node[ground]{}
(FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
R1
to [short, *-o] ++(1,0) node[above]{$v_o$}
;
\end{circuitikz}
The \ctikzset command choosing the style is better placed in the preamble, though. Style should
be coherent for all the document body, so avoiding stating it for every circuit is normally the best
strategy.
The easiest way to reuse the circuit is to put it in a macro. This is a very flexible way of doing it;
the only drawback is that the only easy way to position it is using the first coordinate: you will
not be able to move the component using “anchors”; that is more complex and will need the use
of subcircuits (but you will loose parameters…see section 3.4).
Defining a macro for our amplifier could be as easy as this:
\newcommand\myNIA[4]{%1: name of this amplifier, %2 start coordinate, %3 R1, %4 R2
\draw #2 coordinate(#1-in) to[short] ++(1,0)
node[op amp, noinv input up, anchor=+](#1-OA){\texttt{#1}}
(#1-OA.-) -- ++(0,-1) coordinate(#1-FB)
to[R=#3] ++(0,-2) node[ground]{}
(#1-FB) to[R=#4, *-] (#1-FB -| #1-OA.out) -- (#1-OA.out)
to [short, *-] ++(1,0) coordinate(#1-out)
;
}
We remove the open poles (it’s better to draw them at the end to avoid artefacts) and then we
make the names of the coordinates and of the nodes unique, by prepending a parameter that we
will provide at every invocation. Then we remove the labels (for simplicity here) and add a couple
of coordinates that we will be able to use from the outside when building our circuit.
And we can use it like in the following:
vi
\begin{circuitikz}[scale=0.7, transform shape
+ ]
OA1 + \myNIA{OA1}{(0,0)}{$R_1$}{$R_2$}
vo
− OA2
% start drawing from the output of OA1
R2 −
\myNIA{OA2}{(OA1-out)}{$R_3$}{$R_4$}
R4
\node [ocirc] at (OA1-in) {};
R1 \node [above] at (OA1-in) {$v_i$};
R3 \node [ocirc] at (OA2-out){};
\node [above] at (OA2-out) {$v_o$};
\draw (OA1-out) -| (OA2-in);
\end{circuitikz}
21
2.3 A transistor-based amplifier
The idea is to draw a two-stage amplifier for a lesson, or exercise, on the different qualities of BJT
and MOSFET transistors.
Please Notice that this section uses the “new” position for transistors labels, enabled since version
0.9.7. You should refer to older manuals to see how to do the same with older versions; basically
the transistor’s names where put with an additional node{} command.
Also 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 just a few
numbers that select relative positions and using symmetries. Crucially, this kind of spproach make
each block reusable in other diagrams bu just changing one coordinate.
First of all, let’s define a handy function to show the position of nodes:
\def\normalcoord(#1){coordinate(#1)}
\def\showcoord(#1){coordinate(#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}](){}}
\let\coord=\normalcoord
\let\coord=\showcoord
The idea is that you can use \coord() instead of coordinate() in paths, and that will draw sort
of markers showing them. For example:
C \begin{circuitikz}[american,]
\draw (0,0) node[npn](Q){};
B center \path (Q.center) \coord(center)
(Q.B) \coord(B) (Q.C) \coord(C)
E (Q.E) \coord(E);
\end{circuitikz}
After the circuit is drawn, simply commenting out the second \let command 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 \ctikzset{tripoles/mos style/arrows}:
\begin{circuitikz}[american,]
\ctikzset{tripoles/mos style/arrows}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
Q1 \path (0,0) -- (2,0); % bounding box
\draw (0,0) node[nmos](Q1){\killdepth{Q1}};
\end{circuitikz}
I had to do draw an invisible line to take into account the text for Q1 — the text is not taken
into account in calculating the bounding box. This is because the “geographical” anchors (north,
north west, …) are defined for the symbol only. In a complex circuit, this is rarely a problem.
Another thing I like to modify with respect to the standard is the position of the arrows in transis-
tors, which are normally in the middle the symbol. Using the following setting (see section 4.14.5)
will move the arrows to the start or end of the corresponding pin.
\ctikzset{transistors/arrow pos=end}
The tricky thing about \killdepth{} macro is finicky details. Without the \killdepth macro,
the labels of different transistor will be adjusted so that the vertical center of the box is at the
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):
22
\begin{circuitikz}[american,]
q1 m1 \draw (0,0) node[nmos](Q1){q1} ++(2,0)
node[nmos](M1){m1};
\draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
\draw (0,-2)node[nmos](Q1){\killdepth{q1}} ++(2,0)
node[nmos](M1){\killdepth{m1}};
q1 m1 \draw [red] (Q1.center) ++(0,-0.7ex) -- ++(3,0);
\end{circuitikz}
We will start connecting the first transistor with the power supply with a couple of resistors. Notice
that I am naming the nodes GND, VCC and VEE, so that I can use the coordinates to have all the
supply rails at the same vertical position (more on this later).
VCC = 10 V
VCC
RD
\begin{circuitikz}[american,]
10 kΩ \draw (0,0) node[nmos,](Q1){\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}$};
Q1 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$]
++(0,-1.5) node[ground](GND){};
% show the named coordinates!
\path (GND) \coord(GND)
C1 (VCC) \coord(VCC)
RS GND
(VEE) \coord(VEE);
\end{circuitikz}
5 kΩ
VEE
VEE = −10 V
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 (in |- GND) is the point with
the horizontal coordinate of (in) and the vertical one of (GND), lining it up with the ground of
the capacitor C1 (you can think it as “the point on the vertical of in and the horizontal of GND”).
23
VCC = 10 V
\begin{circuitikz}[american, scale=0.7, transform
shape]
RD
\draw (0,0) node[nmos,](Q1){\killdepth{Q1}};
10 kΩ \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}]
C2
++(0,3) node[vcc](VCC){$V_{CC}=\SI{10}{V}$};
in
vi = vi1 Q1 \draw (Q1.S) to[short] ++(2,0) to[C=$C_1$]
++(0,-1.5) node[ground](GND){};
RG
\draw (Q1.G) to[short] ++(-1,0)
1 MΩ C1 \coord (in) to[R, l2^=$R_G$ and \SI{1}{M\ohm}]
RS
(in |- GND) node[ground]{};
5 kΩ
\draw (in) to[C, l_=$C_2$,*-o]
++(-1.5,0) node[left](vi1){$v_i=v_{i1}$};
\end{circuitikz}
VEE = −10 V
Notice that the only absolute coordinate here is the first one, (0,0); so the elements are connected
with relative movements and can be moved by just changing one number (for example, changing
the to[C=$C_1$] ++(0,-1.5) will move all the grounds down).
This is the final circuit, with the nodes still marked:
% this is for the blue brackets under the circuit
\tikzset{blockdef/.style={%
{Straight Barb[harpoon, reversed, right, length=0.2cm]}-{Straight Barb[harpoon,
reversed, left, length=0.2cm]},
blue,
}}
\def\killdepth#1{{\raisebox{0pt}[\height][0pt]{#1}}}
\def\coord(#1){coordinate(#1)}
\def\coord(#1){coordinate(#1) node[circle, red, draw, inner sep=1pt,
pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm,
% we reset the arrow in pin edge to avoid carrying over the path one!
pin edge={red, overlay,-}]45:#1}](#1-node){}}
\begin{circuitikz}[american, ]
\draw (0,0) node[nmos,](Q1){\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) -- ++(2,0) \coord(bjt);
%
\draw (bjt) node[npn, anchor=B](Q2){\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
]{};
24
\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}
VCC = 10 V
RD
10 kΩ
bjt
C2 vo1 v12 Q2 C3
in load tmp
vi = vi1 Q1 vo2
RG
RL
1 MΩ C1 RE
RS 9.3 kΩ
5 kΩ
VEE = −10 V
tmp tmp
bloque 1 bloque 2
You can see that after having found the place where we want to put the BJT transistor (line 21),
we use the option anchor=B so that the base anchor will be put at the coordinate bjt.
Finally, if you like a more compact drawing, you can add the options (for example):
\begin{circuitikz}[american, scale=0.8] % this will scale only the coordinates
\ctikzset{resistors/scale=0.7, capacitors/scale=0.6}
...
\end{circuitikz}
and you will obtain the following diagram with the exact same code (I just removed the second
\coord definition to hide the coordinates markings).
25
VCC = 10 V
RD
10 kΩ
vo1 v12 Q2
C2 C3
vi = vi1 Q1 vo2
RG
RL
1 MΩ C1 RE
RS 9.3 kΩ
5 kΩ
VEE = −10 V
bloque 1 bloque 2
26
2.4 A logic circuit
Let’s suppose we want to reproduce the cir-
SR-FF
cuit on the right4 , maybe as part of a more
complex one. a0 S Q
Looking at the circuit to draw, I see that
CP
there is a basic block: the flip-flop with the
added three-port circuit to its left, marked
R Q
with the red dashed rectangle. The main
distance to respect here is that we want the
two ANDs in line with the flip-flop inputs,
so I’ll start with the flip-flop and then add
SR-FF
the rest of the block.
a1 S Q
The shapes are very similar to the IEEE
logic gates (see section 4.21.2); after a first
CP
check, the standard size of the port is a bit
too big with respect to the flip-flop, so I scale
R Q
them down a bit.
\ctikzset{
logic ports=ieee,
logic ports/scale=0.7,
} ENABLE CP RESET
I want a reusable block, so I will start from a coordinate and then use only relative, defining
coordinates along the way.
The first thing is to define a suitable flip-flop. The standard SR (see
4.22) is almost what we need, but not exactly the same. So let’s
S Q
define a new one:
CP
\tikzset{sr-ff/.style={flipflop, flipflop def={
t1=S, t2=CP, t3=R, t4={\ctikztextnot{Q}}, R Q
t6=Q, nd=1}},
}
Now we can add the “and” gates. For example, we can add the gates to the right like this:
SR-FF \begin{circuitikz}[]
\draw (0,0) node[sr-ff](FF){} (FF.bup)
S Q node[above]{SR-FF};
\draw (FF.pin 1) -- ++(-1,0) node[and port,
CP anchor=out](AND1){}
(FF.pin 3) -- ++(-1,0) node[and port,
R Q anchor=out](AND2){};
\end{circuitikz}
You can notice a pair of things here: first of all, the use of the anchor=out in the port, to tell
TikZ that we want the node moved so that the out anchor is the reference one. The second one is
that we have repeated the absolute shift (the ++(-1, 0)) twice. This is a bad practice; it is much
better to have the “free” parameters of a schematic just stated once, so that we can change them
in just one point.
You can of course use a macro, like \newcommand{\andshift}{(-1,0)} but it is much more
elegant to do something like this:
4 It seems a quite popular one on tex.stackexchange…
27
SR-FF \begin{circuitikz}[]
\draw (0,0) node[sr-ff](FF){} (FF.bup)
S Q node[above]{SR-FF};
\draw (FF.pin 1) -- ++(-1,0) node[and port,
CP anchor=out](AND1){}
(FF.pin 3) -- (FF.pin 3 -| AND1.out)
R Q node[and port, anchor=out](AND2){};
\end{circuitikz}
In this snippet, the coordinate (FF.pin 3 -| AND1.out) is the TikZ way to say “the point which
is horizontally straight from FF.pin 3 and vertically form AND1.out”. That way one can change
the number -1 to move both AND ports nearer or farther away.
Now we can add the not port. Since version 1.1.3 you can use a path-style not port, so you can
just say: this:
In earlier version, you should have found the center point between the two terminal, position the
“not” shape and ten connect it, like for example (this code must stay into the \draw command):
% let's position the NOT in the center
% this is using the calc tikz library
($(in)!0.5!(in |- AND2.in 2)$) node[not port, rotate=-90](NOT){}
% and connect it
(in) -- (NOT.in) (NOT.out) |- (AND2.in 2)
Now we have the basic block; we have to use it twice, so one of the possible way to do it is to
prepare a command. We will change the names of the nodes and the coordinates to be different
for any “call” of the block (another option is to use a pic; but this is more straightforward).
\newcommand*{\myblock}[1]{% Add #1- to the node and coord names
node[sr-ff](#1-FF){} (#1-FF.bup) node[above]{SR-FF}
(#1-FF.pin 1) -- ++(-1,0) node[and port, anchor=out](#1-AND1){}
(#1-FF.pin 3) -- (#1-FF.pin 3 -| #1-AND1.out)
node[and port, anchor=out](#1-AND2){}
(#1-AND1.in 1) to[short, -*] ++(-1,0) coordinate(#1-in)
to[inline not] (#1-in |- #1-AND2.in 2) -- (#1-AND2.in 2);
}
28
So now we can draw two of our blocks: A-in SR-FF
A-AND1.in 2
\draw (0,0) \myblock{A}; S Q
A-FF.pin 2
\draw (0,-4) \myblock{B};
A-AND2.in 1 CP
Part of the anchors and coordinates that we
have accessible are marked in red in the dia- R Q
A-FF.down
gram at the side.
Now we have to just connect the relevant
parts and add the labels. The names of the B-in
inputs are quite easy: SR-FF
B-AND1.in 2
\draw (A-in) -- ++(-0.5, 0) node[ S Q
B-FF.pin 2
below]{$a_0$};
\draw (B-in) -- ++(-0.5, 0) node[ B-AND2.in 1 CP
below]{$a_1$};
R Q
B-FF.down
And finally:
CP
R Q
SR-FF
a1 S Q
CP
R Q
ENABLE CP RESET
29
3 The components: usage
Components in CircuiTikZ come in two forms: path-style, to be used in to path specifications,
and node-style, which will be instantiated by a node specification.
where #1 is the name of the component, #2 is an (optional) label, and 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 4.14.9.
Most path-style components can be used as a node-style components; to access them, you add
a shape to the main name of component (for example, diodeshape). Such a “node name” is
specified in the description of each component.
3.1.1 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):
e
north west north north east
left right n
west east
s
center south west south east
south w
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{circuitikz}
\draw (0,0) to[potentiometer, name=P, mirror] ++(0,2);
\draw (P.wiper) to[L] ++(2,0);
\end{circuitikz}
Alternatively, that you can use the shape form, and then use the left and right anchors to do
your connections.
\begin{circuitikz}
\draw (0,0) node[potentiometershape, rotate=-90](P){};
\draw (P.wiper) to[L] ++(2,0);
\end{circuitikz}
30
3.1.2 Border anchors
Bipoles have also installed generic border anchors — that means, anchors that start at an angle.
For complexity reason, these are for most of the components simply a generic enclosing rectangle.
They interact in a non-trivial way with the mirror and invert keys, so it’s best not to use them
directly.
90 90 90
120 60 120 60 120 60
90 90
120 60 120 60
150 30 150 30 150 30 150 30
150 30
You can notice that the border anchors are a bit spaced out (this is useful because those anchors
are used to position labels and annotations). You can override this if you need to reach exactly the
border (whatever could that mean depends on the component) by using the key bipoles/border
margin, which is a number that states how much the enclosing border is stretched out (default
value is 1.1). For example, setting \ctikzset{bipoles/border margin=1} will make the border
anchor coincide with the geographical shape:
90 90 90
120 60 120 60 120 60
90 90
120 60 120 60
150 30 150 30 150 30 150 30 150 30
210
generic 330 210
resistor 330 210
fulldiode330 210 vsource 330
240
270
300 240
270
300 capacitivesens330
210
240 300 240 300
270 270 240 300
270
As noticed by user septatrix, although full relative coordinates after a component work as ex-
pected when using ++(x,y)-style coordinates, often there are problems when using the +(x,y)-
style coordinates (which are supposed to set a temporary relative coordinate and then going back
to the starting point).
These kind of coordinate have in practice little use for the building of circuits, so have been only
(very) lightly tested; avoid them if you can — the behavior will depend not only on the CircuiTikZ
version, but also on the TikZ layer underneath.
This behavior, although not optimal, was standard in to operation in plain TikZ before version
3.1.8; it was changed by Henri Menke in later versions. Notice that the change revealed a problem
in CircuiTikZ that should hopefully fixed in v1.4.1; for more details see this issue on GitHub.
31
You can see from the example below (notice the blue curve using a spline line). If all the vertical
lines are at the left, the manual has been compiled with a new CircuiTikZ and TikZ. Otherwise,
the red and/or blue curve will have the vertical line at the right (which in principle is wrong).
In the last (green) example, you can see a workaround using local path and the key current
point is local that will work for older (and do not create problem in newer) versions.
\begin{tikzpicture}
\draw[color=red] (0,0) to[R] +(2,0) +(0,0) -- ++(0,-1);
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\draw[color=blue] (0,0) to[out=30, in=120] +(2,0) +(0,0) -- ++(0,-1);
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\draw[color=purple] (0,0) to[] +(2,0) +(0,0) -- ++(0,-1);
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\draw[color=green!50!black] (0,0)
{[current point is local] to[R] +(2,0)} +(0,0) -- ++(0,-1);
\end{tikzpicture}
3.1.4 Customization
Pretty much all CircuiTikZ relies heavily on pgfkeys for value handling and configuration. Indeed,
at the beginning of circuitikz.sty and in the file 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 \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
circuitikz-0.9.3) if you dig into them.
3.1.4.1 Components size Perhaps the most important parameter is bipoles/length (default
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:
32
10 Ω
A
vx
20 Ω 5Ω
S
5 vx
B
\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}
10 Ω
A
vx
20 Ω 5Ω
S
5 vx
B
\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{\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}
The changes on 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{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}
33
Several groups of components, on the other hand, have a special 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 resistors/scale available:
\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}
1F
\ctikzset{bipoles/thickness=1}
\tikz \draw (0,0) to[C=1<\farad>] (2,0); \par
1F \ctikzset{bipoles/thickness=4}
\tikz \draw (0,0) to[C=1<\farad>] (2,0);
1Ω
\tikz \draw (0,0) to[R=1<\ohm>] (2,0); \par
1Ω \ctikzset{bipoles/resistor/height=.6}
\tikz \draw (0,0) to[R=1<\ohm>] (2,0);
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.
3.1.5 Descriptions
34
wiper pR: potentiometer, american style, type: path-style,
nodename: potentiometershape. Aliases: pR,
american potentiometer. Class: resistors.
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 fill=cyan!30!white:
The Class of the component (see section 3.3) is printed at the end of the description.
Most path-style components can be used as a node-style components; to access them, you add
a shape to the main name of component (for example, diodeshape). Such a “node name” is
specified in the description of each component.
Notice: Nodes must have curly brackets at the end, even when empty. An optional anchor
(#3) can be defined within round brackets to be addressed again later on. And please don’t
forget the semicolon to terminate the \draw command.
Also notice: If using the \tikzexternalize feature, as of Tikz 2.1 all pictures must end
with \end{tikzpicture}. Thus you cannot use the circuitikz environment.
Which is ok: just use the environment tikzpicture: everything will work there just fine.
35
3.2.1 Mirroring and flipping
Mirroring and flipping of node components is obtained by using the TikZ keys xscale and yscale.
Notice that this parameters affect also text labels, so they need to be un-scaled by hand.
− −
OA1 2AO \begin{circuitikz}[scale=0.7, transform shape]
+ + \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}};
OA3 OA4 \end{circuitikz}
+ +
To simplify this task, CircuiTikZ when used in LATEX has three helper macros — \ctikzflipx{},
\ctikzflipy{}, and \ctikzflipxy{}, that can be used to “un-rotate” the text of nodes drawn
with, respectively, xscale=-1, yscale=-1, and scale=-1 (which is equivalent to xscale=-1,
yscale=-1). In other formats they are undefined; contributions to fill the gap are welcome.
− −
OA1 OA2 \begin{circuitikz}[scale=0.7, transform shape]
+ +
\draw (0,3) node[op amp]{OA1};
\draw (3,3) node[op amp, xscale=-1]{\ctikzflipx{OA2}};
\draw (0,0) node[op amp, yscale=-1]{\ctikzflipy{OA3}};
+ + \draw (3,0) node[op amp, scale=-1]{\ctikzflipxy{OA4}};
OA3 OA4 \end{circuitikz}
− −
3.2.2 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.
3.2.3 Descriptions
All the shapes defined by CircuiTikZ. These are all pgf nodes, so they are usable in both 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 fill=cyan!30!white:
36
out
Plain amplifier, type: node, fillable (node[plain amp]{}).
Class: amplifiers.
Sometime, components will expose internal (sub-)shapes that can be accessed with the syntax
<node name>-<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”:
N-out 1.n
cout 1 out 1 Rotary switch, type: node (node[rotaryswitch](N){}).
cin
in mid Class: switches.
center N-out 4.w
The Class of the component (see section 3.3) is printed at the end of the description.
This code, with the default parameters, will render like the following image.
6 This is a just an example, the circuit is not intended to be functional.
37
C
5V
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio
Q2 ZL
Rm
−5 V
Component size can be changed globally (see section 3.1.4.1), or you can change their relative size
by scaling a family of components by setting the key class/scale; for example, you can change
the size of all the diodes in your circuit by setting diodes/scale to something different from the
default 1.0.
Remember that if you use a global scale (be sure to read section 1.7!) you change the coordinate
only, so using scale=0.8 in the environment options you have:
C
5V
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio Q2 ZL
Rm
−5 V
If you want to scale all the circuit, you have to use also transform shape:
38
C
5V
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio
Q2 ZL
Rm
−5 V
Using relative sizes as described in section 3.1.4.1 enables your style for the circuit. For example,
setting:
\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
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio
Q2 ZL
Rm
−5 V
Warning: relative scaling is meant to work for a reasonable range of stretching and shortening,
so try to keep your scale parameter in the 0.5 to 2.0 range (more or less). Bigger or smaller value
can result in awkward shapes.
You can also set a default fill color for the components. You can use the keys class/fill (which
defaults to none, no fill, i.e. transparent component) for all fillable components in the library.
If you add to the previous styles the following commands:
39
\ctikzset{
amplifiers/fill=cyan,
sources/fill=green,
diodes/fill=red,
resistors/fill=violet,
}
you will have the following circuit (note that the first generator is explicitly set to be yellow, so if
will not be colored green!):
C
5V
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio
Q2 ZL
Rm
−5 V
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 blue!30!white “closed” components, but that was largely to hinder
black-and-white photocopying…
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 bipoles, tripoles
and so on, see section 3.1.4.2); to override that you set the key class/thickness to any number.
The default is none, which means that the old way of selecting thickness is used.
For example, amplifiers have the legacy class of 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
\ctikzset{amplifier/thickness=4}
40
C
5V
R IB
− Rs
L OA1 Q1
+
D voQ
vs
vio
Q2 ZL
Rm
−5 V
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 style options that you could use in all
your documents.
When using styles, it is possible to use style files (see section 3.3.5), that then you can load with
the command \ctikzloadstyle. For example, in the distribution you have a number of style files:
legacy, romano, example. When you load a style name name, you will have available a style called
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:
\ctikzloadstyle{romano}
\tikzset{romano circuit style}
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{circuitikz}[legacy circuit style,
..., ]
...
\end{circuitikz}
If you just want to use one style, you can load and activate it in one command with
\ctikzsetstyle{romano}
The example style file will simply make the amplifiers filled with light blue:
\begin{circuitikz}
\draw (0,0) node[op amp]{OA1};
− − \end{circuitikz}
OA1 OA1 \ctikzloadstyle{example}
+ + \begin{circuitikz}[example circuit style]
\draw (0,0) node[op amp]{OA1};
\end{circuitikz}
41
The styles legacy is a style that set (most) of the style parameters to the default, and 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 3.3.5. In the next diagrams, the
left hand one is using the romano circuit style and the rigth hand one the legacy style.
C C
5V 5V
R IB R IB
− Rs − Rs
L OA1 Q1 L OA1 Q1
+ +
D voQ D voQ
vs vs
vio vio
Q2 ZL Q2 ZL
Rm Rm
−5 V −5 V
The best option is to start from 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 example, you edit a file named ctikzstyle-romano.tex with will
define and enact TikZ style with name example circuit style; basically it has to be something
along this:
% example style for circuits
% Do not use LaTeX commands if you want it to be compatible with ConTeXt
% Do not add spurious spaces
\tikzset{example circuit style/.style={%
\circuitikzbasekey/.cd,%
amplifiers/fill=blue!20!white,
},% end .style
}% end \tikzset
%
\endinput
This kind of style will add to the existing style. If you want to have a style that substitute the
current style, you should do like this:
\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,
[...]
}}
If you want to add a setting to your style file that has been recently added to the package (for
example, the thyristor compact shapes added in 1.3.5), but you want that your style file is still
compatible with older versions of CircuiTikZ, you can use the .try statement:
42
% Diodes
diodes/scale=0.6,
diodes/thickness=1.0,
thyristor style/.try=compact,
Or, in case of new values of existing “choice” keys, you can use the syntax:
% Logic ports
logic ports/ieee/.try,
% this way of setting the key does nothing if ieee option
% does not exist; logic ports/.try=ieee does not work
% if the key exists but the value is not defined
logic ports/scale=1.0,
3.4 Subcircuits
Starting from version 1.3.5, there is an experimental7 support for generating sub-circuits, or
circuits blocks. The creation and use of subcircuits is somewhat limited, to keep them simple and
easy to define and maintain.
A subcircuit is basically a path (and just one path!) of generic TikZ instructions, with a series
of accessible coordinates that behave more or less like anchors in the “real” shapes. The basic
limitation is that a subcircuit can be moved, replicated and placed around but it can’t be easily
personalized. Even if scaling and rotation is in principle possible, it is not easily done. Nevertheless,
they can be quite useful to build complex components and reusable blocks.
To define a block you use the \ctikzsubcircuitdef macro; this macro has 3 arguments:
• the first argument is the name of the subcircuit, and it must form a valid TeX command
name when prepended with a backslash: so just letters (no spaces, nor numbers, nor symbols
like underscores etc.);
• the second one is a comma-separated list of anchors names; here you can use whatever you
can use for naming a coordinate or a node (so it’s much more relaxed that the first one);
• finally, the commands that will draw the circuit. You must suppose you are in a \draw
command, with the start coordinate already set-up. You can (and should) use #1 as the
name of the current node, and you must define the coordinates of all the anchors listed
before as coordinate(#1-anchorname). You should not finish the path here and use only
relative coordinates or named ones.
working as-is, please use the GitHub project page and download and save the circuitikzgit.sty file for future-proof
use!
43
\ctikzsubcircuitdef{optovishay}{in 1, out 1, in 2, out 2, center}{%
% reference anchor is -center
coordinate(#1-center)
(#1-center) +(-1.2,-1) rectangle +(1.2,1)
(#1-center) ++(-1.2,0.8) coordinate (#1-in 1)
(#1-center) ++(-1.2,-0.8) coordinate (#1-in 2)
(#1-center) ++(1.2,0.8) coordinate (#1-out 1)
(#1-center) ++(1.2,-0.8) coordinate (#1-out 2)
(#1-center) ++(0,1) coordinate (#1-up)
(#1-in 1) -- ++(0.5,0) coordinate(#1-tmp)
to[leD*, diodes/scale=0.6, led arrows from cathode]
(#1-tmp|- #1-in 2) -- (#1-in 2)
(#1-out 1) -- ++(-0.5,0) coordinate(#1-tmp)
to[pD*, diodes/scale=0.4, mirror] ++(0,-0.5)
edge[densely dashed] ++(0,-0.533) ++(0,-0.566)
to[pD*, diodes/scale=0.4,mirror] (#1-tmp|- #1-out 2) -- (#1-out 2)
% leave the position of the path at the center
(#1-center)
}
Our element is a symbol for an optocoupler; in this case is the symbol used for one cell of the
double Vishay vo1263 device.
The name of the subcircuit is optovishay — notice we can use only letters here, upper or lowercase,
and nothing more. Then we have a series of anchor names; here we can use letters, numbers, spaces
and some symbol — but avoid the dot (.) and the hyphen (-). Additionally, the anchor named
subckt@reference is reserved and shouldn’t be used. If you use spaces, be on the safe side and
never use two or more consecutive spaces.
After that, you have to draw your subcircuit as if you where into a \draw command, starting
from a generic point. In this case, we decide to draw the circuit around this generic point so
that it will result to be the center of the block; so as a first thing, we “mark” the position of the
center anchor, with coordinate(#1-center). The #1 will be substituted with the specific name
of the subcircuit’s instance later — so if you then call one instance of the optocoupler opto1, that
coordinate will be called opto1-center.
We continue by defining all our anchors (there is no need to do that at the start, but it’s handy
because then you can use them). You must define all the anchors!
Important: all the coordinates used must be either relative, or named in the form #1-something;
absolute coordinate will not work when instantiating the block. The block is thought to be used
inside a path specification, so the idea is not to end the path — that means that changing line
styles or colors is at best difficult. You can still use edges, though (see 8.2).
After that, we draw our circuit; in this case a LED and a couple of smaller photodiodes will do.
We also define a coordinate -up (you can define more coordinates, in addition to the anchors, or
name elements with name=#1-something for later access) for adding text.
To use the subcircuit, an additional step is needed. Somewhere you have to activate it. This
is needed to calculate the relative positions of anchors using the current set of style parame-
ters. The normal place is to activate it just before usage; to do that you use the command
\ctikzsubcircuitactivate with the name of the subcircuit. That will define a new command,
\nameofthesubcircuit that you can use then in your paths.
So to check your subcircuit while defining it you can use this simple snippet:
44
\ctikzsubcircuitactivate{optovishay}
O1 O2 \begin{tikzpicture}
\draw (0,0) \optovishay{one}{};
\node [above] at (one-up) {O1};
\draw[color=blue] (one-out 1) -- ++(1,0)
\optovishay{two}{in 1};
\node [above] at (two-up) {O2};
\end{tikzpicture}
3.4.2.1 Scaling, flipping and rotating subcircuits To scale and rotate a subcircuit you
have to include it into a scope with the appropriate scale and rotation commands. Notice that,
as in general in CircuiTikZ, global scales that affect rotation works only if transform shape is
issued (see 1.7); nesting transform shape normally works, but it has been really lightly tested.
\ctikzsubcircuitactivate{optovishay}
\begin{tikzpicture}[scale=0.8, transform shape]
\draw (0,0) \optovishay{three}{};
\draw (three-out 1) -- ++(0.5,0) coordinate(here);
\begin{scope}[xscale=-1,rotate=-45,transform shape]
\draw (here) \optovishay{four}{out 1};
\end{scope}
\draw[blue] (three-out 2) -| (four-out 2);
\end{tikzpicture}
There are no additional parameters definable for subcircuit shapes; this is a bit of a pity, because
sometime they could be useful, especially for labels of objects. Given the need to use transform
shape to translate and rotate them, though, it is better not to add invariant-direction things (like
text) into the subcircuit, unless you are sure you will just translate them. One possibility is to
use additional macros and anchors for positioning, like in the following example.
Suppose you have defined
\ctikzsubcircuitdef{divider}{in, out}{%
coordinate (#1-in) to[R, l=~, name=#1-rh, -*] ++(2,0)
coordinate(#1-tmp) to[R, l=~, name=#1-rl] ++(0,-2)
node[tlground]{} (#1-tmp) --++(0.5,0) coordinate(#1-out)
}
R1 R3
\ctikzsubcircuitactivate{divider}
\begin{tikzpicture}
\draw (0,0) \mydiv{a}{in}{$R_1$}{$R_2$};
R2 R4 \draw (a-out) -- \mydiv{b}{in}{$R_3$}{$R_4$};
\end{tikzpicture}
45
4 The components: list
This section is dedicated to the full list of available components.
4.1.1 Grounds
For the grounds, the center anchor is put on the connecting point of the symbol, so that you can
use them directly in a path specification.
center
Ground, type: node (node[ground]{}). Class: grounds.
4.1.1.1 Grounds anchors Anchors for grounds are a bit strange, given that they have the
center spot at the same location than north and all the ground will develop “going down”:
north
north west north east right
left
center
west east
46
4.1.1.2 Grounds customization You can change the scale of these components (all the
ground symbols together) by setting the key grounds/scale (default 1.0).
The power supplies are normally drawn with the arrows shown in the list above.
4.1.2.1 Power supply anchors They are similar to grounds anchors, and the geographical
anchors are correct only for the default arrow.
north
north west north east
4.1.2.2 Power supplies customization You can change the scale of the power supplies by
setting the key power supplies/scale (default 1.0).
Given that the power supply symbols are basically arrows, you can change them using all the
options of the arrows.meta package (see the TikZ manual for details) by changing the keys
monopoles/vcc/arrow and monopoles/vee/arrow (the default for both is 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{circuitikz}
% next macro is available in ctikzmanutils.sty
VCC
\def\coord(#1){\showcoord(#1)<0:0.3>}
\draw (0,0)
vcc vee
node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
node[vee](vee){VEE} \coord(vee);
VEE \ctikzset{monopoles/vcc/arrow={Stealth[red, width=6pt,
VCC length=9pt]}}
\ctikzset{monopoles/vee/arrow={Latex[blue]}}
vcc vee
\draw (0,-2)
node[vcc](vcc){VCC} \coord(vcc) ++(2,0)
VEE node[vee](vee){VEE} \coord(vee);
\end{circuitikz}
However, arrows in TikZ are in the same class with the line thickness, so they do not scale with
neither the class power supplies scale nor the global scale parameter (you should use transform
canvas={scale…} for this).
If you want that the arrows behave like the legacy symbols (which are shapes), only in the arrow
definitions, you can use the special length parameter \scaledwidth10 in the arrow definition,
which correspond to the width of the legacy vcc or vee. Compare the effects on the following
circuit.
10 Thanks to @Schrödinger’s cat on TEX stackexchange site
47
10 V
10 V
vi
− vi
−
vo vo
+
+ 2V
2V −10 V
−10 V
\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}
48
ageneric: Generic asymmetric bipole, type:
path-style, fillable, nodename: agenericshape.
Class: resistors.
memristor: Memristor, type: path-style, fillable,
nodename: memristorshape. Aliases: Mr. Class:
resistors.
If americanresistors option is active (or the style [american resistors] is used; this is the
default for the package), the resistors are displayed as follows:
If instead europeanresistors option is active (or the style [european resistors] is used), the
resistors, variable resistors and potentiometers are displayed as follows:
49
thR: Thermistor, type: path-style, fillable,
nodename: thermistorshape. Aliases: thermistor.
Class: resistors.
thRp: PTC thermistor, type: path-style, fillable,
nodename: thermistorptcshape. Aliases: thermistor
ϑ
ptc. Class: resistors.
Since version 0.9.5, you can control the position of the wiper in potentiometers using the key
wiper pos, which is a number in the range [0, 1]. The default middle position is wiper pos=0.5.
\begin{circuitikz}[american]
\ctikzset{resistors/width=1.5, resistors/zigs=9}
\draw (0,0) to[pR, name=A] ++(0,-4);
B \draw (1.5,0) to[pR, wiper pos=0.3, name=B] ++(0,-4);
A \ctikzset{european resistors}
\draw (3,0) to[pR, wiper pos=0.8, name=C] ++(0,-4);
C \foreach \i in {A, B, C}
\node[right] at (\i.wiper) {\i};
\end{circuitikz}
Generic sensors have an extra anchor named label to help position the type of dependence, if
needed:
-t° \begin{circuitikz}
\draw (0,2) to[sR, l=$R$, name=mySR] ++(3,0);
\node [font=\tiny, right] at(mySR.label) {-t\si{\degree}};
L \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{\%}};
C \end{circuitikz}
+H%
The anchor is positioned just on the corner of the segmented line crossing the component.
50
4.2.3 Resistive components customization
4.2.3.1 Geometry. You can change the scale of these components (all the resistive bipoles
together) by setting the key resistors/scale (default 1.0). Similarly, you can change the widths
by setting resistors/width (default 0.8).
You can change the width of these components (all the resistive bipoles together) by setting the
key resistors/width to something different from the default 0.8.
For the american style resistors, you can change the number of “zig-zags” by setting the key
resistors/zigs (default value 3).
R
\begin{circuitikz}[
longpot/.style = {pR, resistors/scale=0.75,
P 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);
R
\end{circuitikz}
4.2.3.2 Thickness. The line thickness of the resistive components is governed by the class
thickness; you can change it assigning a value to the key resistors/thickness (default none,
that means bipoles/thickness is used, and that defaults to 2.0; the value is relative to the base
line thickness).
We can call modifiers the elements that are added to the basic shape to express some characteristics
of the component; for example the arrows for the variable resistors or the bar for the sensors.
Normally the thickness of this elements is the same as the one chosen for the component11 . You
can change their thickness with the class key modifier thickness which is relative to the main
component thickness.
\begin{circuitikz}[american]
\draw (0,2) to[vR] ++(2,0) to[sR] ++(2,0);
\ctikzset{resistors/thickness=4}
\draw (0,1) to[vR] ++(2,0) to[sR] ++(2,0);
\ctikzset{resistors/modifier thickness=0.5}
\draw (0,0) to[vR] ++(2,0) to[sR] ++(2,0);
\end{circuitikz}
4.2.3.3 Arrows. You can change the arrow tips used in tunable resistors (vR, tgeneric) with
the key tunable end arrow and in potentiometers with the key wiper end arrow (by default
the key is the word “default” to obtain the default arrow, which is latexslim for both). Also
you can change the start arrow with the corresponding tunable start arrow or wiper start
arrow (the default value “default” is equivalent to {} for both, which means no arrow).
You can change that globally or locally, as ever. The tip specification is the one you can find in
the TikZ manual (“Arrow Tip Specifications”).
11 Due to a bug in versions before 1.3.4, that didn’t happen for thermistors
51
\begin{circuitikz}[american]
% globally all the potentiometrs
\ctikzset{wiper end arrow={Kite[open]}}
\draw (0,0) to[tgeneric] ++(2,0)
% set locally on this variable resistor
to[vR, tunable end arrow={Stealth[red]},
tunable start arrow={Bar}, invert] ++(0,-2)
to[pR] ++(-2,0);
\end{circuitikz}
4.3.1 Capacitors
curve left
center feC: Ferroelectric capacitor12 , type: path-style,
kink left
kink right
fillable, nodename: ferrocapshape. Aliases:
ferrocap. Class: capacitors.
curve right
Capacitors are fillable since v1.4.1; this is normally just a stylistic option but in the case of
ferroelectric capacitors that could be used to show the state of the hysteresis of the component.
12 suggested by Mayeul Cantan
52
\begin{tikzpicture}[]
C1
\ctikzset{capacitors/.cd,
thickness=4, modifier thickness=0.5}
\draw (0,0) to[feC, l=$C_1$, v=v1] ++(3,0)
S1
to[feC, l=$C_2$, fill=green, name=C2] ++(0,-2);
v1 C2 \node [font=\tiny, above right, inner sep=1pt]
at(C2.kink left) {$S_1$};
\end{tikzpicture}
There is also the (deprecated13 — its polarity is not coherent with the rest of the components)
polar capacitor:
You can change the scale of the capacitors by setting the key capacitors/scale to something
different from the default 1.0. For thickness, you can use the same keys (applied to the capacitors
class) as for resistors in 4.2.3.2.
Variable capacitors arrow tips follow the settings of resistors, see section 4.2.3.3.
The relative size of the capacitors is a bit of a mixed bag, because each one has historically different
internal parameters that makes maintaining coherence quite difficult. In v1.4.1 this has changed
and now you can use styling options to change the way the capacitors look. The main parameter
you can set is capacitors/width (default 0.2), which controls the standard distance between
plates. That will change all the components (notice that piezoelectric and cpe default width is
twice the size of a standard capacitor — although this is not evident for the cpe given its shape.)
The capacitors/height key is available also to set the height of the capacitor; the default is 0.6
for most of the capacitors, but 0.5 for electrolytic ones and 0.7 for piezoelectric. When used, it
will set all of them at the same value, which is a good thing.
If you want that only a specific kind of capacitor has a different value for a key, you can always
use a style which will have a local scope, as in the following example.
13 Thanks to Anshul Singhv for noticing.
53
+ \begin{tikzpicture}
\draw (0,1) to [C] ++(1,0) to [elko] ++(1,0);
\ctikzset{capacitors/width=0.15, capacitors/height=0.5}
+
\draw (0,0) to [C] ++(1,0) to [elko] ++(1,0);
\tikzset{big elko/.style={elko=#1, capacitors/width=0.3}}
+ \draw (0,-1) to [C] ++(1,0) to[big elko] ++(1,0);
\end{tikzpicture}
4.3.4 Inductors
If the cuteinductors option is active (default behaviour), or the style [cute inductors] is used,
the inductors are displayed as follows:
core west core east vL: Variable inductor, type: path-style, nodename:
vcuteinductorshape. Aliases: variable cute
inductor. Class: inductors.
sL: Inductive sensor, type: path-style, nodename:
scuteinductorshape. Aliases: cute inductive sensor.
label Class: inductors.
If the americaninductors option is active (or the style [american inductors] is used), the
inductors are displayed as follows:
core west core east vL: Variable inductor, type: path-style, nodename:
vamericaninductorshape. Aliases: variable american
inductor. Class: inductors.
sL: Inductive sensor, type: path-style, nodename:
samericaninductorshape. Aliases: american
label
inductive sensor. Class: inductors.
Finally, if the europeaninductors option is active (or the style [european inductors] is used),
the inductors are displayed as follows:
54
For historical reasons, chokes comes only in the cute. You can use the core west and core east
anchors (see 4.3.6.2) to build your own core lines for the other inductors.
You can change the scale of the inductors by setting the key inductors/scale to something
different from the default 1.0. For thickness, you can use the same keys (applied to the inductors
class) as for resistors in 4.2.3.2.
Variable inductors arrow tips follow the settings of resistors, see section 4.2.3.3.
You can change the width of these components (all the inductors together, unless you use style
or scoping) by setting the key inductors/width to something different from the default, which is
0.8 for american and european inductors, and 0.6 for cute inductors.
Moreover, you can change the number of “coils” drawn by setting the key inductors/coils
(default value 5 for cute inductors and 4 for american ones). Notice that the minimum number
of coils is 1 for american inductors, and 2 for cute ones.
L
\begin{circuitikz}[
longL/.style = {cute inductor, inductors/scale=0.75,
inductors/width=1.6, inductors/coils=9}]
\draw (0,1.5) to[L, l=$L$] ++(4,0);
L
\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);
L \end{circuitikz}
4.3.5.1 Chokes can have single and double lines, and can have the line thickness adjusted
(the value is relative to the thickness of the inductor). In general, you should use the anchors
(see 4.3.6.2) to add core lines to inductors.
\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}
55
4.3.6.1 Taps. Inductors have an additional anchor, called 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{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}
4.3.6.2 Core anchors. Inductors have additional anchors to add core lines (for historical
reasons, there is a cute choke component also, but to use inductors in the chosen style you better
use these anchors). The anchors are called core west and core east and they are positioned
at a distance that you can tweak with the \ctikzset key bipoles/inductors/core distance
(default 2pt).
\begin{circuitikz}[]
L \ctikzset{american}
\draw (0,3) to[L=$L$, name=myL] ++(2,0);
\draw[thick] (myL.core west) -- (myL.core east);
\ctikzset{cute inductors}
L
\draw (0,1.5) to[L=$L$, name=myL] ++(2,0);
\draw[densely dashed] (myL.core west) -- (myL.core east);
\ctikzset{european, bipoles/inductors/core distance=4pt}
L \draw (0,0) to[L=$L$, name=myL, label distance=2pt] ++(2,0);
\draw[thick, double] (myL.core west) -- (myL.core east);
\end{circuitikz}
Notice that the core lines will not change the position of labels. You have to move them by hand
if needed (or position them on the other side); see 5.1.1.1.
The package options fulldiode, strokediode, and emptydiode (and the styles [full
diodes], [stroke diodes], and [empty diodes]) define which shape will be used by ab-
breviated commands such that D, sD, zD, zzD, tD, pD, leD, VC, Ty,Tr (no stroke symbol
available!).
56
empty diode: Empty diode, type: path-style,
fillable, nodename: emptydiodeshape. Aliases: Do.
Class: diodes.
empty Schottky diode: Empty Schottky diode,
type: path-style, fillable, nodename:
emptysdiodeshape. Aliases: sDo. Class: diodes.
57
full photodiode: Full photodiode, type: path-style,
nodename: fullpdiodeshape. Aliases: pD*. Class:
diodes.
These shapes have no exact node-style counterpart, because the stroke line is built upon the empty
variants:
58
4.4.1 Tripole-like diodes
The following tripoles are entered with the usual command, of the form to[Tr, …]. In the
following list you can see the traditional, or legacy, shape of the Thyristors-type devices.
gate
empty triac: Empty triac, type: path-style,
fillable, nodename: emptytriacshape. Aliases: Tro.
Class: diodes.
gate
G thyristor: Standard thyristor (shape depends on pack-
age option), type: path-style, fillable, nodename:
emptythyristorshape. Aliases: Ty. Class: diodes.
anode cathode
gate
put: Standard Programmable Unipolar Transis-
G
tor14 (shape depends on package option), type:
path-style, fillable, nodename: emptyputshape.
Aliases: PUT. Class: diodes.
anode cathode
59
full put: Full PUT, type: path-style, nodename:
fullputshape. Aliases: PUT*. Class: diodes.
gate
agtobar: Standard GTO with bar-type gate on anode
G
(shape depends on package option), type: path-style,
fillable, nodename: emptyagtobarshape. Aliases:
aGTOb. Class: diodes.
anode cathode
60
stroke agtobar: Stroke GTO, bar-type on an-
ode, type: path-style, fillable, nodename:
emptyagtobarshape. Aliases: aGTOb-. Class: diodes.
For basically stylistical reasons, there is a different, more compact, shape available for them,
activated with the key thyristor style=compact (the default is legacy). All the devices above
are present, we will show here just the automatic version for shortness.
G
triac: Standard triac (shape depends on package op-
tion), type: path-style, fillable, nodename:
emptytriacshape. Aliases: Tr. Class: diodes.
anode cathode
gate
thyristor: Standard thyristor (shape depends on pack-
G
age option), type: path-style, fillable, nodename:
emptythyristorshape. Aliases: Ty. Class: diodes.
anode cathode
gate
put: Standard Programmable Unipolar Transistor
G (shape depends on package option), type: path-style,
fillable, nodename: emptyputshape. Aliases: PUT.
anode cathode Class: diodes.
gate
gto: Standard gto (shape depends on package op-
G
tion), type: path-style, fillable, nodename:
emptygtoshape. Aliases: GTO. Class: diodes.
anode cathode
gate
gtobar: Standard GTO with a bar symbol on the gate
G (shape depends on package option), type: path-style,
fillable, nodename: emptygtobarshape. Aliases:
anode cathode GTOb. Class: diodes.
gate
agtobar: Standard GTO with bar-type gate on anode
G (shape depends on package option), type: path-style,
fillable, nodename: emptyagtobarshape. Aliases:
anode cathode aGTOb. Class: diodes.
When inserting a thrystor, a triac or a potentiometer, one needs to refer to the third node-gate
(gate or G) for the former two; wiper (wiper or W) for the latter one. This is done by giving a
name to the bipole:
\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}
61
As commented above, you can change the shape of these devices (globally or locally) setting the key
thyristor style=compact (the default is legacy). Additionally, normally the plain GTO symbols
come without the arrows, but you can add them using a syntax similar to the one explained in
section 4.2.3.3 using the arrow group gto gate.
\begin{circuitikz}[]
\ctikzset{thyristor style=compact}
\draw (0,0) to[GTO=$G_1$] ++(0,-3);
G1 G2 G2 \ctikzset{gto gate end arrow=latexslim}
\draw (2,0) to[GTO*=$G_2$, mirror] ++(0,-3);
\draw (4,0) to[GTOb-=$G_2$, mirror] ++(0,-3);
\end{circuitikz}
Notice that you can set both gto gate end arrow and gto gate start arrow — choosing just
one of the two you can decide the “rotation” direction of the symbol. There is little space though,
so don’t overdo it.
You can change the scale of the diodes by setting the key diodes/scale to something different
from the default 1.0. In Romano’s opinion, diodes are somewhat big with the default style of the
package, so a setting like \ctikzset{diode/scale=0.6} is recommended.
D
\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)
D node[npn, anchor=B]{};
\end{circuitikz}
You can change the direction of the LEDs and photodiodes’ arrows by using the binary keys led
arrows from cathode and pd arrows to cathode (the default are led arrows from anode and
pd arrows to anode), as you can see in the following example.
\begin{circuitikz}
\ctikzset{led arrows from anode} % default
\ctikzset{pd arrows to anode} % default
\ctikzset{full diodes}
\draw (0,0) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
\ctikzset{stroke diodes}
\draw (0,-1) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
\ctikzset{empty diodes}
\draw (0,-2) to[leD] ++(1.5,0) to[pD] ++(1.5,0);
62
4.5 Sources and generators
Notice that source and generators are divided in three classes that can be styled independently:
traditional battery symbols (class batteries), independent generators (class sources) and de-
pendent generators (class 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.
4.5.1 Batteries
63
If (default behaviour) europeancurrents option is active (or the style [european currents]
is used), the shorthands current source, isource, and I are equivalent to european
current source. Otherwise, if americancurrents option is active (or the style [american
currents] is used) they are equivalent to american current source.
Similarly, if (default behaviour) europeanvoltages option is active (or the style [european
voltages] is used), the shorthands voltage source, vsource, and V are equivalent to
european voltage source. Otherwise, if americanvoltages option is active (or the style
[american voltages] is used) they are equivalent to american voltage source.
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.
V
− + \begin{circuitikz}[american]
\draw (0,1) to[sV=$V$] ++(3,0);
\draw (0,0) to[sI=$I$] ++(3,0);
I \end{circuitikz}
64
european controlled current source: Controlled
current source (european style), type: path-style,
fillable, nodename: cisourceshape. Aliases:
cisource. Class: csources.
cute european controlled current source: Cur-
rent source (cute european style), type: path-style,
fillable, nodename: cisourceCshape. Aliases:
cisourceC, cceI. Class: csources.
american controlled current source: Controlled
current source (american style), type: path-style,
fillable, nodename: cisourceAMshape. Aliases:
cisourceAM. Class: csources.
empty controlled source: Empty controlled
source, type: path-style, fillable, nodename:
ecsourceshape. Aliases: ecsource. Class: csources.
If (default behaviour) europeancurrents option is active (or the style [european currents]
is used), the shorthands controlled current source, cisource, and cI are equivalent to
european controlled current source. Otherwise, if americancurrents option is active
(or the style [american currents] is used) they are equivalent to american controlled
current source.
Similarly, if (default behaviour) europeanvoltages option is active (or the style [european
voltages] is used), the shorthands controlled voltage source, cvsource, and cV are
equivalent to european controlled voltage source. Otherwise, if americanvoltages op-
tion is active (or the style [american voltages] is used) they are equivalent to american
controlled voltage source.
The following two behave like the corresponding independent sources, see section 4.5.3.
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.
65
noise current source: Sinusoidal current source, type:
path-style, nodename: isourceNshape. Aliases:
isourceN, nI. Class: sources.
You can change the fill color with the key circuitikz/bipoles/noise sources/fillcolor:
en en \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);
in in
\draw(3,-2) to [nI, l=$i_n$] ++(2,0);
\end{scope}
\end{circuitikz}
If you prefer a patterned noise generator (similar to the one you draw by hand) you can use the
fake color dashed:
en en \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);
in in
\draw(3,-2) to [nI, l=$i_n$] ++(2,0);
\end{scope}
\end{circuitikz}
Notice that if you choose the dashed style, the noise sources are fillable:
\begin{circuitikz}
en en \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);
in in
\draw(3,-2) to [nI, l=$i_n$, fill=blue!50!white
] ++(2,0);
\end{scope}
\end{circuitikz}
66
esource: Empty voltage source, type: path-style,
fillable, nodename: esourceshape. Class: sources.
The transformer shapes vector group options can be specified for the primary (prim=value), the
secondary (sec=value) and tertiary (tert=value) three-phase vector groups: the value can be
one of delta, wye and zig.
\begin{circuitikz}
\draw (0,0) to[oosourcetrans, prim=zig, sec=delta, o-] ++(2,0)
to[oosourcetrans, prim=delta, sec=wye,-o] ++(0,-2)
to[ooosource, prim=wye, sec=zig, tert=delta] (0,0);
\end{circuitikz}
4.5.7 DC sources
The size of the broken part of the DC current source is configurable by changing the value of
bipoles/dcisource/angle (default 80); values must be between 0 (no circle at all, probably not
useful) and 90 (full circle, again not useful).
15 Added by André Alves in v1.3.5
16 The oosourcetrans and ooosource componentes have benn added by user @olfline on GitHub
67
\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}
4.5.8.1 Size. You can change the scale of the batteries by setting the key batteries/scale,
for the controlled (dependent) sources with csources/scale, and for all the other independent
sources and generators with sources/scale, to something different from the default 1.0.
Notice that the size of the double-circle sources (and of the triple-circle one) are tuned so that
the full source occupy more or less the same horizontal space than one of the single-circle one;
obviously, the circle are much smaller. If you want to have the same circle radius, you have to
scale (locally!) those sources by one factor that is 1.5384 (1/0.65) for oosource, 1.6667 (1/0.6)
for oosourcetrans, and 1.8182 (1/0.55) for ooosource.
\begin{circuitikz}
\draw[color=red] (0,0) to[esource] ++(3,0);
\draw (0,0) to[oosourcetrans, prim=delta, sec=wye,
sources/scale=1.667] ++(3,0);
\end{circuitikz}
4.5.8.2 Waveform symbols. Internal symbols of sinusoidal, triangular and square sources are
drawn with the same line thickness as the component by default. You can modify this by setting
the key sources/symbols/thickness for independent sources and the corresponding csource/...
for dependent ones. The value used here is relative to the component (i.e. the circle) value.
Normally the symbol is oriented in the same direction as the line, and rotate rigidly with the com-
ponent; you can change this orientation using the key sources/symbols/rotate or csource/....
The default value is 90 which correspond to the “line” direction (remember, path component are
defined as horizontal ones). If instead of an angle value you use auto, the symbol will be rotated
so that the waveform is always vertical, similar to what happens in instruments:
\begin{circuitikz}
\draw (0,1) to[sqV] ++(3,0)
to[sqV] ++(1,-1)
to[sqV] ++(0,-3);
\ctikzset{sources/symbol/rotate=auto}
\ctikzset{sources/symbol/rotate=auto, sources/symbol/
thickness=3}
\draw[color=red] (0,0) to[sqV] ++(3,0)
to[sqV] ++(0,-3)
to[sqV] (0,0);
\end{circuitikz}
68
4.5.8.3 Polarity symbols. The symbols drawn into the american voltage source17 can be
changed by using the \ctikzset keys bipoles/vsourceam/inner plus and .../inner minus
(by default they are $+$ and $-$ respectively, in the current font), and move them nearer of
farther away by twiddling bipoles/vsourceam/margin (default 0.7, less means nearer).
You can do the same with the american controlled voltage sources, substituting cvsourceam
to vsourceam (notice the initial “c”).
\begin{circuitikz}[american]
5Ω \ctikzset{bipoles/vsourceam/inner plus={\tiny $+$}}
\ctikzset{bipoles/vsourceam/inner minus={\tiny $-$}}
\draw (0,0) to[V, l_=$V$] ++(0,3)
to[R=\SI{5}{\ohm}] ++(3,0)
+ ⊕ to[V, invert,
−
V ⊖
bipoles/vsourceam/inner plus={\color{red}\tiny $\oplus$},
bipoles/vsourceam/inner minus={\color{blue}\tiny $\ominus
$},
bipoles/vsourceam/margin=0.5]
++(0,-3) to[short, -*] (0,0) node[ground]{};
\end{circuitikz}
4.5.8.4 Three-phase symbols. The three-phase symbols delta, wye, and zig follows the line
thickness exactly as the waveform ones (see above). Additionally, you can scale them up and down
by changing the value of the keys sources/symbol/delta scale, .../wye scale, and .../zig
scale (default 1).
4.6 Instruments
17 Since version 1.1.0, thanks to the suggestions and discussion in this TeX.SX question.
69
left right rmeter: Round meter (use t=... for the symbol), type:
path-style, fillable, nodename: rmetershape.
center Class: instruments.
left right rmeterwa: Round meter with arrow (use t=... for the
symbol), type: path-style, fillable, nodename:
rmeterwashape. Class: instruments.
center
left right
smeter: Square meter (use t=... for the symbol), type:
path-style, fillable, nodename: smetershape.
center Class: instruments.
in 1 in 2
left right
qpprobe: QUCS-style power probe, type: path-style,
fillable, nodename: qpprobeshape. Class:
center instruments.
v+ v-
left right
oscope: Oscilloscope18 , type: path-style, fillable,
nodename: oscopeshape. Class: instruments.
in 1 in 2
i
left right iloop: Current loop (symbolic), type: path-style,
nodename: iloopshape. Class: instruments.
center
i+ i-
left iloop2: Current loop (real), type: path-style,
nodename: iloop2shape. Class: instruments.
right
center
You can change the scale of all the instruments (including the current loops) by setting the key
instruments/scale to something different from the default 1.0.
18 Suggested by @nobrl on GitHub
70
4.6.1.1 Oscilloscope waveform. You can change the waveform shown in the oscilloscope
“screen”19 . To change it, you just set the key bipoles/oscope/waveform to one of the available
shape. You have available the shapes in the following list (the default is ramps):
\begin{circuitikz}
\foreach [count=\i] \wvf in {ramps, sin, square, triangle, lissajous, zero, none} {
\ctikzset{bipoles/oscope/waveform=\wvf}
\draw ({2*\i},1.4) node[oscopeshape](O){}
({2*\i},0.65) node[anchor=base]{\texttt{\wvf}};
}
\ctikzset{bipoles/oscope/width=1.0}
\foreach [count=\i] \wvf in {ramps, sin, square, triangle, lissajous, zero, none} {
\ctikzset{bipoles/oscope/waveform=\wvf}
\draw ({2*\i},0) node[oscopeshape]{};
}
\end{circuitikz}
If you want more or different shapes, you can define your owns, but you have to use low-level pgf
commands (see part IX, “The Basic Layer”, in the PGF/TikZ manual). The code is executed into
a \pgfscope …\endpgfscope environment, and it must use the path built with a \pgfusepath.
The coordinates have been scaled so that the external box of the scope is a rectangle between
(-1cm, -1cm) and (1cm, 1cm); the oscilloscope grid is fixed and painted between (-0.75cm,
-0.5cm) and (0,75cm, 0.5cm). If you stretch the scope with the …width or …height keys, the
drawing will be stretched too.
\ctikzset{%
bipoles/oscope/waveform/mywave/.code={%
\pgfsetcolor{red}
\pgfpathmoveto{\pgfpoint{-.75cm}{-.5cm}}
\pgfpathlineto{\pgfpoint{.75cm}{.5cm}}
\pgfusepath{draw}
\pgfsetcolor{green}
\pgfpathmoveto{\pgfpoint{-.75cm}{.5cm}}
\pgfpathlineto{\pgfpoint{.75cm}{-.5cm}}
\pgfusepath{draw}
}}
\begin{circuitikz}
\ctikzset{bipoles/oscope/waveform=mywave}
\draw (0,0) node[oscopeshape]{};
\end{circuitikz}
The oscope element will not rotate the “graph” shown with the component:
19 Suggested by Mario Tafur on TeX.SX
71
\begin{circuitikz}
\foreach \a in {0,45,...,350} {
\draw (0,0) to[oscope] (\a:3);
}
\end{circuitikz}
% local override
\draw (0,0) to[smeter, t=A, rotated instruments]
++(300:3);
\end{circuitikz}
The node-style usage of the oscope is also interesting, using the additional in 1 and in 2 an-
chors; 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 bipoles/oscope/width and
bipoles/oscope/height keys (which both default to 0.6).
\begin{circuitikz}
C1 \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}
C2 \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}
72
4.6.4 Measuring voltage and currents, multiple ways
This is the classical (legacy) option, with the voltmeter and ammeter. The problem is that
elements are intrinsically horizontal, so they look funny if put in vertically.
\begin{circuitikz}
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [ammeter] ++(0,-2) node[ground]{};
V
So the solution is often changing the structure to keep the meters in horizontal position.
V \begin{circuitikz}
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [ammeter] ++(2,0) --
A ++(0,-1) node[ground]{};
\draw (1,0) -- (1,1) to[voltmeter]
++(2,0) node[ground]{};
\end{circuitikz}
Since version 0.9.0 you have more options for the measuring instruments. You can use the generic
rmeterwa (round meter with arrow), to which you can specify the internal symbol with the option
t=... (and is fillable).
+ \begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
v V A to [rmeterwa, t=A, i=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[rmeterwa, t=V, v=$v$] ++(0,-2)
− i node[ground]{};
\end{circuitikz}
This kind of component will keep the symbol horizontal, whatever the orientation:
v
+ − \begin{circuitikz}[american]
V \draw (0,0) -- ++(1,0) to[R] ++(2,0)
to [rmeterwa, t=A, i=$i$] ++(2,0) --
i ++(0,-1) node[ground]{};
A
\draw (1,0) -- (1,1) to[rmeterwa, t=V, v^=$v$]
++(2,0) node[ground]{};
\end{circuitikz}
73
+ \begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
v V A to [rmeter, t=A, i=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[rmeter, t=V, v=$v$] ++(0,-2)
− i node[ground]{};
\end{circuitikz}
If you prefer it, you have the option to use square meters, in order to have more visual difference
from generators:
+ \begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
v to [smeter, t=A, i=$i$] ++(0,-2) node[ground]{};
V A \draw (1,0) to[smeter, t=V, v=$v$] ++(0,-2)
− i node[ground]{};
\end{circuitikz}
Another possibility is to use QUCS20 -style probes, which have the nice property of explictly
showing the type of connection (in series or parallel) of the meter:
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(2,0)
v i to [qiprobe, l=$i$] ++(0,-2) node[ground]{};
\draw (1,0) to[qvprobe, l=$v$] ++(0,-2)
node[ground]{};
\end{circuitikz}
If you want to explicitly show a power measurement, you can use the power probe qpprobe and
using the additional anchors v+ and v- :
\begin{circuitikz}[american]
\draw (0,0) to[short,-*] ++(1,0) coordinate(b)
to[R] ++(2,0) to [qpprobe, l=$i$, a=$v$, name=P]
v i ++(0,-2.5) node[ground](GND){};
\draw (P.v-) -| ++(-0.5,-1) coordinate(a)
to [short, -*] (a-|GND);
\draw (P.v+) -| (b);
\end{circuitikz}
\begin{circuitikz}[american]
\draw (0,0) -- ++(1,0) to[R] ++(3,0)
+ to [iloop, mirror, name=I] ++(0,-2)
node[ground] (GND){};
v \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}
20 QUCS is an open source circuit simulator: http://qucs.sourceforge.net/
74
Or, if you want a more physical structure for the measurement setup:
\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}
75
4.7.1 Mechanical elements customizations
You can change the scale of all the mechanical elements by setting the key mechanicals/scale
to something different from the default 1.0.
You can tune how big is the gap in the openbarrier component by setting the key bipoles/openbarrier/gap
(default value 0.5; 0 means no gap and 1 full gap).
76
lamp: Lamp, type: path-style, fillable, nodename:
lampshape. Class: misc.
north
north west north east
north
north west north east
You can use microphones and loudspeakers with waves (see section 4.16) too:
\begin{circuitikz}
\draw (0,0) to[mic, name=M] ++(0,2)
A 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}
You can change the scale of all the miscellaneous elements by setting the key misc/scale to
something different from the default 1.0.
77
tmultiwire: Triple line multiple wires22 , type:
path-style, nodename: tmultiwireshape. Aliases:
tmultiwire. Class: default.
\begin{circuitikz}
6 \draw (0,0) to[multiwire=4] ++(1,0);
\draw (0,-2) to[bmultiwire=6] ++(1,0);
\draw (0,-4) to[tmultiwire=3] ++(1,0);
\end{circuitikz}
4.10 Crossings
Path style:
Node style:
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{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}
However, sometime it is advisable to mark the non-contact situation more explicitly. To this end,
you can use a path-style component called crossing:
\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}
22 added by olfline
78
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 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{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}
Notice that the plain crossing and the 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 bipoles/crossing/size (default
0.2).
4.11 Arrows
These are pseudo-arrows used in lot of places in the packages (for transistors, flows, currents, and
so on). The first three arrows are magnified by a factor 3 in the boxes below; for the trarrow, the
anchor tip is exactly on the tip and btip is slightly receded.
center
tip
Arrow the same size of currarrow but only filled., type:
node (node[trarrow]{}). No class.
btip
Ip text Arrow used for the flows, with a text anchor, type: node
west east
(node[flowarrow]{$I_p$}). No class.
center
You can use the parameter 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 circuitikz/current arrow scale if you use it into a node.
79
f
\begin{circuitikz}
\draw (0,0) to[R, i=f] ++(2,0) node[npn, anchor=B]{};
f \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}
f
Moreover, you have the arrow tip latexslim which is an arrow similar to the old (in deprecated
arrows library) latex' element:
\begin{circuitikz}[american,]
\draw [latexslim-latexslim] (0,0) -- (1,0);
\end{circuitikz}
The basic passive components (resistors, capacitors and inductors) come with a “tunable version”
(see for example 4.2.3.3) that conveys the information that their value is adjustable. For generic
components you can obtain a similar effect with the extra macro \ctikztunablearrow, introduced
in version 1.4.1. The macro should be called as:
\ctikztunablearrow[extra options]{thickness}{length}{angle}{name}
where extra options is an optional argument with generic TikZ keys, thickness is the relative
thickness (referred to the current line width when the macro is invoked), length is the length of
the arrow with respect to the diagonal size of the component, angle is the inclination with respect
to the normal direction of the component23 , and finally name is the reference name of the bipole
or node.
The arrows are the ones set with the keys tunable start arrow and tunable end arrow (to
maintain coherency across the circuit), but you can override them in the extra options argument
as shown in the following example.
\begin{circuitikz}
\draw (0,0) node[tlground]{} to[sV, name=A] ++(0,3)
− node[op amp, anchor=+](B){};
\ctikztunablearrow{1}{1.2}{30}{A}
+ \ctikzset{tunable start arrow={Bar},
tunable end arrow={Stealth}}
\ctikztunablearrow[color=green,
{Latex[reversed]}-Circle]{1}{1.2}{90}{A}
\ctikztunablearrow[color=blue, densely dashed]{1}{1.2}{-30}{A}
\begin{scope}[transparency group, opacity=0.5]
\ctikztunablearrow[red, shorten <=3mm]{6}{0.8}{110}{B}
\end{scope}
\end{circuitikz}
Notice also the need to force a transparency group if you want a semitransparent arrow.
23 which is the left-to-right direction of the component when shown in the component box in this manual.
80
4.12 Terminal shapes
These are the so-called “bipole nodes” shapes, or poles (see section 6.1). These nodes are always
filled; the “open” versions (starting with an o) are by default filled with the color specified by the
key open nodes fill (by default white), but you can override locally it with the fill parameter.
Since version 0.9.0, “bipole nodes” shapes have all the standard geographical anchors, so you can
do things like these:
\begin{circuitikz}[american,]
\draw (0,-1) node[draw](R){R};
R \draw (R.east) node[ocirc, right]{};
\end{circuitikz}
The size of the poles is controlled by the key nodes width (default 0.04, relative to the basic
length). Be sure to see section 6.1 for more usage and configurability.
left right
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{circuitikz}
\draw (0,0)
vi 50 Ω vo 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}
81
It also has a zero anchor if you need to rotate it about its real center.
\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}
north
west east
adder, type: node, fillable (node[adder]{}). Class:
blocks.
south
n
out2
wilkinson divider, type: node, fillable
in
(node[wilkinson]{}). Class: blocks.
out1
out2
resistive splitter24 , type: node, fillable
in
(node[splitter]{}). Class: blocks.
out1
up
left right
gridnode25 , type: node, fillable (node[gridnode]{}).
Class: blocks.
center down
24 added by matthuszagh
25 added by olfline
82
mod
26 added by dl1chb
83
fft: FFT, type: path-style, fillable, nodename:
FFT fftshape. Class: blocks.
84
dc1 ac1
left
tdcac: three phases AC/DC converter, type:
right
path-style, fillable, nodename: tdcacshape.
ac2
dc2 Class: blocks.
center ac3
port4 port3
Generic fourport, type: node, fillable
(node[fourport]{}). Class: blocks.
port1 port2
left up right up
Coupler, type: node, fillable (node[coupler]{}). Class:
blocks.
left down right down
The ports of the mixer, adder, oscillator and circulator can be addressed with west, south,
east, north; the equivalent left, down, right, up; or the shorter w, s, e, n ones:
\begin{circuitikz} \draw
n (0,0) node[mixer] (mix) {}
(mix.w) node[left] {w}
w e (mix.s) node[below] {s}
(mix.e) node[right] {e}
s (mix.n) node[above] {n}
;\end{circuitikz}
Moreover, the have proper border anchors since version 1.2.3, so you can do things like this:
\begin{circuitikz}
\draw (0,0) node[adder] (mix) {}
(-1,1) -- ++(0.5,0) -- (mix)
(-1,-1) -- ++(0.5,0) -- (mix) -- ++(1,0);
\draw [red, <-] (mix.45) -- ++(1,1);
\end{circuitikz}
Those components have also deprecated anchors named 1, 2, 3, 4; they are better not used
because they can conflict with the border anchor. They still work for backward compatibility, but
could be removed in a future release.
85
\begin{circuitikz} \draw
4 (0,0) node[mixer] (mix) {}
(mix.1) node[left] {1} (mix.2) node[below] {2}
1 3 (mix.3) node[right] {3} (mix.4) node[above] {4};
\draw [ultra thick, red, opacity=0.5]
2 (-1,-1)--(1,1)(-1,1)--(1,-1);
DON’T USE \node [red, below] at (0,-1) {DON'T USE};
\end{circuitikz}
\begin{circuitikz} \draw
(0,0) node[wilkinson] (w) {\SI{3}{dB}}
3 dB (w.in) to[short,-o] ++(-0.5,0)
out2 (w.out1) to[short,-o] ++(0.5,0)
(w.out2) to[short,-o] ++(0.5,0)
in (w.in) node[below left] {\texttt{in}}
out1 (w.out1) node[below right] {\texttt{out1}}
(w.out2) node[above right] {\texttt{out2}}
;
\end{circuitikz}
Also they have the simpler 1, 2, 3, 4 anchors, and although they have no border anchors (for
now), it is better not to use them.
86
\begin{circuitikz} \draw(0,1.5) %bounding box
(0,0) node[coupler] (c) {\SI{10}{dB}}
(c.1) to[short,-o] ++(-0.5,0)
10 dB (c.2) to[short,-o] ++(0.5,0)
(c.3) to[short,-o] ++(0.5,0)
4 3 (c.4) to[short,-o] ++(-0.5,0)
(c.1) node[below left] {\texttt{1}}
(c.2) node[below right] {\texttt{2}}
1 2 (c.3) node[above right] {\texttt{3}}
(c.4) node[above left] {\texttt{4}}
;
\end{circuitikz}
You can change the scale of all the block elements by setting the key blocks/scale to something
different from the default 1.0.
With the option > you can draw an arrow to the input of the block diagram symbols.
\begin{circuitikz} \draw
(0,0) to[short,o-] ++(0.3,0)
A to[lowpass,>] ++(2,0)
D to[adc,>] ++(2,0)
to[short,-o] ++(0.3,0);
\end{circuitikz}
4.13.2.1 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{circuitikz} \draw
(0,0) node[mixer] (m) {}
(m.w) to[short,-o] ++(-1,0)
(m.s) to[short,-o] ++(0,-1)
(m.e) to[short,-o] ++(1,0)
(m.w) node[inputarrow] {}
(m.s) node[inputarrow,rotate=90] {};
\end{circuitikz}
4.13.2.2 Labels and custom two-port boxes You can use the keys t, t1, t2 (shorthands
for text, text in, text out) to fill the generic blocks:
\begin{circuitikz} \draw
B
(0,0) to[short,o-] ++(0.3,0)
to[allpass,>] ++(2,0)
in to[twoport,>,t={B}] ++(2,0)
out to[twoportsplit,t1={\tiny in},
t2={\tiny\color{red}out}] ++(0,-2.5);
\end{circuitikz}
Some two-ports have the option to place a normal label (l=) and a inner label (t=).
\begin{circuitikz}
LNA \ctikzset{bipoles/amp/width=0.9}
\draw (0,0) to[amp,t=LNA,l_=$F{=}0.9\,$dB,o-o] ++(3,0);
F =0.9 dB \end{circuitikz}
87
4.13.2.3 Box option Some devices have the possibility to add a box around them. The inner
symbol scales down to fit inside the box.
\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}
4.13.2.4 Dash optional parts To show that a device is optional, you can dash it. The inner
symbol will be kept with solid lines.
10 dB opt. \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}
4.14 Transistors
body C in
body C out
npn, type: node (node[npn, bodydiode]{}). Class:
transistors.
body E out
body E in
88
photo npn, type: node (node[npn,photo]{}). Class:
nobase
transistors.
body E in
body E out
Q Lpigbt, type: node (node[Lpigbt, bodydiode]{Q}).
Class: transistors.
body C out
body C in
In addition to the standard BJTs transistors, since version 0.9.6 the bjtnpn and bjtpnp are also
available; these are devices where you can have more collectors and emitters (on the other hand,
they have no photo nor bodydiode options — they are silently ignored).
Basically they are the same as the normal npn and pnp, and they (by default) have similar sizes;
the options collectors and emitters will change the number of the relative terminals. The base
terminal is connected midway from the collector and the emitter, not on the center of the base; a
cbase anchor is available if you prefer to use it. The label of the component (the text) is set on
the right side, vertically centered around the base terminal. They will accept the schottky base
key.
89
C
nobase
C1
B Q center bjt npn, type: node (node[bjtnpn, collectors=1,
E1 emitters=2]{Q}). Class: transistors.
cbase E2
nobase E2
E1
B Q bjt pnp, type: node (node[bjtpnp, collectors=3,
C1 emitters=2]{Q}). Class: transistors.
cbase C2
C3
D
hemt without base terminal, type: node (node[hemt,
G Q
nobase]{Q}). Class: transistors.
nogate
S
nfets and pfets have been incorporated based on code provided by Clemens Helfmeier and
Theodor Borsche. Use the package options fetsolderdot/nofetsolderdot to enable/disable
90
solderdot at some fet-transistors. Additionally, the solderdot option can be enabled/disabled for
single transistors with the option solderdot and nosolderdot, respectively.
91
JFET are also available28 , both n-type and p-type.
S
p-type JFET, type: node (node[pjfet]{}). Class:
G transistors.
D
UJT transistors29 have a different anchor names although most of the others, like D and G, work
also (the exception is E and emitter!). Notice that if used with nobase, the anchor E follows the
wire, while G is fixed (as is kink).
B1
kink
E Q n-type UJT, type: node (node[nujt]{Q}). Class:
transistors.
G B2
kink
E B1
p-type UJT, type: node (node[pujt]{Q}). Class:
G Q transistors.
B2
B1
kink
E n-type UJT with nobase option, type: node (node[nujt,
Q
nobase]{Q}). Class: transistors.
G B2
isfet:
Graphene fet have been added in version 1.3.230 . They look better if you set transistors/arrow
pos=end and transistor/thickness=3 or higher for them, so they are plotted with this option
here.
28 based on code provided by Danilo Piazzalunga
29 sugged by user JetherReis on GitHub.
30 added by Romano Giannetti after a suggestion by Cees Keyer.
92
outer hex up
N-type graphene FET, type: node, fillable
Q right (node[ngfet]{Q}). Class: transistors.
outer hex down
inner hex up
pgfet, type: node, fillable (node[pgfet]{Q}). Class:
Q
transistors.
inner hex down
In versions before 0.9.7, transistors text (the node text) was positioned near the collector ter-
minal; since version 0.9.7 the default has been changed to a more natural position near the
center of the device, similar to the multi-teminal transistors. You can revert to the old behav-
ior locally with the key legacy transistors text, or globally by setting the package option
legacytransistorstext.
Notice the use of the utility functions \ctikzflip{x,y,xy} as explained in section 3.2.1.
4.14.5.1 Size. You can change the scale of all the transistors by setting the key transistors/scale
(default 1.0). The size of the arrows (if any) is controlled by the same parameters as currarrow
(see section 4.11.1) and the dots on P-type transistors (if any) are the same as the nodes/poles
(see section 6.1).
4.14.5.2 Arrows. 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 transistors/arrow
pos=end (the default value is legacy).
\begin{circuitikz}
\ctikzset{tripoles/mos style=arrows}
\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}
93
If the option arrowmos is used (or after the command \ctikzset{tripoles/mos style/arrows}
is given), this is the output:
You can go back to the no-arrows mos with noarrowmos locally or with \ctikzset{tripoles/mos
style/no arrows}.
4.14.5.3 Circles. Since 1.2.6, you can add a circle31 to most of the transistor shapes — with
the exception of multi-terminal (bjtnpn and bjtpnp, where it would be awkward anyway) and
graphene FETs. The circle is intended in some case as the component’s housing, and used to
distinguish discrete components from integrated ones.
To add the circle to a single transistor, you use the tr circle keys in the node; if you want all
of your transistors with a circle, you can set the property tr circle with a \ctikzset command
(it will respect normal grouping, of course); in that case, you can use tr circle=false to locally
disable them.
\begin{circuitikz}[]
\draw (0,2) node[npn]{} (2,2) node[npn, tr circle](Q){};
% collector connected to housing
\node [circ] at (Q.circle C){};
\ctikzset{tr circle=true} % or \ctikzset{tr circle} alone
\draw (0,0) node[nigfete]{}
(2,0) node[nigfete, tr circle=false]{};
\end{circuitikz}
4.14.5.4 Body diodes and similar things. For all transistors (minus bjtnpn and bjtpnp)
a body diode (or freewheeling or flyback diode) can automatically be drawn. Just use the global
option bodydiode, or for single transistors, the tikz-option bodydiode. As you can see in the next
example, the text for the diode is moved if a bodydiode is present (but beware, if you change a
lot the relative dimension of components, it may become misplaced):
31 Suggested by Matthias Jung on GitHub
94
1
\begin{circuitikz}
\draw (0,0) node[npn,bodydiode](npn){1}
++(2,0)node[pnp,bodydiode](npn){};
\draw (0,-2) node[nigbt,bodydiode](npn){2}
2 ++(2,0)node[pigbt,bodydiode](npn){};
\draw (0,-4) node[nfet,bodydiode](npn){3}
++(2,0)node[pfet,bodydiode](npn){};
\end{circuitikz}
You can use the body ... anchors to add more or different things to the transistors in addition
(or instead) of the flyback diode.
4.14.5.5 Schottky transistors. The Schottky transistors are generated by adding the schottky
base key (there is also a no schottky base key that can be used if you use the other one as a de-
fault). You can change the size of the Schottky “hook” changing the parameter tripoles/schottky
base size with \ctikzset{} (default 0.05; the unit is the standard resistor length, scaled if
needed.)
\begin{circuitikz}
\draw (0,4) node[npn]{}
++(2,0) node[npn, schottky base]{};
\draw (1,2) node[bjtnpn, collectors=2, emitters=3,
schottky base, rotate=90]{};
\tikzset{schottky base}
\ctikzset{tripoles/schottky base size=0.1}
\draw (0,0) node[pnp]{}
++(2,0) node[npn, no schottky base]{};
\end{circuitikz}
95
4.14.5.6 Ferroelectric transistors You can add the ferroelectric modifier32 to the *mos and
*fet transistor types. Similarly to the Schottky bipolar transistors, you activate it by adding the
ferroel gate key (there is also a no ferroel base key that can be used if you use the other
one as a default).
The mark will follow the transistors class thickness, but you can adjust it independently using
the class parameter modifier thickness as in passive components — this value is relative to the
class’ thickness.
\begin{circuitikz}
\draw (0,2) node[nmos]{}
++(2,0) node[nmos, ferroel gate]{};
\ctikzset{ferroel gate} % by default from now on
\ctikzset{transistors/.cd, % class properties
thickness=1, modifier thickness=3}
\draw (0,0) node[pfet]{}
++(2,0) node[pfet, no ferroel gate]{};
\end{circuitikz}
4.14.5.7 IGBT outer base. Normally, in bipolar IGBTs the outer base is the same size
(height) of the inner one, and of the same thickness (which will depend on the class thickness
value). You can change this by setting (via \ctikzset`) the keys tripoles/igbt/outer base
height (default 0.4, the same as base height), and tripoles/igbt/outer base thickness
(default 1.0), which will be relative to the class thickness.
\begin{circuitikz}
\draw (0,0)
-- ++(1,0) node[nigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[pigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[Lnigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[Lpigbt, anchor=B](B){} (B.nobase)
;
\ctikzset{tripoles/igbt/outer base height=0.3}
\ctikzset{tripoles/igbt/outer base thickness=1.5}
\draw (6,0)
-- ++(1,0) node[nigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[pigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[Lnigbt, anchor=B](B){} (B.nobase)
-- ++(1,0) node[Lpigbt, anchor=B](B){} (B.nobase)
;
\end{circuitikz}
4.14.5.8 UJT transistors. They look better if you use transistors/arrow pos=end, espe-
cially if you use them with tr circle. If you use the key nobase with UJTs, the horizontal part
of the controlling terminal is not drawn; notice that this will move the E or emitter anchor, but
not the generic ones like G.
32 suggested by Mayeul Cantan
96
\begin{circuitikz}[scale=0.8]
\draw (0,5) node[nujt]{} ++(2,0) node[pujt]{}
++(2,0) node[nujt, tr circle]{} ++(2,0)
node[pujt, tr circle]{};
\ctikzset{transistors/arrow pos=end}
\draw (0,2.5) node[nujt](A){} ++(2,0) node[pujt]{}
++(2,0) node[nujt, tr circle]{} ++(2,0)
node[pujt, tr circle](C){};
\draw (0,0) node[nujt, nobase](B){} ++(2,0)
node[pujt, nobase]{} ++(2,0)
node[nujt, tr circle, nobase]{} ++(2,0)
node[pujt, tr circle, nobase](D){};
% "E" anchor follows the nobase option:
\draw[red] (A.E) |- (B.E) (C.E) |- (D.E);
\end{circuitikz}
4.14.5.9 Base/Gate terminal. The Base/Gate connection of all transistors can be disabled
by the options nogate or 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{circuitikz}
C
\draw (2,0) node[npn,nobase](npn){};
\draw (npn.E) node[below]{E};
B \draw (npn.C) node[above]{C};
\draw (npn.B) node[circ]{} node[left]{B};
\draw[dashed,red,-latex] (1,0.5)--(npn.nobase);
E \end{circuitikz}
To draw the PMOS circle non-solid, use the option emptycircle or the command
\ctikzset{tripoles/pmos style/emptycircle}. To remove the dot completely (only useful if
you have arrowmos enabled, otherwise there will be no difference between P-MOS and N-MOS),
you can use the option nocircle or \ctikzset{tripoles/pmos style/nocircle}.
4.14.5.10 Bulk terminals. You can add a bulk terminal33 to nmos and pmos using the key
bulk in the node (and nobulk if you set the bulk terminal by default); additional anchors bulk
and nobulk are added (in the next example, tripoles/mos style/arrows is enacted, too):
bulk
pmos, type: node (node[nmos, bulk]{}). Class:
transistors.
nobulk
97
pmos, type: node (node[pmos, bulk]{}). Class:
transistors.
bulk
nmos depletion, type: node (node[nmosd, bulk]{}).
Class: transistors.
nobulk
pmos nmos
default \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]{}
arrows (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}
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]{};
nocircle \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]{};
no circle, \end{circuitikz}
no arrows,
DON’T
do it
4.14.5.11 Simplified symbols for depletion-mode MOSFETs . The nmosd, pmosd (sym-
plified) symbols for depletion-mode MOSFET (introduced in 1.2.4) behave exactly like the normal
(without the final d) ones.
By default, the thick bar (indicating the pre-formed channel) is filled with the same color as the
drawing:
98
\begin{circuitikz}[ ]
\draw (0,2) to[R] ++(2,0) node[nmosd, anchor=G]{};
\draw[color=red] (0,0) to[R] ++(2,0) node[pmosd, anchor=G]{};
\end{circuitikz}
You can change this behavior by setting the key tripoles/nmosd/depletion color (default value
default, which means “use the draw color”) to the color you want; using none will lead to an
unfilled channel (note that in this case the color does not change automatically with the path!):
\begin{circuitikz}[ ]
\ctikzset{tripoles/nmosd/depletion color=gray}
\draw (0,2) to[R] ++(2,0) node[nmosd, anchor=G]{};
\ctikzset{tripoles/pmosd/depletion color=none}
\draw[color=red] (0,0) to[R] ++(2,0)
node[pmosd, anchor=G]{};
\ctikzset{tripoles/pmosd/depletion color=
{cyan!50!white}}
\draw[color=blue] (0,-2) to[R] ++(2,0)
node[pmosd, anchor=G, bulk]{};
\end{circuitikz}
Obviously you have the equivalent tripoles/pmosd/depletion color for type-P transistors.
They also have path-style syntax, as the other transistors.
\begin{circuitikz}[ ]
\draw (0,0) to[Tnmosd] ++(2,0)
to[Tpmosd, invert] ++(0,-2)
;
\end{circuitikz}
4.14.5.12 Gate/Base gap coloring. You can color the space representing the gate capacitor
or the insulated base by using the key tr gap fill (default none, which means nothing is drawn
there). This fill is done after any circle fill but before any additional modifier (see the example
below). You can use it locally or set it globally (normal scoping works, as ever).
\begin{tikzpicture}
\node[nigfete, tr gap fill=green] at(0,0){};
\node[nigfete, tr gap fill=red, tr circle,
fill=cyan!30] at(1.5,0){};
\node[nmos, tr gap fill=cyan, ferroel gate](A)
at(3,0){};
\end{tikzpicture}
99
4.14.6 Multiple terminal transistors customization
You can create completely “bare” transistors (without the connection leads to the B, C y E ter-
minals), by changing the parameter tripoles/bjt/pins width (default 0.3; it is expressed
as a fraction of the basic (scaled) length) or using the style bjt pins width; and you can
change the distance between multiple collectors/emitters setting with \ctikzset{} the param-
eter tripoles/bjt/multi height (default 0.5) or the style bjt multi height.
C
C2
cbase bjt npn with parameters, type: node (node[bjtnpn,
C1
B Q collectors=2, emitters=2, bjt pins width=0, bjt
E1 multi height=0.8]{Q}). Class: transistors.
nobase
E2
E
4.14.7.1 Position and size. You can see in the following diagram where the circle is positioned
— when there is no bodydiode, it will pass through the anchors for the body diode and near the
base connection. The dimension of the circle is bigger when the bodydiode is in, to encompass
it. The anchors are present even there is no circle, so you can use them to draw different kind of
circles (say, encompassing two transistors) in a coherent way.
circle E
The position of the circle on collector and emitter by default is the one shown above; the position
along the base can be adjusted in most transistors using the \ctikzset parameter transistor
circle/default base in (by default 0.9); njfet and pjfet use transistor circle/njfet
base in (default 1.05; the same for pjfet) and, finally, isfet uses transistor circle/isfet
base in (default 0.65). You can change the resulting size of the circle by setting to something
different to 1.0 the parameter transistor circle/scale circle radius — that will move the
anchors too; for example:
100
4.14.7.2 Line and color. Normally the circle follows the style of the component — the line
thickness is fixed by the class element transistors/thickness and the color is the same as the
component color. You can change, if you need, all of these things using the parameters of the
following table (the parameters are under the \ctikzset category root transistor circle/.
\begin{circuitikz}[]
\draw (0,2) node[npn, tr circle](Q1){};
\ctikzset{transistor circle/relative thickness=2}
\draw (2,2) node[npn, tr circle](Q1){};
\ctikzset{transistor circle/color=red}
\draw (0,0) node[npn, tr circle](Q1){};
\ctikzset{transistor circle/color=default}
\ctikzset{transistor circle/dash={{4pt}{4pt}{1pt}{4pt}}}
\draw[color=blue] (2,0) node[npn, tr circle](Q1){};
\end{circuitikz}
Finally, using the class style you can do quite interesting things.
\begin{circuitikz}[]
\ctikzset{transistors/thickness=4, transistors/fill=cyan!30,
transistor circle/relative thickness=0.25,}
\draw (0,0) node[npn, tr circle](Q1){};
\ctikzset{transistor circle/dash={{2pt}{2pt}}}
\draw (1.5,0) node[npn, tr circle, xscale=-1](Q2){};
\end{circuitikz}
For nmos, pmos, nfet, nigfete, nigfetd, pfet, pigfete, and pigfetd transistors one has
base, gate, source and drain anchors (which can be abbreviated with B, G, S and D):
D \begin{circuitikz} \draw
(0,0) node[nmos] (mos) {}
(mos.gate) node[anchor=east] {G}
G (mos.drain) node[anchor=south] {D}
(mos.source) node[anchor=north] {S}
S ;\end{circuitikz}
\begin{circuitikz} \draw
S
(0,0) node[pigfete] (pigfete) {}
(pigfete.G) node[anchor=east] {G}
G
Bulk (pigfete.D) node[anchor=north] {D}
(pigfete.S) node[anchor=south] {S}
(pigfete.bulk) node[anchor=west] {Bulk}
D ;\end{circuitikz}
34 Follows the syntax of the pattern sequence \pgfsetdash — see TikZ manual for details; phase is always zero.
Basically you pass pairs of dash-length – blank-length dimensions, see the examples.
101
Similarly njfet and pjfet have gate, source and drain anchors (which can be abbreviated with
G, S and D):
S \begin{circuitikz} \draw
(0,0) node[pjfet] (pjfet) {}
G (pjfet.G) node[anchor=east] {G}
(pjfet.D) node[anchor=north] {D}
(pjfet.S) node[anchor=south] {S}
D ;\end{circuitikz}
For npn, pnp, nigbt and pigbt transistors, the anchors are base, emitter and collector anchors
(which can be abbreviated with B, E and C):
C \begin{circuitikz} \draw
(0,0) node[npn] (npn) {}
(npn.base) node[anchor=east] {B}
B (npn.collector) node[anchor=south] {C}
(npn.emitter) node[anchor=north] {E}
E ;\end{circuitikz}
E \begin{circuitikz} \draw
(0,0) node[pigbt] (pigbt) {}
(pigbt.B) node[anchor=east] {B}
B (pigbt.C) node[anchor=north] {C}
(pigbt.E) node[anchor=south] {E}
C ;\end{circuitikz}
Notice that the geographical anchors of transistors are not affected by either the bodydiode and
the circle options; the label text is also outside of them. This is to permit to align the components
independently from that features. On the other hand, that can sometimes create problems because
that element are outside the bounding box automatically calculated by TikZ.
The exception is the right anchor which, when a circle is present, indicates the edge of the circle
itself (since v1.3.2)
north north north
north west north east north west north east north west north east
south west south east south west south east south west south east
south south south
All transistors, except the multi-terminal bjtnpn and bjtpnp, (since 0.9.6) have internal nodes
on the terminal corners, called inner up and inner down; you do not normally need them, but
they are here for special applications:
102
\begin{circuitikz}
\node [npn](A) at(0,2) {};
inner up
\node [pmos](B) at(0,0) {};
inner down \foreach \e in {A, B}
\foreach \a in {inner up, inner down} {
\node[red, circle, inner sep=1pt, draw]
at (\e.\a) {};
inner up \node [right, font=\tiny, blue]
inner down
at (\e.\a) {\a};
}
\end{circuitikz}
Additionally, you can access the position for the flyback diodes and possibly snubbers as shown
in 4.14.5.4.
The multi-terminal transistors have all the geographical anchors; note though that the center
anchor is not the geometrical center of the component, but the logical one (at the same height
than the base). The additional anchors vcenter (vertical geometric center of the collector–emitter
zone) and gcenter (graphical center) are provided, as shown in the following picture. They have
no bodydiode anchors nor inner up/down ones.
north
north center
north west north east
west east
vcenter
west text east gcenter
cbase
center
A complete example of multiple terminal transistor application is the following PNP double current
mirror circuit.
103
\begin{circuitikz}
\ctikzset{transistors/arrow pos=end}
\draw (0,0) node[bjtpnp, xscale=-1](Q1){%
\scalebox{-1}[1]{Q1}};
Q1 Q2 \draw (Q1.B) node[bjtpnp, anchor=B, collectors=2]
(Q2){Q2} (Q1.B) node[circ]{};
\draw (Q1.E) node[circ]{} node[vcc]{} (Q2.E)
node[vcc]{} (Q1.E) -| (Q1.B);
\draw (Q1.C) to[R, l_=$R_0$, f=$I_0$] ++(0,-3.5)
I0 I0 node[ground](GND){};
R0 \draw (Q2.C) -- ++(0,-0.5) coordinate(a);
\draw (Q2.C1) -- ++(1,0) coordinate(b) -- (b|-a);
\draw (a) ++(0,-0.1) node[flowarrow, rotate=-90,
I0 anchor=west]{\rotatebox{90}{$I_0$}};
\draw (b|-a) ++(0,-0.1) node[flowarrow, rotate=-90,
anchor=west]{\rotatebox{90}{$I_0$}};
\path (b) ++(0.5,0); % bounding box adjust
\end{circuitikz}
Here is one composite example (please notice that the 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 pnp1):
\begin{circuitikz} []\draw
(0,0) node[pnp] (pnp2) {Q2}
(pnp2.B) node[pnp, xscale=-1, anchor=B] (pnp1) {}
Q1 Q2
(pnp1) node[left, inner sep=0pt] {Q1}
(pnp1.C) node[npn, anchor=C] (npn1) {Q3}
(pnp2.C) node[npn, xscale=-1, anchor=C] (npn2)
{\scalebox{-1}[1]{Q4}}
Q3 Q4
(pnp1.E) -- (pnp2.E) (npn1.E) -- (npn2.E)
(pnp1.B) node[circ] {} |- (pnp2.C) node[circ] {}
;\end{circuitikz}
Notice that the text labels of transistors are outside the bounding box of the component (that is,
the set of geographical anchors). If it is a problem, use a separate text node to set the transistor’s
label. Of course, transistors like other components can be reflected vertically:
\begin{circuitikz} \draw
D
(0,0) node[pigfete, yscale=-1] (pigfete) {}
(pigfete.bulk) node[anchor=west] {Bulk}
Bulk (pigfete.G) node[anchor=east] {G}
G (pigfete.D) node[anchor=south] {D}
(pigfete.S) node[anchor=north] {S}
S ;\end{circuitikz}
Finally, double-gated components (MOSes, FETs, IGBTs) have an extra anchor centergap posi-
tioned in the middle of the “gate capacitor” or base.
centergap \begin{circuitikz}
\node [nmos](A) at (0,3) {};
\node [nfet](B) at (0,1.5) {};
\node [pigbt](C) at (0,0) {};
centergap \foreach \myn in {A, B, C}
\draw[color=red] (\myn.centergap)
node[ocirc]{} -- ++(1,0)
node[right, font=\tiny]{centergap};
centergap \end{circuitikz}
104
For UJT transistors anchors, see section 4.14.5.8.
For syntactical convenience standard transistors (not multi-terminal ones) 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:
2 3 \begin{circuitikz} \draw
(0,0) node[njfet] {1}
(-1,2) to[Tnjfet=2] (1,2)
to[Tnjfet=3, mirror] (3,2);
;\end{circuitikz}
1
Access to the gate and/or base nodes can be gained by naming the transistors with the n or name
path style:
p1 p2
\begin{circuitikz} \draw[yscale=1.1, xscale=.8]
(2,4.5) -- (0,4.5) to[Tpmos=p1, n=p1] (0,3)
to[Tnmos=n1, n=n1] (0,1.5)
to[Tnmos=n2, n=n2] (0,0) node[ground] {}
n1 (2,4.5) to[Tpmos=p2,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)$)
n2 (0,3) to[short, -o] (-1,3)
;\end{circuitikz}
Transistor paths have the possibility to use the poles syntax (see section 6.1) but they have no
voltage, current, flow, annotation options. Also, the positioning of the labels is very simple and is
not foolproof for all rotations; if you need to control them more please name the node and position
them by hand, or use the more natural node style for transistors.
The name property is available also for bipoles; this is useful mostly for triac, potentiometer and
thyristor (see 4.4.1).
105
anode
cathode
anode
cathode
anode
screen
Tetrode, type: node, fillable (node[tetrode]{}). Class: tubes.
control
cathode
anode
suppressor
screen Pentode, type: node, fillable (node[pentode]{}). Class:
tubes.
control
cathode
Some pentodes have the suppressor grid internally connected to the control grid, which saves a pin on the
tube’s housing.
anode
cathode
Note that the 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 filament option in the node
description:
106
anode
filament 1 filament 2
Sometimes, you don’t want the cathode to be drawn (but you do want the filament). Use the nocathode
option in the node description:
anode
If you want a full cathode to be drawn, use the fullcathode option in the node description. You can then
use the anchors cathode 1 and cathode 2.
anode
cathode 1 cathode 2
107
Conventionally, the model of the tube is indicated at the east anchor:
\ctikzset{tubes/width=1.4}
\ctikzset{tubes/height=1}
12AX7 \begin{circuitikz}
\draw (0,0) node[triode] (Tri) {};
\draw (Tri.east) node[right] {12AX7};
\end{circuitikz}
Ra
Co
Ci
12AX7
Va
Vi Rg
Rc Cc
The magnetron and dynode shapes will also scale with tubes/scale.
108
top
cathode1 cathode2
anode
\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);
1 2 \draw (DC.right)++(0.2,0)to [short,*-] ++(0,-1)
HV to [short] (magn.cathode2);
RFout \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}
4.15.2.1 Dynode customization. The dynode element can be heavily customized. The parame-
ters are the following (all of them under the \ctikzset family monopoles/dynode):
width 0.4 Total width (relative to the base length) measured at the arc width.
height 0.8 Total height (same units as width).
arc angle 30 Angle (from the horizontal, going down) where the arc starts. A value of 90
don’t plot any arc, 0 plots a semicircle. To avoid artifacts, use a value between
-60 and 90; the arc horizontal size is always equal to the width.
arc pos 0.5 Vertical position (relative to the height) of the arc center.
top width 1.0 Relative width of the top bar; a value of 1 means full width, 0 means no bar.
\begin{circuitikz}[american] \ctikzset{tubes/thickness=4}
\draw (0,0) to[R] (2,0) node[dynode]{} to[R,-*] (4,0);
\ctikzset{monopoles/dynode/.cd,
arc angle=0, arc pos=0.7, top width=0.5}
\draw (4,0) node[dynode]{};
\end{circuitikz}
You can use styles and the parameters to create different types of electrodes:
35 Suggested by the user ferdymercury on GitHub.
109
\begin{circuitikz}[american] \ctikzset{tubes/thickness=4}
\tikzset{anode/.style={dynode,
circuitikz/monopoles/dynode/arc angle=90},
photocatode/.style={dynode,
circuitikz/monopoles/dynode/arc pos=1,
circuitikz/monopoles/dynode/top width=0},
}
\draw (0,0) node[dynode]{} (1,0) node[anode]{}
(2,0) node[photocatode]{};
\end{circuitikz}
4.16 RF components
For the RF components, similarly to the grounds and supply rails, the center anchor is put on the
connecting point of the symbol, so that you can use them directly in a path specification.
Notes that in the transmission and receiving antennas, the “waves” are outside the geographical anchors.
top
right
Bare Antenna, type: node, fillable (node[bareantenna]{A}).
left A Class: RF.
bottom center
top waves
Bare TX Antenna, type: node, fillable
Tx (node[bareTXantenna]{Tx}). Class: RF.
center
waves top
Bare RX Antenna, type: node, fillable
Rx (node[bareRXantenna]{Rx}). Class: RF.
center
north
north west top north east
left right
west Waves, type: node (node[waves]{}). Class: RF.
east
bottom
south west south east
south
left right
mstline: Microstrip transmission line36 , type: path-style,
fillable, nodename: mstlineshape. Class: RF.
center
left right
Microstrip port, type: node, fillable (node[msport]{T}). Class:
T
RF.
center
110
Legacy antenna (with tails), type: node (node[antenna]{}).
Class: RF.
center
The RF elements can be scaled using the key RF/scale, default 1.0.
The microstrip linear components’ (mstline, mslstub, msport) heights can be changed by setting the
parameter bipoles/mstline/height (for the three of them, default 0.3). The widths are specified in
bipoles/mstline/width for the first two and by 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
mstlinelen.
111
short
longer stub
\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}
top
45
Motor, type: node, fillable (node[elmech]{M}). Class:
left M right electromechanicals.
bottom
Apart from the standard geographical anchors, elmech has the border anchors (situated on the inner circle)
and the following anchors on the “block”:
north
block north west block north east block up right
block up left
150
60
180 A -60
west B east
210
block south west block south east block down left block down right
south
112
\begin{circuitikz}
\draw (2,0) node[elmech](motor){M};
\draw (motor.north) |-(0,2) to [R] ++(0,-2) to[dcvsource
ω
M ]++(0,-2) -| (motor.bottom);
\draw[thick,->>](motor.right)--++(1,0)node[midway,above]{$\
omega$};
\end{circuitikz}
\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}
The symbols can also be used along a path, using the transistor-path-syntax(T in front of the shape name,
see section 4.14.9). Don’t forget to use parameter n to name the node and get access to the anchors:
\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);
M G
\draw[thick,->>](motor.left)--(generator.left)node[midway,
above]{$\omega$};
\end{circuitikz}
M
A1 B1
113
Transformer (european inductor), type: node
(node[transformer]{}). Class: inductors.
All the double bipoles/quadrupoles have the four anchors, two for each port. The first port, to the left, is
port A, having the anchors A1 (up) and A2 (down); same for port B.
They also expose the base anchor, for labelling, and anchors for setting dots or signs to specify polarity.
The set of anchors, to which the standard “geographical” north, north east, etc. is here:
A1 B1
inner dot A1 outer dot A1
base
inner dot B1 outer dot B1
114
\begin{circuitikz} \draw
(0,0) node[transformer] (T) {}
A1 K B1 (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}
A2 B2 (T.inner dot A1) node[circ]{}
(T.inner dot B2) node[circ]{}
;\end{circuitikz}
\begin{circuitikz} \draw
A1 K B1 (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}
A2 B2 (G.base) node{K}
;\end{circuitikz}
Moreover, you can access the two internal coils (inductances); if your transformer node is called T, they
are named T-L1 and 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 midtap anchor of the inductors can be
on the external or internal side depending on the numbers of coils. Finally, the anchors L1.a and L1.b
are marking the start and end of the coils.
inductors/coils=5 inductors/coils=6
T-L1.b T-L2.a
T-L1.south west T-L2.south east
T-L2.south east T-L2.south east
T-L1.midtap T-L2.south T-L2.midtap T-L2.midtap
T-L2.south west T-L2.south west
T-L1.south east T-L2.south west
T-L1.a T-L2.b
\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}
Transformers are in the inductors class (also the gyrator…), so they scale with the key inductors/scale.
You can change the aspect of a quadpole using the corresponding parameters quadpoles/*/width and
quadpoles/*/heigth (substitute the star for transformer, transformer core or gyrator; default value
is 1.5 for all). You have to be careful to not choose value that overlaps the components!
K \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}
115
Transformers also inherits the inductors/scale (see 4.3.5) and similar parameters. It’s your responsibility
to set the aforementioned parameters if you change the scale or width of inductors.
Transformers core line distance is specified by the parameter quadpoles/transformer core/core width
(default 0.05) and the thickness of the lines follows the choke one; in other words, you can set it changing
bipoles/cutechoke/cthick.
Another very useful parameter is quadpoles/*/inner (default 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):
A1 K B1 \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}
A2 B2 (T.base) node{K} ;
\ctikzset{quadpoles/transformer/inner=1, quadpoles/transformer/
T 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}
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 quadpoles style to toggle between the standard shape of double
bipoles (called inward, default) and the one without horizontal leads (called inline):
\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}
Since 0.9.6, you can tweak the style of each of the coils of the transformers by changing the value of
the two styles transformer L1 and transformer L2; the default for both are {}, that means inherit the
inductors style in force.
116
\begin{circuitikz}[american]
\begin{scope}
\ctikzset{transformer L1/.style={inductors/coils=1, inductors/width=0.2}}
\draw (0,0) node[transformer core](T1){};
\end{scope}
\draw (3,0) node[transformer](T2){};
\ctikzset{cute inductors, quadpoles style=inline}
\ctikzset{transformer L1/.style={inductors/coils=2, inductors/width=0.2}}
\draw (6,0) node[transformer core](T3){};
\ctikzset{transformer L1/.style={american inductors, inductors/coils=1, inductors/
width=0.2}}
\ctikzset{transformer L2/.style={inductors/coils=7, inductors/width=1.0}}
\draw (9,0) node[transformer ](T4){};
\foreach \t in {T1, T2, T3, T4} {
\foreach \l in {L1, L2} {
\foreach \a/\c in {a/blue, b/red}
\node [circle, fill=\c, inner sep=1pt] at (\t-\l.\a) {};
}
}
\end{circuitikz}
Caveat: the size of the transformer is independent from the styles for L1 and L2, so they follow whatever
the parameters for the inductances were before applying them. In other words, the size of the transformer
could result too small if you are not careful.
\begin{circuitikz}
\ctikzset{transformer L1/.style={inductors/width=1.8,
inductors/coils=13}}
% too small!
\draw (0,0) node[transformer core](T1){};
% adjust it
\ctikzset{quadpoles/transformer core/height=2.4}
\draw (2.5,0) node[transformer core](T1){};
\end{circuitikz}
You can obviously define a style for a “non-standard” transformer. For example, you can have a current
transformer37 defined like this:
117
\begin{circuitikz}[
TA core/.style={transformer core,
% at tikz level, you have to use circuitikz/ explicitly
circuitikz/quadpoles style=inline,
circuitikz/transformer L1/.style={
american inductors, inductors/coils=1,
inductors/width=0.3},
} ]
\draw (0,0) node[TA core](T1){};
% changes are local
\draw (0,-3) node[transformer]{};
\end{circuitikz}
Remember that the default pgfkeys directory is /tikz for nodes and for the options of the environment,
so you have to use the full path (with circuitikz/) there.
4.19 Amplifiers
up
- −
Operational amplifier, type: node, fillable (node[op amp]{}).
out
Class: amplifiers.
+ +
down
▷∞
− Operational amplifier compliant to DIN/EN 60617 standard,
+ type: node, fillable (node[en amp]{}). Class: amplifiers.
− out +
+ Fully differential operational amplifier38 , type: node, fillable
− (node[fd op amp]{}). Class: amplifiers.
+ out -
−
transconductance amplifier, type: node, fillable (node[gm
amp]{}). Class: amplifiers.
+
up
refv up
−
plain instrumentation amplifier, type: node, fillable
(node[inst amp]{}). Class: amplifiers.
+
refv down
down
38 Contributed by Kristofer M. Monisit.
118
− +
Fully differential instrumentation amplifier, type: node, fillable
(node[fd inst amp]{}). Class: amplifiers.
+ −
−
ra-
instrumentation amplifier with amplification resistance ter-
minals, type: node, fillable (node[inst amp ra]{}). Class:
amplifiers.
ra+
+
up
bin up
in up bout
Plain amplifier, unmarked, two inputs, type: node, fillable
A1 (node[plain amp]{A$_1$}). Class: amplifiers.
in down out
bin down
up
bout
bin Plain amplifier, one input, type: node, fillable (node[plain
in out mono amp]{}). Class: amplifiers.
center
bout
bin Buffer, type: node, fillable (node[buffer]{}). Class:
in out
amplifiers.
center
The op amp defines the inverting input (-), the non-inverting input (+) and the output (out) anchors:
5V
\begin{circuitikz} \draw
(0,0) node[op amp] (opamp) {}
v− − (opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
vo
(opamp.out) node[right] {$v_o$}
v+ + (opamp.up) --++(0,0.5) node[vcc]{5\,\textnormal{V}}
(opamp.down) --++(0,-0.5) node[vee]{-5\,\textnormal{V}}
;\end{circuitikz}
-5 V
There are also two more anchors defined, up and down, for the power supplies:
119
\begin{circuitikz} \draw
12 V (0,0) node[op amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
v− − (opamp.-) node[left] {$v_-$}
vo (opamp.out) node[right] {$v_o$}
(opamp.down) node[ground] {}
v+ + (opamp.up) ++ (0,.5) node[above] {\SI{12}{\volt}}
-- (opamp.up)
;\end{circuitikz}
\begin{circuitikz} \draw
(0,0) node[fd op amp] (opamp) {}
v− − out + (opamp.+) node[left] {$v_+$}
+ (opamp.-) node[left] {$v_-$}
− (opamp.out +) node[right] {out +}
v+ + out - (opamp.out -) node[right] {out -}
(opamp.down) node[ground] {}
;\end{circuitikz}
The instrumentation amplifier inst amp defines also references (normally you use the down, unless you are
flipping the component):
\begin{circuitikz} \draw
(0,0) node[inst amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
v− − (opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {out}
out
(opamp.up) node[vcc]{}
v+ + (opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
;\end{circuitikz}
The fully diffential instrumentation amplifier inst amp defines two outputs:
\begin{circuitikz} \draw
(0,0) node[fd inst amp] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
v− − + out + (opamp.out +) node[right] {out +}
(opamp.out -) node[right] {out -}
v+ + − 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}
The instrumentation amplifier with resistance terminals (inst amp ra) defines also terminals to add an
amplification resistor:
120
\begin{circuitikz} \draw
v− − (0,0) node[inst amp ra] (opamp) {}
(opamp.+) node[left] {$v_+$}
(opamp.-) node[left] {$v_-$}
(opamp.out) node[right] {out}
out (opamp.up) node[vcc]{}
(opamp.down) node[vee] {}
(opamp.refv down) node[ground]{}
(opamp.refv up) to[short, -o] ++(0,0.3)
v+ + (opamp.ra-) to[R] (opamp.ra+)
;\end{circuitikz}
Amplifiers have also “border” anchors (just add b, without space, to the anchor, like b+ or bin up and so
on). These can be useful to add “internal components” or to modify the component. Also the leftedge
anchors (on the border midway between input) is available.
\begin{circuitikz}[]
−
\draw (0,2.2) node[op amp](OA){IA1};
IA1 \node[oosourceshape, rotate=90, scale=0.5]
+ at (OA.leftedge) {};
\draw (0,0) node[plain amp](A){$A$};
\draw [color=red] (A.bin up) -- ++(0.2,0)
coordinate (tmp)
to[R, resistors/scale=0.5]
A
(tmp|-A.bin down) -- (A.bin down);
\end{circuitikz}
You can scale the amplifiers using the key amplifiers/scale and setting it to something different from
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 noinv input down (default) or noinv input up key; and the output with
noinv output up (default) or noinv output down key:
\begin{circuitikz} \draw
(0,0) node[fd inst amp,
noinv input up,
noinv output down] (opamp) {}
(opamp.+) node[left] {$v_+$}
v+ + − out - (opamp.-) node[left] {$v_-$}
(opamp.out +) node[right] {out +}
v− − + 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}
When you use the noinv input/output ... keys the anchors (+, -, out +, out -) will change with the
effective position of the terminals. You have also the anchors in up, in down, out up, out down that will
not change with the positive or negative sign.
You can change the symbols “+” or “−” appearing in the amplifiers if you want, both globally and on
component-by-component basis. The plus and minus symbols can be changed with \ctikzset of the keys
121
amplifiers/plus and amplifiers/minus (which defaults to the math mode plus or minus cited before),
or using the styles amp plus and amp minus.
The font used is set in several keys, but you can change it globally with \tikzset{amp symbol font},
which has a default of 10-point (in LATEX, and the corresponding one in ConTEXt). You can change it for
example with
\tikzset{amp symbol font={%
\color{blue}\fontsize{12}{12}\selectfont\boldmath}}
to have plus and minus symbols that are bigger and blue.
\begin{circuitikz}[]
⊕
% change in this circuit only
\tikzset{amp symbol font={\color{blue}\small\boldmath}}
% local change
− \draw (0,2.2) node[op amp, amp plus=$\oplus$]{};
\draw (0,0) node[op amp]{};
+ % from now on...
\ctikzset{amplifiers/plus={$\oplus$}}
\ctikzset{amplifiers/minus={$\ominus$}}
\draw (0,-2.2) node[fd op amp]{};
⊖
⊕ \end{circuitikz}
⊖
⊕
If you want different symbols for input and output you can use a null symbol and put them manually
using the border anchors.
\begin{circuitikz}[]
\ctikzset{amplifiers/plus={}}
\ctikzset{amplifiers/minus={}}
1 \draw (0,0) node[fd op amp](A){};
3
\node [font=\small\bfseries, right] at(A.bin up) {1};
4 \node [font=\small\bfseries, right] at(A.bin down) {2};
2
\node [font=\small\bfseries, below] at(A.bout up) {3};
\node [font=\small\bfseries, above] at(A.bout down) {4};
\end{circuitikz}
The amplifier label (given as the text of the node) is normally more or less centered in the shape (in the
case of the triangular shape, it is shifted a bit to the left to seem visually centered); since version 1.1.0
you can move it at the left side plus a fixed offset setting the key component text or the style with the
same name to left; by default the key is center. You can change the offset with the key left text
distance (default 0.3em; you must use a length here). These parameters are shared with IEEE-style logic
ports.
\begin{circuitikz}[]
741 741 \draw (0,2.5) node[plain amp]{\texttt{741}};
\draw (3,2.5)
node[plain amp, component text=left]
{\texttt{741}};
\ctikzset{component text=left}
\draw (0,0) node[op amp]{\texttt{741}};
− −
\ctikzset{left text distance=0.6em}
741 741 \draw (3,0) node[op amp]{\texttt{741}};
+ + \end{circuitikz}
122
These keys are also used for the positioning of the labels in the label positioning of IEEE logic gates
(see 4.21.2).
4.19.2.1 European-style amplifier customization Thanks to the suggestions from David Rou-
vel ([email protected]) 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 ConTEXt
compatibility; but see later on how to change it. Notice that the font used for the symbol is defined in
tripoles/en amp/font2 and that the font used for the + and - symbols is tripoles/en amp/font.
You can change the distances of the inputs, using tripoles/en amp/input height (default 0.3):
\begin{circuitikz}
▷∞ \ctikzset{tripoles/en amp/input height=0.45}
vin− − \draw (0,0)node[en amp](E){}
vout (E.out) node[right] {$v_{\mathrm{out}}$}
vin+ + (E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$};
\end{circuitikz}
\begin{circuitikz}
▷∞ \ctikzset{tripoles/en amp/input height=0.45}
vin+ + \draw (0,0)node[en amp, noinv input up](E){}
vout (E.out) node[right] {$v_{\mathrm{out}}$}
vin− − (E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$};
\end{circuitikz}
To flip the amplifier in the horizontal direction, you can use xscale=-1 as usual:
\begin{circuitikz}
∞▷ \ctikzset{tripoles/en amp/input height=0.45}
+ vin+
\draw (0,0)node[en amp, xscale=-1, noinv input up](E){}
vout (E.out) node[left] {$v_{\mathrm{out}}$}
− vin− (E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$};
\end{circuitikz}
Notice that the label is fully mirrored, so check below for the generic way to change this.
You can use the new key en amp text A to change the infinity symbol with an A:
▷A \begin{circuitikz}
\draw (0,0)node[en amp, en amp text A](E){}
vin− − (E.out) node[right] {$v_{\mathrm{out}}$}
vout
vin+ + (E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
And if you want, you can completely change the text using the key en amp text=, which by default is
$\mathstrut{\triangleright}\,{\infty}$:
123
\begin{circuitikz}
▷ 200 \draw (0,0)node[en amp, en amp text={%
vin− − ${\triangleright}$ \small 200}](E){}
vout (E.out) node[right] {$v_{\mathrm{out}}$}
vin+ + (E.-) node[left] {$v_{\mathrm{in}-}$}
(E.+) node[left] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
Notice two things here: the first, that \triangleright is enclosed in braces to remove the default spacing
it has as a binary operator, and that en amp text A is simply a shortcut for
en amp text={$\mathstrut{\triangleright}\,\mathrm{A}$}
A▷ \begin{circuitikz}
\draw (0,0)node[en amp, xscale=-1, en amp text A](E){}
− vin−
(E.out) node[left] {$v_{\mathrm{out}}$}
vout
+ vin+ (E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
But notice that the “A” is also flipped by the xscale parameter. So the solution in this case is to use
scalebox, like this:
\begin{circuitikz}
200 ▷ \draw (0,0)node[en amp, xscale=-1, en amp text={%
− vin− ${\triangleright}$ \scalebox{-1}[1]{\small 200}}](E){}
vout (E.out) node[left] {$v_{\mathrm{out}}$}
+ vin+ (E.-) node[right] {$v_{\mathrm{in}-}$}
(E.+) node[right] {$v_{\mathrm{in}+}$} ;
\end{circuitikz}
If you need a different kind of amplifier, you can use the muxdemux (see section 4.23) shape for defining one
that suits your needs (you need version 1.0.0 for this to work, and 1.3.8 for the draw only... option).
\tikzset{tdax/.style={muxdemux,
muxdemux def={NL=2, Lh=3, NR=1, Rh=0,
NB=4, NT=5}, font=\scriptsize\ttfamily}}
\begin{circuitikz}
TDA1 TDA2
\draw (0,0) node[tdax](A){TDA1};
\draw (2.5,0) node[tdax, muxdemux def={Rh=0.5},
draw only top pins={1,4-5}]{TDA2};
\end{circuitikz}
124
4.20.1 Traditional switches
out 1
in spdt, type: node (node[spdt]{}). Class: switches.
out 2
\begin{circuitikz} \draw
(0,0) node[spdt] (Sw) {}
out 1 (Sw.in) node[left] {in}
in
out 2 (Sw.out 1) node[right] {out 1}
(Sw.out 2) node[right] {out 2}
;\end{circuitikz}
125
\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}
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:
while the node-style components are the single-pole, double-throw (spdt) ones:
out 1
mid Cute spdt up, type: node (node[cute spdt up]{}). Class:
in
switches.
out 2
Cute spdt mid with arrow, type: node (node[cute spdt mid
arrow]{}). Class: switches.
126
4.20.2.1 Cute switches anchors The nodes-style switches have the following anchors:
Please notice the position of the normal anchors at the border of the ocirc shape for the cute switches;
they are thought to be compatible with an horizontal wire going out. Additionaly, you have the cin, cout
1 y cout 2 which are anchors on the center of the contacts.
For more complex situations, the contact nodes are available39 using the syntax name of the node-in,
…-out 1 and …-out 2, with all their anchors.
\begin{circuitikz}
out 1 \draw (0,0) node[cute spdt up] (S1) {}
in (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};
in
\draw [red] (S1-in.s) -- (S2-in.n);
out 2 \draw [blue] (S1-out 2.s) -- (S2-out 1.n);
\end{circuitikz}
The mid anchor in the cute switches (both path- and node-style) can be used to combine switches to get
more complex configurations:
\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}
4.20.2.2 Cute switches customization You can use the key bipoles/cuteswitch/thickness
to decide the thickness of the switch lever. The units are the diameter of the ocirc connector, and the
default is 1.
\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}
Finally, the switches are normally drawn using the ocirc shape, but you can change it, as in the following
example, with the key 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 circ and ocirc
shapes, so you have to use the internal node syntax to connect it.
39 Thanks to @marmot on tex.stackexchange.com.
127
\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}
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).
N-out 1.n
cout 1 out 1 Rotary switch, type: node (node[rotaryswitch](N){}). Class:
cin
in mid switches.
center N-out 4.w
Notice that the name of the shape is rotaryswitch, no spaces. The default rotary switch component
has 5 channels (this is set in the parameter multipoles/rotary/channels), spanning form −60° to 60°
(parameter multipoles/rotary/angle) and with the wiper at 20° (parameter multipoles/rotary/wiper).
Moreover, there are by default no arrows on the wiper; if needed, you can change this default setting the
parameter multipoles/rotary/arrow which can assume the values none, cw (clockwise), ccw (counter-
clockwise) or both.
To simplify the usage of the component, a series of styles are defined: rotary switch=<channels> in
<angle> wiper <wiper angle> (notice the space in the name of the style!). Using rotary switch without
parameters will generate a default switch.
To add arrows, you can use the styles rotary switch - (no arrow, whatever the default), rotary switch
<- (counterclockwise arrow), rotary switch -> (clockwise) and 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 rotaryswitch, not for the styles.
128
\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}
4.20.3.1 Rotary switch anchors Rotary switches anchors are basically the same as the cute
switches, including access (with the <node name>-<anchor name> notation) to the internal connection
nodes. The geographical anchors work as expected, marking the limits of the component.
north
north north west north east
north west north east
center center
ext center
ext south west ext south ext south east
The code for the diagram at the left, above, without the markings for the anchors, is:
\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}
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:
129
1
2 3
4
\begin{circuitikz}
5 \draw (0,0) node[rotary switch=13 in 120 wiper 0](S){};
6
\foreach \i in {1,...,13} % requires "calc"
7
8
\path ($(S.aout \i)!1ex!(S.sqout \i)$)
9 node[font=\tiny\color{red}]{\i};
13 10
12 11 \end{circuitikz}
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 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{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}
4.20.3.2 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 multipoles/rotary/shape, and the thickness of the wiper with multipoles/rotary/thickness.
The optional arrow has thickness equal to the standard bipole thickness bipoles/thickness (default 2).
\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}
Finally, the size can be changed using the parameter tripoles/spdt/width (default 0.85).
\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}
130
4.20.4 Switch arrows
You can change the arrow tips used in all switches (traditional and “cute”) with the key switch end
arrow (by default the key is the word “default” to obtain the default arrow, which is latexslim). Also
you can change the start arrow with the corresponding switchable start arrow or wiper start arrow
(the default value “default” is equivalent to {}, which means no arrow). They keys are settable with
\ctikzset as with \tikzset (to ease their usage in nodes).
You can change that globally or locally, as ever. The tip specification is the one you can find in the TikZ
manual (“Arrow Tip Specifications”).
\begin{circuitikz}
\draw (0,2) to[cspst] ++(2,0)
node[cute spdt up arrow, anchor=in]{};
\draw (0,0) to[cspst] ++(2,0)
node[cute spdt up arrow, anchor=in,
switch start arrow={Bar[red]},
switch end arrow={Triangle[blue]}]{};
\end{circuitikz}
4.20.4.1 Rotary switch arrows. You can change the rotary switch arrow shape in the same way
as you change the ones in regular switches. Notice however that if you set either switch end arrow
or switch start arrow they will be followed only if you have set both arrows with <-> or equivalent,
otherwise just one will be used.
\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 (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){};
\ctikzset{switch end arrow={Triangle[blue]}}
\ctikzset{switch start arrow={Bar[red]}}
\begin{scope}[yshift=-2cm]
\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 (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){};
\end{scope}
\end{circuitikz}
131
4.21.1 American Logic gates
bin 1
American or port, type: node, fillable (node[american or
port]{}). Class: logic ports.
bout
bin 2
There is no “european” version of the following symbols; for now they are used both in american and
european styles, but iy may change in the future.
132
4.21.2 IEEE logic gates
In addition to the legacy ports, since release 1.1.0, logic ports following the recommended geometry of
distinctive-shape symbols in IEEE Std 91a-1991 Annex A (Recommended symbol proportions) are also
available40 .
These ports are completely independent from the legacy set (either american or european); they are not
eanbled by default because the relative size of the ports is very different from the legacy ones, and that
will disrupt every schematic (especially if drawn with absolute coordinate). If you want to use them as
default, you can use the command \ctikzset{logic ports=ieee} and by default the shapes and port,
or port and so on will be the IEEE standard ones.
The transmission gate (also known as “bowtie”) components are not described in the IEEE standard, so
they are simply inspired by the other IEEE ports — this is why their name is prefixed by ieee and not
by ieeestd. They are aliased to tgate and double tgate though, and it is recommended to use those
names (maybe in the future there will be american ports and/or european ports versions available).
in 1 bout
IEEE standard “or” port, type: node, fillable (node[ieeestd
out
or port]{}). Class: logic ports.
bin 2
up
N-not
IEEE standard “nor” port, type: node, fillable (node[ieeestd
left
nor port](N){}). Class: logic ports.
center
down
bin 1 ibin 1
right IEEE standard “xor” port xor, type: node, fillable
left (node[ieeestd xor port]{}). Class: logic ports.
body left
bout IEEE standard “xnor” port, type: node, fillable
out (node[ieeestd xnor port]{}). Class: logic ports.
body right
up
IEEE standard buffer port, type: node, fillable (node[ieeestd
in 1
bin 1 buffer port]{}). Class: logic ports.
down
bout Schmitt port matched to IEEE standard ports, type: node, fil-
in out
lable (node[ieeestd schmitt port]{}). Class: logic ports.
40 Thanks to Jason for proposing it and digging out the info, see this GitHub issue.
133
Inverting Schmitt port matched to IEEE standard ports, type:
node, fillable (node[ieeestd invschmitt port]{}). Class:
logic ports.
notgate
up
bout IEEE style transmission gate, type: node, fillable (node[ieee
in 1 out
bin 1 down tgate]{}). Class: logic ports.
gate
bnotgate
up
bout IEEE style double transmission gate, type: node, fillable
in out (node[ieee double tgate]{}). Class: logic ports.
bin
down
bgate
north west
Schmitt symbol to add to input pins if needed, type: node,
fillable (node[schmitt symbol]{}). Class: logic ports.
south east
bin 1
European or port, type: node, fillable (node[european or
≥1
port]{}). Class: logic ports.
bout
bin 2
134
European not port, type: node, fillable (node[european not
1
port]{}). Class: logic ports.
If (default behaviour) americanports option is active (or the style [american ports] is used), the
shorthands and port, or port, buffer port, nand port, nor port, not port, xor port, xnor port,
schmitt port and invschmitt port are equivalent to the american version of the respective logic
port.
If otherwise europeanports option is active (or the style [european ports] is used), the shorthands
and port, or port, buffer port, nand port, nor port, not port, xor port, xnor port are equiv-
alent to the european version of the respective logic port; schmitt port and invschmitt port are
the same as in american ports style.
Finally, for version 1.1.0 and up, you can use the style ieee ports to set the shorthands to the set
of ieeestd ports. (There is no global option for this).
The one-input, one-output ports have a handy path-style equivalent; they are the following:
bnotgate
inline tgate: transmission gate, type: path-style,
fillable, nodename: tgate. Class: logic ports.
bgate
bnotgate
inline double tgate: double transmission gate, type:
path-style, fillable, nodename: double tgate. Class:
logic ports.
bgate
Those ports follows the current selected style, although you can change it on the fly (even if it has not
a lot of sense); you can apply labels, annotations and (again, not a lot of sense) voltages to them. The
assigned value is typeset as if it were the main text of the node.
135
label
I1
+ − \begin{circuitikz}[american]
\ctikzset{logic ports=ieee}
∆V \draw (0,0) to[inline not=I1, l=label, v=$\Delta V$] ++(2,0);
\draw (0,-2) to[inline not, a=ann, european ports] ++(2,0);
\end{circuitikz}
1
ann
Notice that in the inline version the leading pins are not drawn, so in the case of the transmission gates
you have to use the border pins to connect the gates.
\begin{circuitikz}[ ]
\ctikzset{logic ports=ieee,
logic ports/fill=yellow}
\draw (0,0) to[inline not] ++(2,0)
to[inline double tgate, name=P] ++(3,0)
(P.bnotgate) |- ++(-3,1);
\end{circuitikz}
Since version 1.0.0, the default shape of the family of american “or” ports has changed to a more “pointy”
one, for better distinguish them from the “and”-type ports. You can still going back to the previous aspect
with the key american or shape that can be set to pointy or roundy. The legacy style will enact the
old, roundy style also.
\begin{circuitikz}[
american]
% legacy shapes
\ctikzset{american or shape=roundy}
\ctikzset{logic ports/fill=yellow}
\node [or port](O1) at (0,0) {};
\node [nor port](O2) at (0,-1.5) {};
\node [xor port](O3) at (0,-3) {};
\node [xnor port](O4) at (0,-4.5) {};
\begin{scope}[xshift=3cm]
% new shapes
\ctikzset{american or shape=pointy}
\node [or port](O1) at (0,0) {};
\node [nor port](O2) at (0,-1.5) {};
\node [xor port](O3) at (0,-3) {};
\node [xnor port](O4) at (0,-4.5) {};
\end{scope}
\end{circuitikz}
4.21.5.1 American logic port customization Logic port class is called logic ports, so you
can scale them all with logic ports/scale (default 1.0).
As for most components, you can change the width and height of the ports; the thickness is given by the
parameter tripoles/thickness (default 2).
It is possible to change height and width of the logic ports using the parameters tripoles/american type
port/ plus width or height:
136
\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] {};
This is especially useful if you have ports with more than two inputs, which are instantiated with the
parameter number inputs :
\begin{circuitikz}
\draw (0,3) node[american and port] (A) {P1};
\begin{scope}
\ctikzset{tripoles/american or port/height=1.6}
P1 \draw (A.out) -- ++(0.5,0)
node[american or port,
P2 number inputs=5,
anchor=in 1] (B) {P2};
P3
\end{scope}
\draw (0,1.5) node[american or port] (C) {P3};
\draw (C.out) |- (B.in 2);
\end{circuitikz}
You can suppress the drawing of the logic ports input leads by using the boolean key logic ports draw
input leads (default true) or, locally, with the style no inputs leads (that can be reverted with input
leads), like in the following example. The anchors do not change and you have to take responsibility do
do the connection to the “border”-anchors.
\begin{circuitikz}
\node [or port](O1) at (0,2) {};
\node [or port, no input leads](O1) at (2,2) {};
\ctikzset{logic ports draw input leads=false}
\node [and port](O1) at (0,0) {};
\node [nand port, input leads](O1) at (2,0) {};
\end{circuitikz}
This is useful if you need to draw a generic port, like the one following here:
\begin{circuitikz}
\ctikzset{tripoles/american nand port/height=1.6}
\draw (0,0)
node[american nand port,
circuitikz/tripoles/american nand port/height=1.1,
Pn
…
In an analogous manner, there is a setting logic ports draw output leads (and a corresponding style
no output leads) that suppresses the drawing of the output lead. A shortcut boolean key logic ports
draw leads will suppress or enable all leads (the corresponding styles are no leads and all leads).
You can tweak the appearance of american “or” family (or, nor, xor and xnor) ports, too, with the
parameters inner (how much the base circle go “into” the shape, default 0.3) and angle (the angle at
which the base starts, default 70).
137
\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] {};
4.21.5.2 American logic port anchors These are the anchors for logic ports:
\begin{circuitikz}
\draw (0,3) node[american and port] (A) {P1};
\node at (A.bin 1) [ocirc, left]{} ;
\begin{scope}
P1 \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};
P2
\node at (B.bin 3) [ocirc, left]{} ;
P3 \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}
As you can see, the center anchor is (for historic reasons) not in the center at all. You can fix this with
the command \ctikzset{logic ports origin=center}:
\begin{circuitikz}
\ctikzset{logic ports origin=center}
\draw (0,0) node[and port] (myand) {}
1
3 (myand.in 1) node[anchor=east] {1}
2 (myand.in 2) node[anchor=east] {2}
(myand.out) node[anchor=west] {3};
center \draw[<-] (myand.center) -- ++(1,-1)
node{center};
\end{circuitikz}
138
\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}
In the case of not, there are only in and out (although for compatibility reasons in 1 is still defined and
equal to in):
\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}
This last circuit could be drawn also (and probably in a more natural manner) using the path-style
components:
\begin{circuitikz}[american]
\draw (0,0) node[ground]{} to[C] ++(0,1.5)
coordinate(c)
to[inline not] ++(2.5,0) -- ++(0,1)
-| ++(-5,-1)
to[inline not] (c);
\end{circuitikz}
The rest of this section will assume you have issued the command \ctikzset{logic ports=ieee}, so that
the short form of the names is used.
IEEE standard logic gates have a basic difference with the legacy ones: the proportions of their shapes
does not change when you change the size, so you can’t have a “tall” port or a “squatty” ones. The
two-inputs gates, by default, have their default size designed so that they match the chips component
(see 4.24).
1 8 \begin{circuitikz}
IC2A \draw (0,0) node[dipchip](C){IC} (C.pin 8)
2 7
IC node[or port, anchor=in 1,
3 6
color=red](A){IC2A};
4 5 \end{circuitikz}
If you need, say, a 4-inputs port, the port will look like this:
1 8
\begin{circuitikz}
2 7 IC2A \draw (0,0) node[dipchip](C){IC} (C.pin 8)
IC node[or port, anchor=in 1, number inputs=4,
3 6
color=red](A){IC2A};
4 5 \end{circuitikz}
139
…and in this case it is clear that it does not match. With standard ports, there are two possibilities. The
first one is to scale the port; if you set the port height so that it has the same size (see “IEEE logic gates
customization” below for details) as the number of ports, they will match again.
\begin{circuitikz}
1 8
\draw (0,0) node[dipchip](C){IC} (C.pin 8)
2 7 node[or port, anchor=in 1,
IC IC2A number inputs=4,
3 6
circuitikz/ieeestd ports/height=4,
4 5 color=red](A){IC2A};
\end{circuitikz}
But then the size of the port is quite “unusual”. The solution is technical literature is to use what we can
call a “rack” for the inputs; basically, only a certain number of pins are kept on the port, and the other
are put on an extended input line.
\begin{circuitikz}
1 8
\draw (0,0) node[dipchip](C){IC} (C.pin 8)
2 7 node[or port, anchor=in 1,
IC IC2A number inputs=4,
3 6
inner inputs=2,
4 5 color=red](A){IC2A};
\end{circuitikz}
When using the inner inputs key, keep in mind the rule of thumbs:
• the distance between the pins is matched with the chip ones when the inner inputs match the
/ieeestd ports/height key;
• when the number of pins in the rack is odd, the result is often quite ugly, so try to avoid it.
For example, look at the following example; given that we are asking an odd number of pins on the rack,
some of the inputs are drawn on the port’s border, resulting in a less-than-ideal diagram.
1 8 \begin{circuitikz}
\draw (0,0) node[dipchip](C){IC} (C.pin 8)
2 7
IC node[or port, anchor=in 1,
3 6 IC2A number inputs=5,
4 5
inner inputs=2,
color=red](A){IC2A};
\end{circuitikz}
In this case, if you don’t like the solution, the better approach is to let the gate grow a bit.
\begin{circuitikz}
1 8
\draw (0,0) node[dipchip](C){IC} (C.pin 8)
2 7 node[or port, anchor=in 1,
IC number inputs=5,
3 6 IC2A
inner inputs=3,
4 5 circuitikz/ieeestd ports/height=3,
color=red](A){IC2A};
\end{circuitikz}
The good thing about the rack mechanism is that you can have quite big ports without problems.
140
IC1A
You can use the additional elements (the notcirc and the schmitt symbol to obtain circuits like the
following ones (well, a bit of a mix of conventions, but...):
\begin{circuitikz}
\draw (0,0) node[and port](A){A} (A.out)
node[buffer port, anchor=in,
component text=left](B){B} (B.bin)
node[schmitt symbol, above left]{}
A B (A.bin 1) node[schmitt symbol, right]{};
\node [notcirc, left] at (A.bin 1) {};
\node [notcirc, above](C) at (B.up) {};
\draw (C.north) |- ++(-1,1) (B.down) --++(0,-1);
\end{circuitikz}
Notice the key component text=left that moves the label near to the left border of the component. There
is also a \ctikzset{component text=left} if you prefer to have it as a default for all the IEEE ports.41
4.21.6.1 Stacking and aligning IEEE standard gates. The standard gates are designed so
that they stacks up nicely when positioned using the external leads as anchors. Notice that the ports do
have different sizes, but the leads lengths are designed to counter the differences.
\begin{circuitikz}
\draw
A1 A1 (0,0) node[and port, anchor=in 1]{A1}
(0,-1.2) node[nand port, anchor=in 1]{A2}
(0,-2.4) node[or port, anchor=in 1]{A3}
A2 A2 (0,-3.6) node[xnor port, anchor=in 1]{A4};
\draw
(3,0) node[and port, anchor=in 1](A1){A1}
A3 A3 (3,-1.2) node[nand port, anchor=in 1]{A2}
(3,-2.4) node[or port, anchor=in 1]{A3}
(3,-3.6) node[xnor port, anchor=in 1](A4){A4};
A4 A4 \draw[red, dashed]([yshift=0.8cm]A1.body left)
-- ([yshift=-0.8cm]A4.body left);
\end{circuitikz}
The length of the external leads can be changed by the user, but notice that if you use a too small value
you can jeopardize that property.
The single input ports (not port, buffer port and their Schmitt equivalent) are smaller that the six
standard ports, so they are not kept aligned by default; the just have the same distance at the input side.
For the not ports, the left position of the text results often in a better look (the centered text in the
triangle seems to be much more at the right).
41 You can use the same key with amplifiers, too.
141
\begin{circuitikz}
A1 A1 \ctikzset{component text=left}
\draw (0,0) node[nand port, anchor=in 1]{A1}
(0,-1.8) node[buffer port, anchor=in 1]{A2}
(0,-3.2) node[not port, anchor=in 1]{A3};
A2 A2 \draw (3,0) node[nand port, anchor=in 1](A1){A1}
(3,-1.8) node[buffer port, anchor=in 1]{A2}
(3,-3.2) node[not port, anchor=in 1](A3){A3};
\draw[red, dashed]([yshift=0.8cm]A1.body left)
A3 A3 -- ([yshift=-0.8cm]A3.body left);
\end{circuitikz}
4.21.6.2 IEEE standard ports customization There are several parameters that can be used
to customize the IEEE standard ports, although less than the ones in the legacy american ones — the
basic shape is set to follow the IEEE recommendation. The basic parameters are shown in the following
table, and they can be set via \ctikzset{ieeestd ports/...}
baselen 0.4 the basic length for every dimension, as a fraction of the
(scaled) resistor length
height 2 the height of the port, in term of baselen. Pin distance is
given by this parameter divided by the inner pins.
pin length 0.7 length of the external pin leads that are drawn with the port.
This length is always calculated starting from the inner body
of the shape.
not radius 0.154 radius of the “not circle” added to the negated-output ports.
The default value is the IEEE recommended one.
xor bar distance 0.192 distance of the detached input shape in xor and xnor ports.
The default value is the IEEE recommended one.
xor leads in 1 If set to 0, there will be no leads drawn between the detached
input line and the body in the xor and xnor ports. IEEE rec-
ommends 1 here.
schmitt symbol size 0.3 Size of the small Schmitt symbol to use near input leads.
For example, using a not radius of 0.1 will give a “not ball” of the same size of a connecting pole, as it
is in the legacy ports.
\begin{circuitikz}
\draw (0,2) node[xnor port](P){}
(P.out) to[short, -o] ++(1,0);
\ctikzset{ieeestd ports/.cd, not radius=0.1,
xor bar distance=0.3, xor leads in=0}
\draw (0,0) node[xnor port](P){}
(P.out) to[short, -o] ++(1,0);
\end{circuitikz}
In addition to the specific parameters, you can also apply to these ports the boolean style no input leads
as in legacy ones (this simply does not draw the input leads, but the anchors stays where they should):
\begin{circuitikz}
\draw (0,0) node[nand port,
number inputs=5, no input leads,](B){Pn};
Pn
…
142
Changing the leads length must be done with a bit of care, because if the length is shorter than the port
left or right extrusions strange things can happen (yes, a 4-inputs xnor gates is not so well defined…but
it’s a nice example to show):
\begin{circuitikz}
\ctikzset{ieeestd ports/pin length=0.2}
\draw (0,0) node[xnor port,
number inputs=4, inner inputs=2](B){};
\end{circuitikz}
4.21.6.3 IEEE standard ports anchors Geographical anchors define the rectangular space that
the port is using, included the leads if presents.
north
north west north east
north
north west north east
The inputs anchor are in number (on the tip of the lead) and bin number (border inputs) on the com-
ponent’s border (useful if you draw the ports with no inut leads). Additionally, you have ibin number
(inner border inputs) for the x-type ports. The anchor named left is where a central border input would
be.
In one-input ports (not port, the buffer, and Schmitt-type ports) you can use plain in or in 1 indifferently.
On the output, out is on the tip of the lead, and bout on the rightmost border (so, if there is a negation
circle, it is on it); right is the same as bout.
The main body of the port is marked with body left and body right anchors (as seen in the middle port
in the diagram above); you have also an up and down anchors centered on the body (you can use them as
enable signals or similar things).
Finally, the internal notcirc node used for the output negation is accessible with the name nodename-not,
where nodename is the name given to the logic port node.
4.21.6.4 Transmission gate symbols. The tgate and double tgate components are available
since 1.2.4 but only in the IEEE style. An additional parameter tgate scale (default 0.7; if you set
this to 1 the triangles will have the same size as a ieeestd buffer port) select the relative scale of the
components.
\begin{circuitikz}
\ctikzset{logic ports=ieee}
\draw (0,0) to[inline not, *-*] ++(2,0)
node[tgate, anchor=in]{};
\end{circuitikz}
143
The anchors for the tgate’s control point are called gate and notgate (and the corresponding bgate and
bnotgate for the border anchors).
notgate bnotgate
notgate bnotgate
left right left right
in out in out
bin bout bin bout
gate bgate
gate bgate
European logic port are the same class as american and IEEE-style ones, and they obey the same class
modifier. Moreover, you can use the no inputs pin as in the other logic ports to suppress input pins.
4.21.7.1 European logic port customization Normally the European-style logic port with in-
verted output are marked with a small triangle; if you want you can change it with the key tripoles/european
not symbol; its default is triangle but you can set it to circle like in the following example. As you
can see, the circle size is the same as the circuit poles; if you prefer the size used in the IEEE standard
ports, you can use set it to ieee circle.
\begin{circuitikz}[european]
& \draw (0,3) node[nand port](A){}
(A.out) to[short, *-o] ++(0.5,0);
\ctikzset{tripoles/european not symbol=circle}
\draw (0,1.5) node[nand port](A){}
&
(A.out) to[short, *-o] ++(0.5,0);
\ctikzset{tripoles/european not symbol=ieee circle}
\draw (0,0) node[european nand port](A){}
(A.out) to[short, *-o] ++(0.5,0);
&
\end{circuitikz}
In some standard, the xnor port is different — without the negation at the end and with just an = sign.42
You can switch to this if you like, with the key european xnor style that can be default or direct.
\begin{circuitikz}[european]
\draw (0,0) node[xnor port]{};
=1 = \ctikzset{european xnor style=direct}
\draw (3,0) node[xnor port]{};
\end{circuitikz}
4.21.7.2 European logic port anchors The anchors are basically the same as in the american-
style ports.
left right
& bin 1 & bin 1 & bin 1 &
center bout bout bout
bin 2 bin 2 bin 2
144
4.22 Flip-flops
Flip-flops (available since version 1.0.0) are an hybrid between the logic ports and the chips. They have
a class by themselves (flipflops) but the default parameters are set at the same values as the logic gates
one.
The default flip flop is empty: it is just a rectangular box like a blank dipchip with 6 pins.
up
bup
bpin 1 bpin 6
pin 1 pin 6
bdown
down
As you can see, in a void flip flop no external pins are drawn: you have to define the meaning of each
of them to see them. To define a specific flip-flop, you have to set a series of keys under the \ctikzset
directory multipoles/flipflop/, corresponding to pins 1…6, u for “up” and d for “down”:
• a text value t0, t1, …t6, and tu and td (the last ones for up and down) which will set a label on
the pin;
• a clock wedge flag (c0, …c6, cu, cd), with value 0 or 1, which will draw a triangle shape on the
border of the correspondig pin;
• a negation flag (n0, …n6, nu, nd), with value 0 or 1, which will put and ocirc shape on the outer
border of the correspondig pin.
To set all this keys, an auxiliary style flipflop def is defined, so that you can do the following thing:
\tikzset{flipflop AB/.style={flipflop,
flipflop def={t1=A, t3=B, t6=Q, t4={\ctikztextnot{Q}},
td=rst, nd=1, c2=1, n2=1, t2={\texttt{CLK}}},
}}
to obtain:
bpin 1 bpin 6
pin 1 A Q pin 6
pin 2 CLK Example custom flip flop, type: node, fillable (node[flipflop
AB]{}). Class: flipflops.
pin 3 B Q
rst
bdown
down
\ctikztextnot{} is a small utility macro to set a overbar to a text, like RST (created by \ctikztextnot{RST}).
By default, the following flip-flops are defined:
145
D Q
CLK Q
S Q
R Q
D Q
Edge-triggered synchronous flip-flop D, type: node, fillable
(node[flipflop D]{}). Class: flipflops.
T Q
Edge-triggered synchronous flip-flop T, type: node, fillable
(node[flipflop T]{}). Class: flipflops.
J Q
Edge-triggered synchronous flip-flop JK, type: node, fillable
(node[flipflop JK]{}). Class: flipflops.
K Q
If you prefer that the negated output is labelled Q and a dot indicating negation is shown, you can add
the dot on notQ key:
J Q
synchronous flip-flop JK with asynchronous set and reset,
type: node, fillable (node[flipflop JK, dot on notQ]{}).
Class: flipflops.
K Q
You can also add “vertical” asynchronous set and reset (active low) adding the style add async SR to all
of them:
146
SET
J Q
synchronous flip-flop JK with asynchronous set and reset,
type: node, fillable (node[flipflop JK, add async SR]{}).
Class: flipflops.
K Q
RST
If you like different pin distributions, you can easily define different flip-flops to your taste. For example,
somebody likes the clock pin on the bottom pin:
\tikzset{flipflop myJK/.style={flipflop,
flipflop def={t1=J, t2=K, t6=Q, t4={\ctikztextnot{Q}}, c3=1}}
}
J Q
Example custom flip flop, type: node, fillable (node[flipflop
K
myJK]{}). Class: flipflops.
The standard definition of the default flip-flops are the following (in the file pgfcircmultipoles.tex):
\tikzset{
% async
latch/.style={flipflop, flipflop def={t1=D, t6=Q, t3=CLK, t4=\ctikztextnot{Q}}},
flipflop SR/.style={flipflop, flipflop def={t1=S, t3=R, t6=Q, t4=\ctikztextnot{Q}}},
% sync
flipflop D/.style={flipflop, flipflop def={t1=D, t6=Q, c3=1, t4=\ctikztextnot{Q}}},
flipflop T/.style={flipflop, flipflop def={t1=T, t6=Q, c3=1, t4=\ctikztextnot{Q}}},
flipflop JK/.style={flipflop,
flipflop def={t1=J, t3=K, c2=1, t6=Q, t4=\ctikztextnot{Q}}},
% additional features
add async SR/.style={flipflop def={%
tu={\ctikztextnot{SET}}, td={\ctikztextnot{RST}}}},
dot on notQ/.style={flipflop def={t4={Q}, n4=1}},
}
Flip-flops have all the standard geometrical anchors, although it should be noticed that the external pin
are outside them. The pins are accessed by the number 1 to 6 for the lateral ones (like in DIP chips), and
with the up and down anchors for the top and bottom one. All the pins have the “border” variant (add a
b in front of them, no spaces).
147
up
north bup
north west north east bpin 1 bpin 6
SET
pin 1 J Q pin 6
J Q bpin 2 bpin 5
pin 2 pin 5
west text east
center pin 3 K Q pin 4
RST
K Q bpin 3 bpin 4
bdown
south west south east
south down
If you have negated pins, you can access the ocirc shapes with the name as <nodename>-N<pin number>,
and all the respective anchors (for example — myFFnode-N4.west).
Flip-flop’s size is controlled by the class parameters (like flipflops/scale) and the specific \ctikzset
keys multipoles/flipflop/width and multipoles/flipflop/pin spacing. Class parameters are also
used for line thickness and fill color. The default values are matched with the logic ports ones.
The fonts used for the pins 1…6 is set by the key multipoles/flipflop/font (by default \small in LATEX
and the equivalent in other formats) and the font used for pins u and d is multipoles/flipflop/fontud
(\tiny by default). You can change it globally or specifically for each flip flop.
As in chips, you can change the length of the external pin with the key external pins width; you can
for example have a pinless flip-flop like this:
SET
J Q
synchronous flip-flop JK, type: node, fillable (node[flipflop
JK, add async SR, external pins width=0]{}). Class:
flipflops.
K Q
RST
Notice however that negated pins when the pins width is zero has to be handled with care. As explained in
the poles sections, the ocirc shape is drawn at the end of the shape to cancel out the wires below; so if you
use a pinless flipflop when you do the connection you should take care of connecting the symbol correctly.
J Q
To this end, the shapes of the negation circles are made available as <nodename>-N<pin number>, as you
can see in the next (contrived) example.
148
Normally the symbols on the flip-flop are un-rotated when you rotate the symbol, but as in case of chips,
you can avoid it.
SET
J Q
Q Q
Q
RST
SET
SET RST
J K
K
J
K Q
RST
\begin{tikzpicture}
\draw (0,0) node[flipflop JK, add async SR]{};
\draw (3,0) node[flipflop JK, add async SR, rotate=90]{};
\draw (7,0) node[flipflop JK, add async SR, rotate=90, rotated numbers]{};
\end{tikzpicture}
You can also change the size of the wedge, with the key multipoles/flipflop/clock wedge size (default
value 0.2).
\begin{circuitikz}[]
\draw (0,0) node[flipflop JK]{JK};
J Q J Q J Q \ctikzset{multipoles/flipflop/clock
wedge size=0.1}
JK JK JK \draw (2.3,0) node[flipflop JK]{JK};
\ctikzset{multipoles/flipflop/clock
K Q K Q K Q wedge size=0.4}
\draw (4.6,0) node[flipflop JK]{JK};
\end{circuitikz}
Flip-flops “not circles” follows the current logic port setting (either if you choose ieee ports, or if you
are using european ports with european not symbol set to cirle or ieee circle.
J Q
\begin{circuitikz}[]
\ctikzset{logic ports=european,
& JK tripoles/european not symbol=ieee circle}
\draw (0,0) node[nand port](A){}
K Q (A.out) to[short] ++(0.5,0)
node[flipflop JK, dot on notQ, anchor=pin 2]{JK};
\ctikzset{logic ports=european,
J Q tripoles/european not symbol=circle}
\draw (0,-3) node[nand port](A){}
(A.out) to[short] ++(0.5,0)
& JK
node[flipflop JK, dot on notQ, anchor=pin 2]{JK};
\end{circuitikz}
K Q
149
lpin 1 blpin 1
lpin 2 blpin 2
MD1 rpin 1
brpin 1 mux-demux, type: node, fillable (node[muxdemux]{MD1}).
Class: muxdemuxes.
bbpin 1
bpin 1
You can define a custom shape for the muxdemuxes using an interface similar to the one used in flip-flops;
for example:
\tikzset{demux/.style={muxdemux, muxdemux def={Lh=4, Rh=8, NL=1, NB=3, NR=8}}}
will generate the following shape (the definition above is already defined in the package):
MD2
Demultiplexer 1 → 23 with Lh=4, Rh=8, NL=1, NB=3, NR=8 ,
type: node, fillable (node[demux]{MD2}). Class: muxdemuxes.
The shape can be also defined with an inset. For example it can be used like this to define a 1-bit adder
(also already available):
\tikzset{one bit adder/.style={muxdemux,
muxdemux def={Lh=4, NL=2, Rh=2, NR=1, NB=1, w=1.5,
inset w=0.5, inset Lh=2, inset Rh=1.5}}}
150
ALU, type: node, fillable (node[ALU]{\rotatebox
ALU
w
In designing the shape there are several pa-
rameters to be taken into account. In the dia-
gram on the right they are shown in a (hope-
fully) practical way. The parameter can be set Lh
inset Lh
Rh
inset Rh
in a node or in a style using the muxdemux def
key as shown above, or set with \ctikzset as
multipoles/muxdemux/Lh keys and so on.
inset w
NL, NR, NB, NT : number of pins relatively on the left, right, bottom and top side (default 8, 1, 3,
0). When an inset is active (in other words, when Lh > 0) the pins are positioned on the top and
bottom part, not in the inset; the exception is when the number of left pins is odd, in which case
you have one pin set on the center of the inset. If you do not want a pin in one side, use 0 as number
of pins.
square pins : set to 0 (default) if you want the square pins to stick out following the slope of the bottom
or top side, 1 if you want them to stick out in a square way (see the example above for the ALU).
All the distances are multiple of multipoles/muxdemux/base len (default 0.4, to be set with \ctikzset),
which is relative to the basic length. That value has been chosen so that, if you have a numbers of pins
which is equal to the effective distance where they are spread (which is Lh without inset, Lh − (inset Lh)
with an inset), then the distance is the same as the default pin distance in chips, as shown in the next
circuit. In the same drawing you can see the effect of square pins parameters (without it, the rightmost
bottom lead of the mux 4by2 shape will not connect with the below one).
1 8
\begin{circuitikz}
\tikzset{mux 4by2/.style={muxdemux,
2 7 muxdemux def={Lh=4, NL=4, Rh=3,
IC1 MUX NB=2, w=2, square pins=1}}}
3 6
\node [dipchip, num pins=8](A) at (0,0) {IC1};
4 5
\node [one bit adder, scale=-1, anchor=lpin 2]
at (A.pin 1){};
8 7 \node [mux 4by2, anchor=lpin 1](B)
1 6 at (A.pin 8){MUX};
IC2 \node [qfpchip, num pins=8, anchor=pin 8] at
2 5
3 4 (B.bpin 1) {IC2};
\end{circuitikz}
151
4.23.2 Mux-Demux customization
Mux-demuxes have the normal parameters of their class (muxdemuxes): you can scale them with the
\ctikzset key muxdemuxes/scale, control the border thickness with muxdemuxes/thickness and the
default fill color with muxdemuxes/fill — they are set, by default, at the same values than logic ports.
External pins’ length is controlled by the key multipoles/external pins width (default 0.2) or by the
style external pins width. The parameter multipoles/external pins thickness is also respected.
like in chips. In addition, like in logic ports, you can suppress the drawing of the leads by using the
boolean key logic ports draw input leads (default true) or, locally, with the style no inputs leads
(that can be reverted with input leads). The main difference between setting external pins width to
0 or using no inputs lead is that in the first case the normal pin anchors and the border anchors will
coincide, and in the second case they will not move and stay where they should have been if the leads
were drawn.
You can draw only selected pins and leave out the rest by setting the keys multipoles/draw only side
pins and the corresponding style draw only side pins where side can be left, right, top, bottom.
Those key accept a comma separated list of pin numbers or ranges of pin numbers (a range is given as
⟨start⟩ - ⟨end⟩, ends are inclusive). The numbers will not be expanded in any way, except those given
as ends of ranges. A special value (and the initial one) is all, in which case all pins are drawn. The
anchors will be adjusted, such that each xpin n will be placed at the end of the pins which are drawn,
and coincide with the bxpin n anchors for the suppressed pins.
\begin{circuitikz}
\node [muxdemux, muxdemux def={NL=4, NR=3, NT=5, NB=3, w=2,
inset w=0.5, Lh=4, inset Lh=2.0, inset Rh=1.0,
square pins=1},
X
draw only right pins={1,3},
draw only top pins={1-3},
draw only bottom pins={3}](C) at (0,0) {X};
\end{circuitikz}
Mux-demuxes have a plethora of anchors. As in the case of chips, the geographic anchors mark the
rectangle occupied by the component, without taking into account the pin leads.
north
north west north east
top
top left
center up
top right inset top
center up inset top left
inset top right
center inset center narrow center
west text east left X right inset left
inset right
center
center down inset bottom left inset bottom right
The pins anchors are named lpin, rpin, bpin and tpin for the left, right, bottom and top pin respectively,
and points to the “external” pin. The border pins are named the same, with a b added in front: blpin,
brpin, bbpin and btpin. The following graph will show the numbering and position of the pin anchors.
152
blpin 1 btpin 1
tpin 1 11
2
brpin 1
2 3
4
3 1
2 3
lpin 1 1
1
1 rpin 1 2
2 3
4
X2 4 X
5
3 6
4
1 7
3
2 5
3 8
6 3
2
bbpin 2 71
bpin 2 bbpin 2
The code that implemented the printing of the numbers (which in muxdemuxes, differently from chips, are
never printed automatically) in the last graph is the following one.
\begin{circuitikz}
\node [muxdemux, muxdemux def={NL=4, NR=3, NT=3, NB=3, w=2, inset w=0.5,
Lh=4, inset Lh=2.0, inset Rh=1.0, square pins=1}](C) at (0,0) {X};
\node [muxdemux, muxdemux def={NL=7, NR=8, NT=4, inset w=1.0,
inset Lh=4.0, inset Rh=0.0}](D) at (4,0) {X};
\foreach \myn/\NL/\NR/\NB/\NT in {C/4/3/3/3,D/7/8/3/4} {
\foreach \myp in {1,...,\NL} \node[right, font=\tiny] at (\myn.blpin \myp){\myp};
\foreach \myp in {1,...,\NR} \node[left, font=\tiny] at(\myn.brpin \myp) {\myp};
\foreach \myp in {1,...,\NB} \node[above, font=\tiny] at (\myn.bbpin \myp){\myp};
\foreach \myp in {1,...,\NT} \node[below, font=\tiny] at (\myn.btpin \myp){\myp};
}
You can use these shapes to draw a lot of symbols that are unavailable; using a bit of LATEX command
trickery you can use them quite naturally too…. Examples with personalized amplifier shapes are listed
in section 4.19.3.
As an additional example, this was used before the introduction of the double tgate symbol in 1.2.4
(see 4.21.6.4):
\def\tgate#1{
node[simple triangle, anchor=left, no input leads](#1-LR){}
(#1-LR.right) node[simple triangle, xscale=-1,
anchor=left](#1-RL){}
([yshift=.5ex]#1-RL.btpin 1) node[ocirc]{}}
\begin{circuitikz}[
simple triangle/.style={muxdemux, muxdemux def={
NL=1, NR=1, NB=1, NT=1, w=2, Lh=2, Rh=0,
}}]
\draw (0,0) \tgate{A} (0,-2) \tgate{B};
\draw (A-RL.bpin 1) -- (B-RL.tpin 1);
\end{circuitikz}
Finally, you can play with them to create chips that have generic numbers of pins on the four sides, as in
the following example (asked on TeX.Stackexchange):
153
\begin{tikzpicture}[scale=0.8, transform shape]
\tikzset{ic555/.style={muxdemux,
muxdemux def={Lh=10, NL=5, Rh=10, NR=5,
NB=2, w=6, NT=2, square pins=1},
no input leads, external pins width=0.4,
circuitikz/muxdemuxes/fill=blue!10}
}
\node [ic555, font=\small\ttfamily,align=center](A)
8 4 at (0,0) {555\\Astable};
% left pins
\foreach \rawpin/\npin/\label in
{2/7/Discharge, 4/2/Trigger, 5/6/Threshold} {
7 \draw (A.lpin \rawpin) -- (A.blpin \rawpin)
Discharge
node[midway, blue, font=\small, above]{\npin}
555 3 node[right, font=\small]{\label};
Astable }
2
% top pins
Trigger \foreach \rawpin/\npin in {1/8, 2/4} {
\draw (A.tpin \rawpin) -- (A.btpin \rawpin)
6 node[midway, blue, font=\small, left]{\npin};
Threshold
}
5 1 % bottom pins
\foreach \rawpin/\npin in {1/5, 2/1} {
\draw (A.bpin \rawpin) -- (A.bbpin \rawpin)
node[midway, blue, font=\small, left]{\npin};
}
% finally, left
\draw (A.rpin 3) -- (A.brpin 3)
node[midway, blue, font=\small, above]{3};
\end{tikzpicture}
1 8
2 7
Dual-in-Line Package chip, type: node, fillable
3 6 (node[dipchip]{}). Class: chips.
4 5
8 7
1 6
Quad-Flat Package chip, type: node, fillable
2 5 (node[qfpchip]{}). Class: chips.
3 4
You can scale chips with the key chips/scale. As ever, that will not scale text size of the labels, when
they are printed.
The line thickness of the main shape is controlled by multipoles/thickness (default 2) and the one of
the external pins/pads with multipoles/external pins thickness (default 1).
154
You can customize the DIP chip with the key multipoles/dipchip/width (with a default of 1.2) and the
key multipoles/dipchip/pin spacing (default 0.4) that are expressed in fraction of basic lengths (see
section 3.1.4). 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 multipoles/qfpchip/pin spacing key.
The number of pins is settable with the key num pins. Please notice that the number of pins must be
even for dipchips and multiple of 4 for qfpchips, otherwise havoc will ensue.
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 multipoles/external pins width greater than 0 (default value
is 0.2, so you’ll have leads as shown above). Moreover, you can transform the thin lead into a pad by
setting the key multipoles/external pad fraction to something different form 0 (default is 0); the value
expresses the fraction of the pin spacing space that the pad will use on both sides of the pin.
You can, if you want, avoid printing the numbers of the pin with hide numbers (default show numbers)
if you prefer positioning them yourself (see the next section for the anchors you can use).
\begin{circuitikz}
\ctikzset{multipoles/thickness=4}
RST
\ctikzset{multipoles/external pins thickness=2}
\draw (0,0) node[dipchip,
num pins=12,
hide numbers,
IC1
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}
Also, you can suppress the drawing of the pins, by using the style no inputs leads (that can be reverted
with input leads). The main difference between setting external pins width to 0 or using no inputs
lead is that in the first case the normal pin anchors and the border anchors will coincide, and in the
second case they will not move and stay where they should have been if the leads were drawn.
For special use you can suppress the orientation mark with the key no topmark (default topmark).
\begin{circuitikz}
1 8
\draw (0,0) node[dipchip,
2 7 num pins=8, no topmark,
IC1 external pins width=0.0](C){IC1};
3 6
\draw (C.pin 1) -- ++(-0.5,0) to[R]
4 5 ++(0,-1.5) node[ground]{};
\end{circuitikz}
The font used for the pins is adjustable with the key multipoles/font (default \tiny)
16 15 14 13
\begin{circuitikz}
1 12 \ctikzset{multipoles/font={\color{red}\tiny}}
\draw (0,0) node[qfpchip,
2 11
IC1 num pins=16,
3 10 external pad fraction=6](C){IC1};
4 9
\draw (C.pin 1) -- ++(-0.5,0) to[R]
5 6 7 8 ++(0,-2) node[ground]{};
\end{circuitikz}
155
You can draw only selected pins and leave out the rest by setting multipoles/draw only pins43 . This
key accepts a comma separated list of pin numbers or ranges of pin numbers (a range is given as ⟨start⟩
- ⟨end⟩, ends are inclusive). The numbers will not be expanded in any way, except those given as ends of
ranges. A special value (and the initial one) is all, in which case all pins are drawn. The anchors will be
adjusted, such that each pin n will be placed at the end of the pins which are drawn, and coincide with
the bpin n anchors for the suppressed pins.
\begin{circuitikz}
\draw (0,3) node[dipchip,
1 8
num pins=8,
2 7 draw only pins={1, 3, 5-8}](C){IC1};
IC1 \draw (C.pin 1) -- ++(-0.5,0) to[R]
3 6
++(0,-1.5) node[ground]{};
4 5 \foreach \x in {1,...,8} {
\draw[red] (C.pin \x) circle[radius=2pt];
\draw[blue] (C.bpin \x) circle[radius=1pt];
12 11 10
}
1 9 \draw (0, 0) node[qfpchip, draw only pins={1-2, 6, 8, 4},
external pad fraction=4, num pins=12](Q){};
2 8
\foreach \x in {1,...,12} {
3 7 \draw[red] (Q.pin \x) circle[radius=2pt];
4 5 6
\draw[blue] (Q.bpin \x) circle[radius=1pt];
}
\end{circuitikz}
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 pin 1, pin 2 , …, with just one space between pin and the number. Border pin
anchors (bpin 1…) are always on the box border, and can be used to add numbers or whatever markings
are needed. Obviously, in case of 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 north) and with the short abbreviations n, nw, w…. The dot anchor is
useful to add a personalized marker if you use the no topmark key.
nw north ne n
dot
pin 1 pin 8
1 8 1 8 1 8
bpin 1 bpin 8
pin 2 pin 7
2 7 2 7 2 7
west center east w center e
bpin 2 bpin 7
pin 3 IC1 pin 6 IC2
3 6 3 text 6 3 6
bpin 3 bpin 6
pin 4 pin 5
4 5 4 5 4 5
sw south se s
bpin 4 bpin 5
You can rotate chips, and normally the pin numbers are kept straight (option straight numbers, which
is the default), but you can rotate them if you like with rotated numbers. Notice that the main label has
to be (counter-) rotated manually in this case.
43 Added by Jonathan P. Spratte in v1.3.8
156
\begin{circuitikz}
\draw (0,0) node[dipchip,
8 7 6 5
rotate=90]{%
6
\rotatebox{-90}{IC2}};
5
IC2
3
IC
\draw (3,0) node[qfpchip,
4
rotated numbers,
3
1 2 3 4
rotate=45]{IC3};
\end{circuitikz}
The seven segment display lets you show values as if they were displayed in a classical seven segment
display.44
The main “bare” component is the one shown above, but for simplicity a couple of style interfaces are
defined:
\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}
44 This component has been loosely inspired by the package SevenSeg by Germain Gondor, 2009, see
TEXexample.net.
157
There are two main configuration methods. The first one is seven segment val, which will take an
hexadecimal number or value and display it: the possible values are 0,...,15, plus A, B, C, D, E, F
(or lowercase) and the symbol - (minus).
The other interface is 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 dot specifies if you want a decimal dot or not. The key none will remove the dot and the space
it would take; empty will not show the dot at all but reserve the space, and on or off will show the dot
in the corresponding state.
The option box (can be on or off) simply toggles the drawing of the external box. You can separate it
from the display with the key seven seg/box sep (default 1pt), and it will use the thickness specified in
multipoles/thickness (The same as the chips).
You can use these option with the “bare” object bare7seg and the keys seven seg/bits (default 0000000),
seven seg/dot (default none) and seven seg/box (default off); there is no option equivalent to the val
interface.
These are the anchors for the seven segment displays; notice that when the dot parameter is not none,
the cell is a bit wider at the right side.
north north
north west north east north east a
f b
You can scale the seven segment display with the key 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:
\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"
158
\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}
159
5 Labels, voltages and currents
\begin{circuitikz}
R1
\draw (0,0) to[R, l=$R_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
R1
\draw (0,0) to[R=$R_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, v=$v_1$] (2,0);
v1 \end{circuitikz}
R1 \begin{circuitikz}
i1
\draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
v1 \end{circuitikz}
R1 \begin{circuitikz}
i1
\draw (0,0) to[R=$R_1$, i=$i_1$, v=$v_1$] (2,0);
v1 \end{circuitikz}
\begin{circuitikz}\draw
1 kΩ
(0,0) to[resistor=1<\kilo\ohm>] (2,0)
;\end{circuitikz}
When drawing a component left-to-right, the label l is by default above the component, and the annotation
a is by default below it. The position of annotations and labels can be adjusted adding the characters _
or ^ to the key.
R1 \begin{circuitikz}
\draw (0,0) to[R, l=$R_1$,a=1<\kilo\ohm>] (2,0);
1 kΩ \end{circuitikz}
1 kΩ \begin{circuitikz}
\draw (0,0) to[R, l_=$R_1$,a^=1<\kilo\ohm>] (2,0);
R1 \end{circuitikz}
160
For passive components, you can use type=text as a shortcut for type, l=text:
R1 \begin{circuitikz}
\draw (0,0) to[R=$R_1$,a=1<\kilo\ohm>] (2,0);
1 kΩ \end{circuitikz}
Notice though that in active component (sources of either voltage or current) the shortcut will set the
voltage (v) or current (i) property.
5.1.1.1 Adjust label and annotation position. Normally the package will guess a good position
for the label or annotation; if you do not like it, you can add45 (or remove, with negative values) distance
using the \ctikzset keys label distance and annotation distance.
\begin{circuitikz}
R R
\draw (0,0) to[sR, l=$R$, label distance=-4pt] (2,0)
to [sR, l=$R$] (4,0);
\end{circuitikz}
\begin{circuitikz}[american]
\ctikzset{bipoles/inductors/core distance=4pt}
L
\draw (0,1) to[L=$L$, name=myL] ++(2,0);
\draw[thick, double] (myL.core west) -- (myL.core east);
L \draw (0,0) to[L=$L$, name=myL, label distance=2pt] ++(2,0);
\draw[thick, double] (myL.core west) -- (myL.core east);
\end{circuitikz}
When TikZ processes the options, there will be problems if the label (or annotation, voltage, or current)
contains one of the characters = (equal) or , (comma) — because the parser search for those two characters
to delimit the arguments, giving unexpected errors and wrong output. These two characters can be
protected from the option parser using an extra set of braces.
R=3 \begin{circuitikz}
% the following will fail:
% \draw (0,0) to[R, l=$R=3$]
\draw (0,0) to[R, l={$R=3$}] (3,0);
\draw (0,0) to[R={$R=3$}] (0,3);
R=3 R, 3
\draw (3,3) to[R={$R,3$}] (3,0);
% this works, but it has wrong spacing
R=3 \draw (0,3) to[R, l=$R{=}3$] (3,3);
\end{circuitikz}
Caveat: up to version 1.2.7, due to the way in which CircuiTikZ used to processes the options, even
that was not sufficient, so you must protect that tokens even more, for example using an \mbox command,
or redefining the characters with a TEX \def:
45 Since version 1.3.3
161
R=3 \begin{circuitikz}
\def\eq{=}
% the following will fail up to 1.2.7:
% \draw (0,0) to[R, l={$R=3$}] (3,0);
\draw (0,0) to[R, l=\mbox{$R=3$}] (3,0);
R=3 R, 3 \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
R=3 \draw (0,3) to[R, l=$R{=}3$] (3,3);
\end{circuitikz}
The default orientation of labels is controlled by the options smartlabels, rotatelabels and straightlabels
(or the corresponding label/align keys). Here are examples to see the differences:
90 45 \begin{circuitikz}
\ctikzset{label/align = straight}
135 0 \def\DIR{0,45,90,135,180,-90,-45,-135}
\foreach \i in \DIR {
180 -45 \draw (0,0) to[R=\i, *-o] (\i:2.5);
}
-135 -90 \end{circuitikz}
90
\begin{circuitikz}
45
\ctikzset{label/align = rotate}
13
0 \def\DIR{0,45,90,135,180,-90,-45,-135}
5
\foreach \i in \DIR {
180 \draw (0,0) to[R=\i, *-o] (\i:2.5);
-4
}
5
\end{circuitikz}
-90
35
-1
162
90 \begin{circuitikz}
45
\ctikzset{label/align = smart}
13
0 \def\DIR{0,45,90,135,180,-90,-45,-135}
5
\foreach \i in \DIR {
180 \draw (0,0) to[R=\i, *-o] (\i:2.5);
-4
}
5
\end{circuitikz}
35
-90
-1
When using circuitikz in LaTeX, you can use stacked (two lines) labels. The example should be self-
explanatory: the two lines are specified as l2=line1 and line2. You can use the keys l2 halign to control
horizontal position (left, center, right) and l2 valign to control the vertical one (bottom, center, top).
The default values for alignement are thought for vertical components (where the stacke labels are more
natural), in other positions you have to force them.
Notice that you can’t use the compact <...> notation for siunitx with stacked labels. Before v1.3.6
the label was ignored, but that has been converted into an error.
Since v1.3.6 you have the same possibility with the annotation (just use a2=..., a2_=..., a2 valign
and so on. Notice that the default position for stacked annotation is v2 halign=l.
The l2 and a2 will only work in LaTeX because they use a tabular environment in their implementation.
For plain TeX and ConTeXt you have to use l and a and build the stack of labels externally.
RCC RCC
RCC 4.7 kΩ 4.7 kΩ RCC
4.7 kΩ 4.7 kΩ
C=D A=B
Y X
RCC RCC
RCC
4.7 kΩ 4.7 kΩ RCC
4.7 kΩ
4.7 kΩ
\begin{circuitikz}[american]
%
% default for l2 is: l2 halign=l, l2 valign=c. DO NOT USE the <...> notation
%
\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);
\draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=b] ++(2,0);
\draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, ] ++(0,2);
\draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, , l2 valign=t] ++(-2,0);
\draw (5,0) to[R, l2^=$R_{CC}$ and \SI{4.7}{k\ohm}, l2 halign=c, l2 valign=t] ++(0,-2);
\draw (10,2) to[R, l2={A=B} and X, a2={C=D} and Y] ++(0,-4);
\end{circuitikz}
For extra options about labels and annotations, please refer to section 5.6
163
5.2 Currents and voltages
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 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:
• oldvoltagedirection, or the key style 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);
• nooldvoltagedirection, or the key style voltage dir=noold: The standard from version 0.5 on-
ward, utilize the (German?) standard of voltage arrows in the direction of electric fields (without
fixing batteries);
• RPvoltages (meaning Rising Potential voltages), or the key style voltage dir=RP: the arrow is in
direction of rising potential, like in oldvoltagedirection, but batteries and current sources are
fixed so that they follow the passive/active standard: the default direction of v and i are chosen so
that, when both values are positive:
– in passive component, the element is dissipating power;
– in active components (generators), the element is generating power.
• EFvoltages (meaning Electric Field voltages), or the key style voltage dir=EF: the arrow is in
direction of the electric field, like in nooldvoltagedirection, but batteries are fixed;
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 \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 noold and
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:
\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
}
164
voltage dir voltage dir voltage dir voltage dir
dir=old dir=noold dir=RP dir=EF
R
american i1 i1 i1 i1
+ − + − + − + −
v1 v1 v1 v1
R i1 i1 i1 i1
european
v1 v1 v1 v1
v1 v1 v1 v1
v1 v1 v1 v1
battery2 v1 v1 v1 v1
european
i1 i1 i1 i1
+
−
−
+
+
−
V v1 v1 v1 v1
european
i1 i1 i1 i1
165
voltage dir voltage dir voltage dir voltage dir
dir=old dir=noold dir=RP dir=EF
I i1 i1 i1 i1
american + − − + − + − +
v1 v1 v1 v1
I i1 i1 i1 i1
european
v1 v1 v1 v1
sV v1 v1 v1 v1
european
i1 i1 i1 i1
+
−
−
+
+
−
cV v1 v1 v1 v1
european
i1 i1 i1 i1
v1 v1 v1 v1
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 i_>, i^<, i>_, i>^, as shown in the following
examples.
This manual has been typeset with the option RPvoltages.
166
5.2.1 Common properties of voltages and currents
Currents, voltages and flows (see later) are positioned along, or across, the part of the wires that connect
the inner component to the rest of the circuit. So, changing the length of the connection (the coordinates
that embrace the to[...] command) will change the position of the components.
f
i \begin{circuitikz}
\draw (-1,1) to[R, v=$v$, i=$i$, f>^=$f$] (1,1);
f v
i \draw (-2,0) to[R, v=$v$, i=$i$, f>^=$f$] (2,0);
\end{circuitikz}
v
However, you can override the properties voltage/distance from node (default 0.5: how distant from
the initial and final points of the path the arrow starts and ends or the plus and minus symbols are
drawn) and voltage/bump b (how high the bump of the arrow is — how curved it is, default 1.5), and
also voltage/european label distance (how distant from the normal position the voltage label will be,
default 1.4) on a per-component basis, in order to fine-tune the voltages:
You can also use a global ctikzset on the key voltage/distance from node (and similar) that will act
as a default value. Notice however that the specific component value overrides the global one, and
several components have pre-defined overrides, so they will ignore the default value. The components that
have out of the box predefined overrides for distance from node are generic, ageneric, fullgeneric
and memristor (set to 0.4), and the ones that have it for bump b are generic, ageneric, fullgeneric,
memristor, tline, varistor, photoresistor, thermistor, thermistorntc, thermistorptc, ccapacitor,
emptyzzdiode, fullzzdiode, emptythyristor, fullthyristor, emptytriac and fulltriac„ with several
values (you can look at them in the file pgfcirc.defines.tex)
Notice also that normally distance from node is a relative displacement, computed on the node-component
wire. So that this will put the start and stop point 1/4 of the way between node and component:
\begin{circuitikz}
v1 \ctikzset{voltage/distance from node=0.25}
\draw (0, 2) to[D, v=$v_1$] ++(4,0);
\draw (0, 1) to[D, v=$v_1$] ++(3,0);
v1 \draw (0, 0) to[D, v=$v_1$] ++(2,0);
\end{circuitikz}
v1
The value of distance from node can be also an absolute distance; in that case is measured from the
start of the connection toward the component on the left (and symmetrically on the right), so this will
put the start and end point to 0.25 cm from the start of the node:
167
\begin{circuitikz}
v1 \ctikzset{voltage/distance from node=0.25cm}
\draw (0, 2) to[D, v=$v_1$] ++(4,0);
\draw (0, 1) to[D, v=$v_1$] ++(3,0);
v1 \draw (0, 0) to[D, v=$v_1$] ++(2,0);
\end{circuitikz}
v1
There is currently no way to specify the position at a fixed distance from the component (as opposed as
from the node).
The same concept as distance from node applies to the key current/distance for the position of the
current’s arrow (and to flow/distance for the flow arrow position):
ı
\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);
If you want to change those parameters by defining a component-specific key you have to use the internal
name of the component (in the component list, is the nodename without the terminal “shape” part):
Note the .initial; you have to create such key the first time you use it. These kind of adjustments are
not guaranteed to work in future upgrades, though; if you have to create a key you are somehow touching
the internal structure of the package; it’s much safer to create a style.
One common request is to change the style of the arrows (both head and line) of these elements. Voltages,
currents and flows are part of the same path of the component, so this is not possible in simple way; you
have to drawn your own with TikZ commands using the facilities explained in section 5.8.
5.3 Currents
Inline (along the wire) currents are selected with i_>, i^<, i>_, i>^, and various combination; the default
position and direction is obtained with the simple key i=....
Basically, ^ and _ control if the label is above or below the line (above and below do depend on the
direction of the component path), and < and > the direction of the arrow; swapping them (from for
example from i^> to i>^) will switch the side of the component where the symbol is drawn. See the
following examples:
\begin{circuitikz}
i1 \draw (0,0) to[R, i^>=$i_1$] (2,0);
\end{circuitikz}
168
\begin{circuitikz}
i1 \draw (0,0) to[R, i_>=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i^<=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i_<=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i>^=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i>_=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i<^=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (0,0) to[R, i<_=$i_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}
i1 \draw (2,1) to[R, i<=$i_1$] (0,1);
i1 \draw (0,0) to[R, i<=$i_1$] (2,0);
\end{circuitikz}
Default directions can change if the component is active or passive,46 following the chosen global voltage
direction strategy (see section 5.2).
10V \begin{circuitikz}
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
i1 \end{circuitikz}
10V \begin{circuitikz}[american]
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
−
+
i1 \end{circuitikz}
46 This, in hindsight, has been a bad feature — and I’m partly responsible for it. But removing it would create
169
10V \begin{circuitikz}[american]
\draw (0,0) to[V=10V,invert, i_=$i_1$] (2,0);
+
−
i1 \end{circuitikz}
Current generators with the direct label (the one obtained by, for example, I = something) will treat it
as a current:
\begin{circuitikz}
a1
\draw (0,0) to[I=$a_1$] (2,0);
\end{circuitikz}
If you use the option americancurrent or using the style [american currents] you can changhe the style
of current generators.
\begin{circuitikz}[american currents]
a1
\draw (0,0) to[I=$a_1$] (2,0);
\end{circuitikz}
5.4 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.
i1 \begin{circuitikz}
\draw (0,0) to[R, f=$i_1$] (3,0);
\end{circuitikz}
i1 \begin{circuitikz}
\draw (0,0) to[R, f<=$i_1$] (3,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, f_=$i_1$] (3,0);
i1 \end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, f_>=$i_1$] (3,0);
i1 \end{circuitikz}
i1 \begin{circuitikz}
\draw (0,0) to[R, f<^=$i_1$] (3,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, f<_=$i_1$] (3,0);
i1 \end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, f>_=$i_1$] (3,0);
i1 \end{circuitikz}
170
5.5 Voltages
See the introduction at Currents and Voltages (section 5.2, page 164) for the default direction of the
voltage and currents.
Voltages come in four different styles: European (with curved or straight arrows) and American (with
signs that can stay near the wire or raised at the label level).
Direction and position of the symbols are controlled in the same way as for the currents (see section 5.3)
with the _^<> symbols.
The default, with curved arrows. Use option europeanvoltage or style [european voltages], or setting
(even locally) voltage=european.
v1 \begin{circuitikz}[european voltages]
\draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
v1 \begin{circuitikz}[european voltages]
\draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v_>=$v_1$] (2,0);
v1 \end{circuitikz}
\begin{circuitikz}[european voltages]
\draw (0,0) to[R, v_<=$v_1$] (2,0);
v1 \end{circuitikz}
The default direction for active elements can change, depending on the global voltage dir setting, so be
careful.
1A \begin{circuitikz}
\draw (0,0) to[I=1A, v_=$u_1$] (2,0);
\end{circuitikz}
u1
1A \begin{circuitikz}
\draw (0,0) to[I<=1A, v_=$u_1$] (2,0);
\end{circuitikz}
u1
1A
\begin{circuitikz}
\draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0);
\end{circuitikz}
u1
171
1A
\begin{circuitikz}
\draw (0,0) to[I,l=1A, v_=$u_1$] (2,0);
\end{circuitikz}
u1
Moreover, for historical reasons, voltage generators have differently looking arrows (they are straight even
in curved European style).
u1
\begin{circuitikz}
i1
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
1V
10V \begin{circuitikz}
\draw (0,0) to[V=10V, i_=$i_1$] (2,0);
i1 \end{circuitikz}
You can change this last thing by forcing “off” the status of “voltage generator” of the component; but
now the normal (passive) rule will apply, so, again, be careful.
\begin{circuitikz}
\draw (0,0) to[battery, bipole/is voltage=false,
v>=$u_1$,] (2,0);
u1 \end{circuitikz}
As for the currents, the direct label of voltage sources is passed as a voltage:
k · a1
\begin{circuitikz}
\draw (0,0) to[cV=$k\cdot a_1$] (2,0);
\end{circuitikz}
The following results from using the option americanvoltage or the style [american voltages].
a1 \begin{circuitikz}[american voltages]
\draw (0,0) to[V=$a_1$] (2,0);
−
+
\end{circuitikz}
Using straight arrows. Use option straightvoltages or style [straight voltages], or setting (even
locally) voltage=straight.
v1 \begin{circuitikz}[straight voltages]
\draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
v1 \begin{circuitikz}[straight voltages]
\draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
172
\begin{circuitikz}[straight voltages]
\draw (0,0) to[R, v_>=$v_1$] (2,0);
v1 \end{circuitikz}
\begin{circuitikz}[straight voltages]
\draw (0,0) to[R, v_<=$v_1$] (2,0);
v1 \end{circuitikz}
\begin{circuitikz}[straight voltages]
i1 \draw (0,0) to[I, v=10V, i_=$i_1$] (3,0);
10V \end{circuitikz}
And you can override that with bipole/is voltage keeping into account that the default direction will
be the one of passive components:
Use option americanvoltage or set [american voltages] or use the option voltage=american.
v1 \begin{circuitikz}[american voltages]
− + \draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
v1 \begin{circuitikz}[american voltages]
+ − \draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}[american voltages]
− + \draw (0,0) to[R, v_>=$v_1$] (2,0);
v1 \end{circuitikz}
\begin{circuitikz}[american voltages]
+ − \draw (0,0) to[R, v_<=$v_1$] (2,0);
v1 \end{circuitikz}
1A \begin{circuitikz}[american]
− + \draw (0,0) to[I=1A, v_=$u_1$] (2,0);
u1 \end{circuitikz}
1A \begin{circuitikz}[american]
− + \draw (0,0) to[I<=1A, v_=$i_1$] (2,0);
i1 \end{circuitikz}
173
5.5.4 Raised American style
Since version 1.2.1, “raised” American voltages are available; to use them, set the style [raised voltages]
or use the option voltage=raised. This is a version of the American-style voltage where the signs are
raised to the level of the label. The label is centered between the two signs, and the position of the signs
is calculated supposing that the label itself will be pretty simple; if you have very big labels you will
need to adjust the position with voltage shift and/or the voltage/distance from node properties (see
section 5.2.1).
− v1 + \begin{circuitikz}[raised voltages]
\draw (0,0) to[R, v^>=$v_1$] (2,0);
\end{circuitikz}
+ v1 − \begin{circuitikz}[raised voltages]
\draw (0,0) to[R, v^<=$v_1$] (2,0);
\end{circuitikz}
\begin{circuitikz}[raised voltages]
\draw (0,0) to[R, v_>=$v_1$] (2,0);
− v1 + \end{circuitikz}
\begin{circuitikz}[raised voltages]
\draw (0,0) to[R, v_<=$v_1$] (2,0);
+ v1 − \end{circuitikz}
1A \begin{circuitikz}[american]
\ctikzset{voltage=raised}
\draw (0,0) to[I=1A, v_=$u_1$] (2,0);
− u1 + \end{circuitikz}
1A \begin{circuitikz}[raised voltages]
\draw (0,0) to[I<=1A, v_=$i_1$] (2,0);
− i1 + \end{circuitikz}
It is possible to move the arrows and the plus or minus signs away form the component with the key
voltages shift (default value is 0, which gives the standard position):
i1
\begin{circuitikz}[]
v1 \draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0);
i1 \draw (0,-1) to[R, v=$v_1$, i=$i_1$,
voltage shift=0.5] (2,-1);
v1 \draw (0,-2) to[R, v=$v_1$, i=$i_1$,
i1
voltage shift=1.0] (2,-2);
\end{circuitikz}
v1
174
Negative values do work as expected:
+ v1 −
i1 \begin{circuitikz}[raised voltages]
\draw (0,1.5) to[R, v^=$v_1$, i=$i_1$] ++(2,0);
\draw (0,0) to[R, v^=$v_1$, i=$i_1$,
voltage shift=-1.0] ++(2,0);
+ v1 −
i1 \end{circuitikz}
You can fine-tune the position of the + and - symbols and the label in independent way using voltage/shift
(default 0.0 for the former and voltage/american label distance (the distance of the label form the
lines of the symbols, default 1.4) for the latter.
\begin{circuitikz}[american voltages]
i1 \draw (0,1) to[R, v=$v_1$, i=$i_1$] ++(2,0);
+ − % normally 1.4, make it tighter
v1
i1 \ctikzset{voltage/american label distance=0.5}
+ − \draw (0,0) to[R, v=$v_1$, i=$i_1$] ++(2,0);
v1
\end{circuitikz}
u1
\begin{circuitikz}[voltage shift=0.5]
i1
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
1V
u1
− +
\begin{circuitikz}[american voltages, voltage shift=0.5]
i1
\draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0);
\end{circuitikz}
1V
Additionally, the open component is treated differently; the voltage is placed in the middle of the open
space47 :
\begin{circuitikz}[american voltages]
+ vo − \draw (0,1.5) -- ++(0.5,0)
to[open, v=$v_o$, o-o] ++(2,0) -- ++(0.5,0);
\draw (0,0) -- ++(0.5,0)
to[open, v=$v_o$, voltage=straight, *-*] ++(2,0)
vo -- ++(0.5,0);
\end{circuitikz}
If you want or need to maintain the old behavior for open voltage, you can set the key open voltage
position to legacy (the default is the new behavior, which correspond to the value center).
47 Since v1.1.2, thank to an issue opened by user rhandley on GitHub.
175
5.5.6 American voltages customization
Since 0.9.0, you can change the font48 used by the american voltages style, by setting to something
different from nothing the key voltage/american font (default: nothing, using the current font) style:
+ − \begin{circuitikz}[american]
VS \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);
+ −
VS \end{circuitikz}
Also, if you want to change the symbols (sometime just the + sign is drawn, for example, or for highlighting
something), using the keys voltage/american plus and voltage/american minus (default $+$ and $-$).
⊖ ⊕ \begin{circuitikz}[american]
VS \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);
⊕ ⊖
VS \end{circuitikz}
This could be especially useful if you define a style, to use like this:
− + \tikzset{red plus/.style={
VS 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);
+ −
VS \end{circuitikz}
5.6 Changing the style of labels, voltages, and other text ornaments
Since version 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
/tikz/circuitikz key directory and applied to every node that contains the text; you can also change
them locally by using the tikz direct keys in local scopes.
For example, you can make all annotations small by using:
\ctikzset{bipole annotation style/.style={font=\small}}
where the annotation will be in normal font (it has been reset!) and red, or append to the style:
...to[bipole annotation append style={color=red}, R, a={Red small note}]...
48 There was a bug before, noticed by the user dzereb on tex.stackexchange.com which made the symbols using
different fonts in a basically random way. In the same page, user campa found the problem. Thanks!
176
Caveat: you have to put the style changing key at the start of the to arguments to have any effect49 .
The available styles and commands are bipole label style, bipole annotation style, bipole voltage
style, bipole current style, and bipole flow style. The following example shows a bit of everything.
F1
L1 A2 R1 F2
I1 I2
A1
+ − + −
L2 V1 V2
2L
\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}
R1flow R2flow
L1label L2annotation R1current R2current
L1 L1
A2 L2 F1 R1 F2
I1 I2
+ − + −
A1 L1annotation L2 V1 R1voltage V2 R2voltage
L2label
2L
\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}
49 No, I do not know why. Hints and fixes are welcome.
50 The access to labels and annotations was present before, but not documented.
177
If you want to have more access to the label positioning algorithm, since 1.2.5 you can access the
label rotation using the command \ctikzgetdirection{nodename} (where node name is for example
L1label or L2annotation), and the anchor used for positioning the node as \ctikzgetanchor{component
label}{type}, where component label is, for example, L1 and type is either label or annotation (notice
that the syntax is slightly different, for implementation reasons). Those values are available only if the
dipole declares a l or a keys; if you want them without any label you need to declare a blank one (like
for example l=~). The following example gives an idea of the values of those macro for the three types of
label positioning strategies.
L1 L1
L1 V1 V1 V1
dir: 45 dir: 45
dir: 0 dir: 0 dir: 0 dir: 270
anchor: mid anchor: mid
anchor: -45 anchor: mid east anchor: mid east anchor: mid
Lab
L1 L1
ab
ab
L
L
A A
L2
L1
A
a L2 L2
a
ht
L1 V1 V1 V1
ig
e
t
t
dir: 0
ar
ra
ta
anchor: mid west dir: 45 anchor: mid west dir: 45 anchor: mid
sm
anchor: 135
st
ro
anchor: mid anchor: mid
\begin{circuitikz}[]
\draw (0,1) to[R, v=$v$] ++(3,0);
\draw (0,0) to[R, v, name=R, voltage/bump b=3] ++(3,0);
v
\draw [thin, red, -{Stealth[width=8pt]}, ]
(R-Vfrom) .. controls (R-Vcont1) and (R-Vcont2).. (R-Vto)
v node [black, pos=0.5, fill=white]{v};
\end{circuitikz}
Or, for example, to have a different voltage style; normally you would define a macro:
51 some options have been added in v1.4.1
52 in regular voltages, the arrows are not real TikZ arrows, but the auxiliary arrow shapes of CircuiTikZ
178
\begin{circuitikz}[voltage shift=0.5]
R1 \def\eurVPM#1#2{% node, label
i
+ −
\draw [thin, -{Stealth[width=8pt]}, shorten >=5pt,
+ shorten <=5pt] (#1-Vfrom) node[font=\tiny]{$-$}
v1
.. controls (#1-Vcont1) and (#1-Vcont2)..
(#1-Vto) node[font=\tiny]{$+$}
R2 v2 node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};}
\draw (0,0) to[R=R1, name=R1, v, i=$i$] ++(3,0)
−
to[R, l_=R2, v^, name=R2] ++(0,-3);
\eurVPM{R1}{$v_1$} \eurVPM{R2}{$v_2$}
\end{circuitikz}
Since v1.4.1 you can also keep the voltage, current and flow labels and suppress the output of the symbols
(arrows or plus/minus depending on the style) with the keys no v symbols, no i symbols, no f symbols
(there are also the corresponding v symbols, i symbols and f symbols in case you want to switch the
behavior off/on globally). This for example simplify an often requested feature, like having all the current
in one color and the voltages in another one, which is not possible natively because the arrows are part of
the same path One possible implementation is the following one:
\newcommand{\iarronly}[1]{% name
\node [currarrow, color=red, anchor=center,
rotate=\ctikzgetdirection{#1-Iarrow}] at (#1-Ipos) {};
vR }
\newcommand{\varronly}[1]{% name
\draw [color=blue] (#1-Vfrom) .. controls (#1-Vcont1)
and (#1-Vcont2).. (#1-Vto) node [currarrow,
sloped, anchor=tip, allow upside down,pos=1]{};
}
\begin{circuitikz}[]
\ctikzset{!vi/.style={no v symbols, no i symbols}}
iR \ctikzset{bipole voltage style/.style={color=blue},
bipole current style/.style={color=red}}
\draw (120:6) to[R, *-, name=R, v^=$v_R$, !vi]
L
(120:3) to[short, i=$i_R$, name=SR, !vi] (0,0);
\draw (180:4) to[L, o-, l=$L$, name=L2, v=$v_L$, !vi]
vL (180:2) to[V, -*, name=V2, v_=$v_2$, !vi] (0:0);
v2
\iarronly{SR}\varronly{R}\varronly{L2}\varronly{V2}
\end{circuitikz}
You will have access to the anchors for voltages, currents and flows when, in the bipole, you have both a v,
i, f specification (one or more of them) and a name key, to give the bipole a name. Otherwise, the anchors
and the associated functions are not defined. To suppress the normal output of the v, i, f keys, you can
use such keys without any argument, like in the previous example; notice that the _ and ^ modifiers work
as expected.
The following line of resistors has been drawn with the following commands; it is used to show the name
of the available anchors.
\draw (0,0) to[R=R1, v=$v$, name=R1] ++(4,0)
to[R, l_=R2, i=$i$, name=R2] ++(4,0)
to[R=R3, f=$f$, name=R3] ++(4,0);
R3-Ffrom R3-Fto
R1 R2-Ifrom R2-Ito R3 f
i
179
The meaning of the anchors is the following:
• Vfrom and Vto are the main points where the voltage information is given: start and end point of
the arrow, or position of the + or − sign. This is the same for the Ffrom or Fto anchors for flows;
for inline currents, the corresponding Ifrom and Ito mark the wire segment where the arrowhead
is positioned (at the specified current/distance fraction. The direction of the arrow is available
using the auxiliary macro \ctikzgetdirection (see below).
• Vcont1 and Vcont2 are the control points for the curved arrow (see the examples above); in the case
of straight arrows or american-style voltages, they are set at the midpoint between Vfrom and Vto.
• Vlab is where the text label for the voltage is normally positioned. The anchor used for such label
is available using the auxiliary macro \ctikzgetanchor (see below)
• Ipos and Fpos are the position for the arrowhead or the small flow arrow (which is a currarrow
or flowarrow node normally) is positioned, respectively. The label is then added to the correct
side of it using the anchor available via \ctikzgetanchor (see below, 5.8.2). In this case, the exact
position of the label is not available if you do not position the element, for this there is no Flab or
Ilab coordinate; you have to use the Fpos and Ipos coordinate with the corresponding Ilab and
Flab anchors.
Changing the options of the elements, will change the anchors acoordingly:
\ctikzset{current/distance=0.2}
\draw (0,0) to[R=R1, v>=$v$, name=R1] ++(4,0)
to[R, l_=R2, i<_=$i$, name=R2] ++(4,0)
to[R, l_=R3, f<_=$f$, name=R3] ++(4,0);
R2-Ipos
R1 R2-Ito R2-Ifrom R3-Fto R3-Ffrom
i
R1-Vfrom v R1-Vto R2 f R3
R1-Vcont1 R1-Vcont2
R3-Fpos
R1-Vlab
Obviously, the anchors follow the voltage style you choose:
\draw (0,0) to[R=R1, v=$v$, name=R1, voltage=straight] ++(4,0)
to[R=R2, v=$v$, name=R2, voltage=american] ++(4,0)
to[R=R3, v=$v$, name=R3, voltage=raised] ++(4,0);
R2-Vcont1 R2-Vcont2
R1-Vcont1 R1 R1-Vcont2 R2 R3
R3-Vcont1 R3-Vcont2
+ −
v v + v −
R2-Vto R2-Vfrom
R1-Vto R1-Vfrom
R1-Vlab R2-Vlab R3-Vto R3-Vfrom
R3-Vlab
Notice the postion of the control points, as well as the fact that the anchor available with \ctikzgetanchor
is applied to Vfrom and Vto symbols, too.
Finally, as ever, generators are treated differently, but you have all your anchors too.
\ctikzset{american}
\draw (0,0) to[V=$v$, name=G1, voltage=european] ++(4,0)
to[V=$v$, v=$v$, name=G2, voltage=american] ++(4,0)
to[battery2, v=$v$, name=G3, voltage=raised] ++(4,0);
−
+
180
5.8.2 Auxiliary information
When the anchors are activated, there are additional macros that you can use:
• \ctikzgetanchor{<name>}{<anchor>}: name is the name of the bipole, and anchor can be Vlab,
Fpos or Ipos. This macro expands to the normal anchor position (something like north, south
west). Notice that if you have not activated the corresponding anchor, the content of this macro is
not specified. It could be equivalent to \relax (basically, empty) or contains the anchor of a bipole
with the same name from another drawing — it’s a global macro like the coordinates.
• \ctikzgetdirection{<name>}: a number which is the direction of the named bipole.
• \ctikzgetdirection{<name>-Iarrow}: a number which is the direction of the current arrow re-
quested for the named bipole; using <name>-Farrow you get the same information for flow arrows.
For example, you could like the voltage label oriented with the bipole:
\begin{circuitikz}[]
\def\myvv#1#2{%
\draw [thin, blue, ->,]
(#1-Vfrom) .. controls (#1-Vcont1) and (#1-Vcont2).. (#1-Vto)
node [pos=0.5, below,
vB
Or you could use the anchor to substitute the flow with a fancy one and still position automatically the
label; suppose you have the following definition in your preamble (see TikZ manual, “Path decorations”):
% requires \usetikzlibrary{decorations, decorations.pathmorphing}
\tikzset{%
lray/.style={decorate, decoration={
snake, amplitude=2pt,pre length=1pt,post length=2pt, segment length=5pt,},
-Triangle,
}}
\begin{circuitikz}[]
PA \newcommand\myff[3][blue]{% [opt: color] node label
\draw [lray, #1, ] (#2-Ffrom) -- (#2-Fto)
node [anchor=\ctikzgetanchor{#2}{Flab}, inner sep=4pt]
at (#2-Fpos) {#3};}
\draw (0,1) to[R, f, name=A] ++(3,0);
\draw (0,0) to[R, f_<, name=B] ++(3,0);
PB \myff{A}{$P_A$}\myff[red]{B}{$P_B$}
\end{circuitikz}
An interesting application of the advanced voltage is to have fixed length straight voltage arrows.53 The
normal voltage arrows length depends not on the component length but on the node distance (this is the
behavior since when the voltages were first introduced, so it can’t be changed).
53 This was suggested by users Franklin and Zarko in a question on tex.stackexchange.com
181
v1 v2
v3
\begin{circuitikz}[european,]
\ctikzset{voltage=straight}
\draw (0,0) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
\end{circuitikz}
Using the advanced voltage interface mechanism, you can for example design voltages that are of fixed
lengths; in the example below the new xparse method for defining commands is used, so that we can have
a couple of different optional arguments:
\NewDocumentCommand{\fixedvlen}{O{0.5cm} m m O{}}{% [semilength]{node}{label}[extra options]
% get the center of the standard arrow
\coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
% draw an arrow of a fixed size around that center and on the same line
\draw[-Triangle, #4] ($(#2-Vcenter)!#1!(#2-Vfrom)$) -- ($(#2-Vcenter)!#1!(#2-Vto)$);
% position the label as in the normal voltages
\node[anchor=\ctikzgetanchor{#2}{Vlab}, #4] at (#2-Vlab) {#3};
}
v1 v2
v3
V1 V2
V3
\begin{circuitikz}[european,]
\ctikzset{voltage=straight}
\draw (0,2) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
\draw (0,0) to[R,v=,name=v1,*-*] ++(2,0) to[R, v<=, name=v2] ++(4,0) to[C, *-*, v, name=v3] ++(1,0);
\fixedvlen{v1}{$V_1$}
\fixedvlen{v2}{$V_2$}
\fixedvlen{v3}{$V_3$}[red]
\end{circuitikz}
Notice that with a coherent naming you can use a \foreach loop for the last three lines.
You can also notice that the arrow is not exactly the same as other arrows in the circuit; if you want them
to be exactly the same, you can use a trick to get the default CircuiTikZ arrow size — please look at this
answer by Romano on tex.stackexchange.com.
Another possibility is to have the arrow length based on the length of the component; for example you
can use this code:
\NewDocumentCommand{\compvlen}{O{1.5} m m O{}}{% [relative length]{node}{label}[extra options]
% get the center of the standard arrow
\coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
% draw an arrow of a size proportional to the component length
% around that center and on the same line
% the component length is calculated using the let...in with the left and right anchors
% and multiplied by the relative length
\draw[-Triangle, #4] let \p1=(#2.left), \p2=(#2.right), \n1={0.5*#1*veclen(\x2-\x1,\y2-\y1)}
in ($(#2-Vcenter)!\n1!(#2-Vfrom)$) -- ($(#2-Vcenter)!\n1!(#2-Vto)$);
% position the label as in the normal voltages
\node[anchor=\ctikzgetanchor{#2}{Vlab}, #4] at (#2-Vlab) {#3};
}
182
v1 v2
v3
V1 V2
V3
\begin{circuitikz}[european,]
\ctikzset{voltage=straight}
\draw (0,2) to[R,v=$v_1$,*-*] ++(2,0) to[R, v<=$v_2$] ++(4,0) to[C, *-*, v=$v_3$] ++(1,0);
\draw (0,0) to[R,v=,name=v1,*-*] ++(2,0) to[R, v<=, name=v2] ++(4,0) to[C, *-*, v, name=v3] ++(1,0);
\compvlen{v1}{$V_1$}
\compvlen{v2}{$V_2$}
\compvlen{v3}{$V_3$}[red]
\end{circuitikz}
\begin{circuitikz}
1 kΩ
\draw (0,0) to[R, l=1<\kilo\ohm>] (2,0);
\end{circuitikz}
\begin{circuitikz}
1 kΩ
\draw (0,0) to[R, l=$\SI{1}{\kilo\ohm}$] (2,0);
\end{circuitikz}
\begin{circuitikz}
1 mA \draw (0,0) to[R, i=1<\milli\ampere>] (2,0);
\end{circuitikz}
\begin{circuitikz}
1 mA \draw (0,0) to[R, i=$\SI{1}{\milli\ampere}$] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, v=1<\volt>] (2,0);
1V \end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, v=$\SI{1}{\volt}$] (2,0);
1V \end{circuitikz}
54 This option is still experimental — personally (Romano) I would advise using the normal \SI{}{} syntax.
183
6 Using bipoles in circuits
osquarepole
squarepole \begin{circuitikz}
\ctikzset{bipoles/length=.5cm, nodes width=0.1}%small
odiamondpole
components, big nodes
\foreach \a/\p [evaluate=\a as \b using (\a+180)] in
diamondpole {-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)
ocirc
node[font=\tiny, anchor=\b]{\p};
none
circ \end{circuitikz}
These bipole nodes are added after the path is drawn, as every node in TikZ — 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 ocirc of the previous path.
\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}
You can define shortcuts for the 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{circuitikz}
\ctikzset{-s/.style = {bipole nodes={none}{osquarepole, fill=red}}}
\draw (0,0) to[R, -s] ++(2,0);
\end{circuitikz}
There are several predefined shorthand as the above; in the following pages you can see all of them.
\begin{circuitikz}
\draw (0,0) to[R, o-o] (2,0);
\end{circuitikz}
55 You can use other shapes too, but at your own risk…Moreover, notice that none is not really a node, just a
special word used to say “do not put any node here”.
184
\begin{circuitikz}
\draw (0,0) to[R, -o] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, o-] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, *-*] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, -*] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, *-] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, d-d] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, -d] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, d-] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, o-*] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, *-o] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, o-d] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, d-o] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, *-d] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R, d-*] (2,0);
\end{circuitikz}
185
6.1.1 Transparent poles
“Open-poles” terminals (ocirc, odiamondpole, and osquarepole) are normally filled with the background
color at full opacity. This is because, for simplicity of operation, the nodes are placed after the wires are
drawn and have to “white-out” the underlying lines.
Anyway, if you know what you are doing, you can change it with the key poles/open fill opacity (with
\ctikzset) or the style open poles opacity. Notice that you will have artifacts if you don’t use the
border anchors of the poles to connect wires, and you need to do that by hand.
Notice that in poles, the opacity is always selected with these keys, and it overrides the opacity of the
draw commands (when not set explicitly is as if it is set to 1.0, i.e., full opaque). This is because you
normally do not want unfilled poles!
You also have the similar keys for the “full” poles (albeit they are probably not useful at all).
\begin{circuitikz}
\draw (0,0) to[pD] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[pD, mirror] (2,0);
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[pD, invert] (2,0);
\end{circuitikz}
186
Placing labels, currents and voltages works also, please note, that mirroring and inverting does not influ-
ence the positioning of labels and voltages. Labels are by default above/right of the bipole and voltages
below/left, respectively.
T \begin{circuitikz}
i1
\draw (0,0) to[ospst=T, i=$i_1$, v=$v$] (2,0);
v \end{circuitikz}
T i1 \begin{circuitikz}
\draw (0,0) to[ospst=T, mirror, i=$i_1$, v=$v$] (2,0);
v \end{circuitikz}
T \begin{circuitikz}
i1
\draw (0,0) to[ospst=T, invert, i=$i_1$, v=$v$] (2,0);
v \end{circuitikz}
T i1 \begin{circuitikz}
\draw (0,0) to[ospst=T,mirror,invert, i=$i_1$, v=$v$] (2,0);
v \end{circuitikz}
\begin{circuitikz}
1 kΩ \draw (0,0) to[R=1<\kilo\ohm>,
i>_=1<\milli\ampere>, o-*] (3,0);
1 mA
\end{circuitikz}
1 mA \begin{circuitikz}
\draw (0,0) to[D*, v=$v_D$,
i=1<\milli\ampere>, o-*] (3,0);
vD \end{circuitikz}
\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}
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:
187
\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}
188
7 Colors
Color support in CircuiTikZ is quite limited. You will have no problem if:
1. You stick to use styles (see 3.3.2) for filling your components, or using a direct fill=... option
directly;
2. when coloring whole circuits, use the option color=... in your global picture options or in the
\draw command (not just the color name as a shorthand);
3. forget about transparency.
Nevertheless, if you really need to do strange things with colors you can read on; you can do almost
everything but there are several glitches to take into account.
\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}
and
\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}
189
\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}
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
to:
1Ω
\begin{circuitikz} \draw
(0,0) to[V=1<\volt>] (0,2)
{ to[R=1<\ohm>, color=red] (2,2) }
1V 1F to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
1Ω
\begin{circuitikz} \draw
(0,0){to[V=1<\volt>, color=red] (0,2) }
to[R=1<\ohm>] (2,2)
1V 1F to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
1Ω
\begin{circuitikz} \draw[color=red]
(0,0) to[V=1<\volt>, color=red] (0,2);
\draw (0,2) to[R=1<\ohm>] (2,2)
1V 1F to[C=1<\farad>] (2,0) -- (0,0)
;\end{circuitikz}
190
7.2 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{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}
This fill color will override any color defined by the style (see section 3.3.2). 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{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}
You can combine shape colors with fill colors, too, but you should use the draw color option style for this:
\begin{circuitikz} \draw[color=red]
1
(0,2) node[and port, fill=yellow] (myand1) {1}
(0,0) node[and port, fill=cyan] (myand2) {2}
3 (2,1) node[xnor port,fill=red!30!white] (myxnor) {3}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
2 ;\end{circuitikz}
This is because, as you can see from the following example in port 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 circuitTikZ
architecture). A workaround is shown in port 3:
\begin{circuitikz} \draw
1
(0,2) node[and port, color=black] (myand1) {1}
(0,0) node[and port, color=blue, fill=cyan] (myand2) {2}
3 (2,1) {[color=blue] node[xnor port, fill=cyan] (myxnor) {3}}
(myand1.out) -| (myxnor.in 1)
(myand2.out) -| (myxnor.in 2)
2 ;\end{circuitikz}
191
7.2.1 Background colors different from white
Notice also that the connection point are always filled, although the color tries to follow the color of the
filling of the component (but look at section 6.1.1). Moreover, if you want to pass fill transparency down
to path-style components, you have to put it into the options of the \draw command.
\begin{circuitikz}
\fill[cyan] (0,3.0) rectangle (7,7);
\draw [fill opacity=0.5] (1,6.5) to[generic, fill=white,o-o] ++(2,0);
\draw (1,5.5) to[short, fill=red, 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,4.5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0);
\draw (1,4) node[ocirc]{} -- ++(1,0) node[ocirc]{};
\draw [thick, color=green!50!black] (4,4) to [D,o-o,fill=yellow] ++(0,2) to[D*, fill
=yellow]
++(2,0) to[D*,fill=yellow] ++(0,-2) to[D, fill=red, o-o] ++(-2,0);
\end{circuitikz}
As you can see, the “black” components (as D*) follow the color of the line, not the fill.
Note however that if you choose a colored background, for example with the \pagecolor{} command or
with other tricks, the nodes will be by default still filled with white.
\begin{circuitikz}[european]
\fill[color=blue] (-1,-1) rectangle (4,1);
\draw[color=white] (0,0) to[R, o-o] ++(3,0);
\end{circuitikz}
You have two solutions for this. You can redefine the o-o (and the similar commands -o, o-, *-o and so
on) with a blue filled “open” pole:
\tikzset{bcirc/.style={shape=ocirc, fill=blue}}
\ctikzset{o-o/.style ={
\circuitikzbasekey/bipole/nodes/left=bcirc,
\circuitikzbasekey/bipole/nodes/right=bcirc}}
\begin{circuitikz}[european]
\fill[color=blue] (-1,-1) rectangle (4,1);
\draw[color=white] (0,0) to[R, o-o] ++(3,0);
\end{circuitikz}
Also, since v1.2.3, you can set the key open poles fill (default: white which works for ocirc, odiamondpole
and osquarepole):
192
\begin{circuitikz}[european]
\ctikzset{open poles fill=blue}
\fill[color=blue] (-1,-1) rectangle (4,1);
\draw[color=white] (0,0) to[R, o-o] ++(3,0);
\end{circuitikz}
193
8 FAQ: Frequently asked questions
Q: When I use a node to name a connection in the circuit, I have gaps in the wires! I am sure it used to
work!
A: This is explained in 1.9. The fast answer is that in a hurry, use the 1.1.2 fallback point with:
\usepackage{circuitikz-1.1.2}
in your preamble.
But really, your circuit definition is buggy, so the best thing to do is fix that; if you want to name a point
in you circuit, you should use a coordinate, not a node.56 Here is a small tutorial on why you should
change your circuit.
Nodes, in TikZ, have normally a non-zero size even when they are empty; moreover, connections are
supposed to join the border of nodes. Please study the following (pure TikZ, not CircuiTikZ):
\begin{tikzpicture}
\path (1,1) node (A){}; % empty node at (1,1)
\draw (1,0) -- (A) -- (2,1); % surprise!
\end{tikzpicture}
The gap is there because the node has a non-zero size (more in detail, its inner sep is by default different
from zero). You can see it easily if you draw the node shape:
\begin{tikzpicture}
\path (1,1) node [draw=red](A){};
\draw (1,0) -- (A) -- (2,1);
\end{tikzpicture}
The problem is that when you want to name a coordinate, in the sense of a dimensionless point, you
should use a coordinate, not a node!
\begin{tikzpicture}
\path (1,1) coordinate (A); % give a name to (1,1)
\draw (1,0) -- (A) -- (2,1);% now it's ok!
\end{tikzpicture}
Now, before version 1.2.1 (and since around 0.6), CircuiTikZ was detecting when a connection was
between nodes and sort-of added a node.center movement to the path. That in turn generated the need
of hacks to draw the correct joining of lines, because that kind of movement broke the continuity of the
path, like in this example:
\begin{tikzpicture}[line width=4pt]
\path (1,1) node (A){};
\draw (1,0) -- (A.center) (A) (A.center) -- (2,1);
\end{tikzpicture}
You can see more example and more reasoning on GitHub; start from the issue detecting the join problem,
then look at the merged fix; you can follow several issue and discussion from there, but for example there
are circuits that can’t be drawn with the “hack” in, like this one.
So finally it was decided57 to remove the change, to simplify the code and to make the package more
maintainable.
56 Yes, I understand from where the confusion arise — in circuit theory they are called nodes.
57 well, Romano decided, so you can blame him. I do not think that workarounds to correct malformed circuits
are really maintainable; just see the bunch of code removed by the patch! — Romano.
194
8.2 Using dashed (or colored) wires in circuits
Q: How can I make part of the wires dashed (or colored)? This does not work:
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
to[short, dashed, red] ++(1,0)
to [R] ++(2,0); % surprise!
\end{circuitikz}
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
[dashed, red] -- ++(1,0)
to [R] ++(2,0); % surprise!
\end{circuitikz}
A: This is an effect on how TikZ builds and draws path. As explained in the TikZ manual,58 most path
options are globally valid for the whole path; color and dash/dot is one of this. You have two options in
this case. The first one is to use two paths.
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0) coordinate(a);
\draw [dashed, red] (a) -- ++(1,0) coordinate(b);
\draw (b) to [R] ++(2,0);
\end{circuitikz}
The other one is to use edge operations59 ; be sure to read about it on the TikZ manual60 — but basically
this is similar to the to operation but it builds another path (added at the end of the current path, like
nodes are). This means that it can use different options, and that it does not moves the path coordinates.
So, for example:
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
edge[dashed, red] ++(1,0)
% we have to move the path position here!
++(1,0) to [R] ++(2,0);
\end{circuitikz}
The only problem with this approach is that the edges are added after the nodes, so it can create problems
with nodes (look carefully!):
\begin{circuitikz}
\draw (0,0) to[R,-o] ++(2,0)
edge[dashed, red] ++(1,0)
++(1,0) to [R] ++(2,0);
\end{circuitikz}
So it’s better, in this case, to add the nodes manually after the path (there is no perfect solution!):
58 in 3.1.5b, section 14, “syntax for path specification”
59 I took the idea form this answer by @LaTeXdraw-com user on TeX.SE, thanks!
60 in 3.1.5b, section 17.12, “connecting nodes: use the edge operation”
195
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0) coordinate(a)
edge[dashed, red] ++(1,0)
++(1,0) to [R] ++(2,0);
\node [ocirc] at (a){};
\end{circuitikz}
A more complex example can be seen (look at the comments!) in the following circuit.
\begin{circuitikz}[american]
\draw (0,0) to[R, v=$v_1$] ++(2,0)
edge[dashed] ++(1,0)
++(1,0) to[R]
++(2,0) to [R] ++(0,2) coordinate(a)
edge[red, dashed] ++(0,1)
here % several edges start from the same position
edge[dashed, ->] node[above]{here} ++(-1,0)
% notice that the path here is still
% at coordinate (a)!
++(0,1) to[R] ++(0,2)
(a) ++(-1,0) to[sV] ++(-2,0);
+ − \end{circuitikz}
v1
! Emergency stop.
\begin{circuitikz} \draw
node[ocirc] (A) at (0,0) {}
node[ocirc] (B) at (2,1) {}
v (A) to[open, v=$v$] (B)
;\end{circuitikz}
Q: I cannot write to[R = $R_1=12V$] nor to[ospst = open, 3s]: I get errors.
A: It is a limitation of the parser, joined with a suboptimal processing by CircuiTikZ (up to 1.2.7) of
the passing of the argument of keys.
You should protect commas and equal signs like in to[R = {$R_1=12V$}] or to[ospst = {open, 3s}].
In versions up to 1.2.7, use for example \mbox{} or define \def{\eq}{=} and use to[R = $R_1\eq 12V$],
or try to protect commas and equal signs like to[ospst = open{,} 3s] or ospst=\mbox{open, 3s} in-
stead; see caveat in section 5.1.
196
8.5 Global scaling and rotating
Q: I tried to change the direction of the y axis with yscale=-1, but the circuit is completely messed up.
A: Yes, it’s a known bug (or misfeature, or limitation). See section 1.7. Don’t do that.
Q: I tried to put a diode in a pic, but it’s coming out badly rotated.
A: Yes, it’s a known bug (or misfeature, or limitation, or a fact of life). See section 1.7. CircuiTikZ is not
compatible with pics at this point.
tfullgeneric
variable capacitor
\begin{circuitikz}[european]
\draw (1,0) node{new default} (4,0) node{old default} (7,0) node{new!};
\foreach [count=\i] \comp in
{variable american resistor, variable european resistor,
variable cute inductor, variable american inductor, tfullgeneric,
variable capacitor} {
\draw (0,-\i) node[left]{\texttt{\comp}} to[\comp, name=E] ++(2,0);
\ctikzset{bipoles/fix tunable direction=false}
\draw (3,-\i) to[\comp, name=E] ++(2,0);
\ctikzset{bipoles/fix tunable direction=true, tunable end arrow={Bar}}
\draw (6,-\i) to[\comp, name=E] ++(2,0);
}
\end{circuitikz}
197
9 Defining new components
Per me si va ne la città dolente,
per me si va ne l’etterno dolore,
per me si va tra la perduta gente.
…
Lasciate ogne speranza, voi ch’intrate.61
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.
% components
% paths
\makeatother
\begin{document}
\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}
This will compile to something like this (in this case, we are using a couple of existing components to
check everything is ok):
61 https://classicsincontext.wordpress.com/2010/02/28/canto-iii-per-me-si-va-ne-la-citta-dolente/
198
left right
damper: Mechanical damping, type: path-style, fillable,
nodename: dampershape. Class: mechanicals.
center
north
north west north east
right
left text
west east
center
south west south east
south
\begin{circuitikz}
\draw (0,0) to[R] ++(2,0)
to[damper] ++(2,0);
\end{circuitikz}
The command circuitdescbip* is used to show the component description (you can check the definition
and the usage looking at ctikzmanutils.sty file, and the \geolrcoord is used to show the main anchors
(geographical plus left and right) of the component.
From now on, you can add the new commands for the component between the \makeatletter and
\makeatother commands and, modifying the example, check the results.
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).
After that we will copy, for example, the definition of the damper into our code, just changing the name:
%% 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}}
199
\pgf@circ@maybefill
% 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}
This \pgfcircdeclarebipolescaled command will define a shape that is named viscoeshape, with all
the correct geographical anchors based on the depth, height and width defined in the parameters: in
this case we are reusing the ones of the damper shape. Moreover, the element is assigned to the class
mechanicals for styling.
To be coherent with the styling, you should use (when needed) the length \pgf@circ@scaled@Rlen
as the “basic” length for drawing, using the fill functions (they are defined at the start of the file
pgfcirc.defines.tex) to fill and stroke — so that the operation will follow the style parameters and,
finally, use the macro \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 none.
The anchors for the bipole (which then set the lengths \pgf@circ@res@left) are already scaled for your
use. You can use these lengths (which defines, normally, the geographical anchors of the element) to draw
your shapes.
This is not sufficient for using the element in a to[] path command; you need to “activate” it (the
definition of the commands are normally in pgfcircpath.tex). In this case the component is simple —
look at the definitions if you need to do more complex things.
\pgfcirc@activate@bipole@simple{l}{viscoe}
In the definition above, the {l} parameter means that using the component like to[viscoe=A] will be
equivalent to to[viscoe, l=A]; you can use also v or i or f if your component needs it. Now you can
show it with:
\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)
200
to[viscoe] ++(2,0);
\end{circuitikz}
\end{LTXexample}
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 in the main argument of the \pgfcircdeclarebipole, things will be setup so
that the lengths \pgf@circ@res@right and \pgf@circ@res@up are the x-y coordinates of the upper right
corner, and \pgf@circ@res@left and \pgf@circ@res@down are the x-y coordinates of the lower left corner
of your shape. The center coordinate is usually at (0pt, 0pt).
Looking at the implementation of the spring element, one possibility is changing the lines between lines 12
and 16 with:
% 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
left right
viscoe: Mechanical viscoelastic element, type: path-style,
fillable, nodename: viscoeshape. Class: mechanicals.
center
north
north west north east
right
left text
west east
center
south west south east
south
\begin{circuitikz}
\draw (0,0) to[spring] ++(2,0)
to[viscoe] ++(2,0);
\end{circuitikz}
Now you can check if the voltage labels are correct for your new component:
\begin{circuitikz}[]
\draw (0,0) to[spring] ++(2,0)
to[viscoe, v=V] ++(2,0);
V \end{circuitikz}
If you think they are too tight or too loose you can use a (developer-only) key to adjust the distance:
201
\begin{circuitikz}
\ctikzset{bipoles/viscoe/voltage/additional shift/.
initial=1}
\draw (0,0) to[spring] ++(2,0)
V to[viscoe, v=V] ++(2,0);
\end{circuitikz}
Notice that by default the key bipoles/mybipole/voltage/additional shift is not defined, so if you
want to use it you must create it before (this is the meaning of the .initial here).
Now you can save all the code between the \makeatletter and \makeatother in a file and \input{} it
for using your special component, or submit the component to the project (see below).
As a final note, notice that the viscoe element is already added to the standard package.
at the start of anchors and macros definition, and use (for example, the exact code will change greatly
depending on your component):
\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
}
and then use \pgf@circ@scaled@Rlen (or the anchors) as default lengths while you draw it.
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…) will answer.
202
10 Examples
Here a series of example, contributed by several people, is shown with their code.
2.2 kΩ
0.3 kΩ i1
1 kΩ
1
1 mA
10 µF b 12 mH
i1
\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}
203
10.2 Using the (experimental) siunitx syntax
2 mH
4 nF
1 kΩ
1 2 3
a(t)
e(t) 0.25 kΩ 2 nF
\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}
10 Ω
A
vx
20 Ω 5Ω
S
v
5 x
B
\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}
204
10.3 Photodiodes
\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}
Cd1
−
Rd Rd Uwy
Uwe +
Cd2
\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}
205
10.5 Mixing circuits and graphs
t0 i1 /mA
1 mA
4
Ω
+
2k
+
− 2V
-3 2
v1 v1 /V
-2 4
− i1
2 kΩ
-4
1 kΩ
−
+
4V
\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/\si{\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}
206
10.6 RF circuit
RF
LO
\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.port3)
(w1.out2) .. controls ++(0.8,0) and ++(0,-0.8) .. (c2.port4)
(c1.port1) .. controls ++(-0.8,0) and ++(0,0.8) .. (c3.port2)
(c1.port4) .. controls ++(-0.8,0) and ++(0,-0.8) .. (c2.port1)
(w1.in) to[short,-o] ++(-1,0)
(w1.in) node[left=30] {LO}
(c1.port2) node[match,yscale=1] {}
(c1.port3) to[short,-o] ++(1,0)
(c1.port3) node[right=30] {RF}
(c2.port3) to[detector,-o] ++(0,1.5)
(c2.port2) to[detector,-o] ++(0,1.5)
(c3.port1) to[detector,-o] ++(0,-1.5)
(c3.port4) to[detector,-o] ++(0,-1.5)
;
\end{circuitikz}
207
10.7 A styled low noise input stage
E+
R+
+
−
R−
E− AD8429
v+ v−
digitally
1 2 3 4 controlled
switches
ADG1414
Rgnd
Rc Egnd
ground
R R
electrode
vcm
Body
\ctikzloadstyle{romano}
\scalebox{0.707}{%
\begin{circuitikz}[american, romano circuit style]
\ctikzset{bipoles/cuteswitch/thickness=0.5}
\draw (0,0) node[ground](GND0){} to[sV, l=$v_{cm}$] ++(0,1)
to [R, l=$R_c$, -*] ++(0,1.5) coordinate(vcm) --++(0,0.5) coordinate(diffc);
\draw (diffc) -| ++(-0.5, 0.5) to[sV,l=$v_+$, name=vplus] ++(0,1) --++(0,2)
-- ++(2.5,0) coordinate(skin+ a) to[battery2, l=$E_+$, name=eplus] ++(1,0)
to[R=$R_+$, name=rplus] ++(2,0) coordinate(skin+ b) -- ++(0.5,0)
-- ++(4,0) coordinate(hpin+) to[highpass] ++(2,0)
node[inst amp, anchor=+, noinv input up,
circuitikz/amplifiers/scale=1.6,
circuitikz/tripoles/inst amp/width=1](LNA){LNA}
(LNA.out);
\coordinate (skin- a) at (LNA.- -| skin+ a);
\draw (diffc) -| ++(0.5,0.5) to[sV,l_=$v_-$, name=vminus] ++(0, 1) |- (skin- a);
\draw (skin- a) to[battery2, l_=$E_-$, name=eminus] ++(1,0)
to[R, l_=$R_-$, name=rminus] ++(2,0) coordinate(skin- b) -- ++(2.5,0)
-- (skin- b -| hpin+) to[highpass] (LNA.-);
\coordinate (gnd a) at (vcm -| skin+ a);
\draw (vcm) -- (gnd a) to[battery2, l_=$E_\mathrm{gnd}$, name=egnd] ++(1,0)
to[R, l_=$R_\mathrm{gnd}$, name=rgnd] ++(2,0) coordinate(gnd b);
% switch set
\def\swdown{-3.2}
\draw (skin- b) ++(1,0) coordinate(sw1) to[cosw, invert, mirror, l=1, *-, name=s1]
++(0,\swdown) to[short, -*] ++(0, -1.5);
\draw (sw1) ++(1,0) coordinate(sw2) to[cosw, invert, mirror, l=2, *-] ++(0,\swdown)
to[R=$R$, -*] ++(0, -1.5);
\draw (sw2|-skin+ b) ++(1,0) coordinate(sw3) to[short, *-] (sw3|-sw2) to[cosw,
invert, mirror, l=3,] ++(0,\swdown) to[R=$R$, -*] ++(0, -1.5);
\draw (sw3) ++(1,0) coordinate(sw4) to[short, *-] (sw4|-sw2) to[cosw, invert, mirror,
l=4, name=s4] ++(0,\swdown) to[short] ++(0, -1.5) coordinate(endsw);
\draw (gnd b) |- (endsw) node[rectjoinfill]{};
% boxes
\node [rectangle, draw, dashed, fit=(GND0) (vplus) (vpluslabel) (vminuslabel)](body)
{};
\node [anchor=south east, align=center] at (body.south east) {Body} ;
\node [rectangle, draw, dashed, fit=(rplus) (eplus) (epluslabel) (rpluslabel)](top)
{};
\node [rectangle, draw, dashed, fit=(eminus) (rminus) (eminuslabel) (rminuslabel)](
bot){};
208
\node [anchor=center, align=center] at ($(top.south)!0.5!(bot.north)$) {electrodes}
;
\node [rectangle, draw, dashed, fit=(egnd) (rgnd) (egndlabel) (rgndlabel)](gnd){};
\node [below, align=center] at (gnd.south) {ground\\ electrode} ;
\node [rectangle, draw, dashed, fit=(s1) (s4label), inner ysep=8pt](switches){};
% ADC and micro
\draw (LNA.out) -- ++(0.5,0) node[msport,circuitikz/RF/scale=2](ADC){ADC};
\draw (ADC.right) -- ++(0.5,0) node[twoportshape, anchor=left, t=$\upmu$C](uC){};
\draw (uC.south) -- (uC.south |- switches.east) -- ++(-4,0)
node[align=left, anchor=east](DCS){\small digitally\\ controlled\\ switches};
\draw[-Stealth] (DCS.west) -- (switches.east);
% components
\node [anchor=north west] at ([xshift=-10pt, yshift=-5pt]switches.south east) {ADG
1414};
\node [anchor=north west] at ([yshift=-5pt]LNA.refv down) {AD8429};
\end{circuitikz}
} % scalebox
R1
\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}
209
10.9 3-phases block schematic
fault
HVDC line
transformer
210
11 Changelog and Release Notes
The major changes among the different CircuiTikZ versions are listed here. See https://github.com/
circuitikz/circuitikz/commits for a full list of changes.
– Add draw only pins feature to dipchip and qfpchip, thanks to Jonathan P. Spratte, and a
similar option to control the pins of muxdemux
– Make dipchip and qfpchip respect no input leads option
– Several corrections to the manual
– New options for the line thickness, rotation and size of symbols drawn in sources
– New tutorial: drawing a circuit around an operational amplifier
– Documentation fixes and small enhancements
211
– Added stacked annotations for symmetry with stacked labels.
– Fixed a bug in the plotting of inst amp ra terminals.
– Fixed a bug in managing stacked labels (l2=...); possibly it will be mildly backward-
incompatible (please see the manual about incompatible changes)
– Added separate configuration for the line thickness of resistors, capacitors, and inductors
modifiers
– Added ferroelectric capacitors and ferroelectric gate MOS/FETs (suggested by Mayeul Cantan)
– Added an option to fill the gate gap in MOSes, FETs and IGBTs with a color
– Added a “centergap” anchor for transistors
– Added the option “nogate” to the hemt symbol
– Fixed a bug in thermistors not respecting their class line thickness
– Fixes in the manual (copy and paste of snippets without numbers, correct old usage of siunitx,
factor out repetitions in the preamble; thanks to Ulrike Fischer.
– Fixed a bug introduced in 1.3.3 that would reduce compatibility with the circuits internal
library; reported by JetherReis)
212
– Added graphene FETs (suggested by Cees Keyer)
– Added left/right anchors to transistors
– Fixed a bug in flip-flops
– Fixed a long-standing problem with labels and similar decoration with equal signs and commas
– Fixed a typo in the manual (thanks to @muzimuzhi on GitHub)
– The Mother of All Code Refactoring: no real changes (modulo errors)
– Added a rollback point to 1.2.7
– The recent temporary changes to TikZ to v3.1.8a revealed a problem in corner cases with
circuitikz that should be fixed (thanks to Henri Menke)
213
• Version 1.2.3 (2020-08-07)
Several fixes and small enhancement all over the map, changes in the documentation to better
explain the reasons and effect of the path-building changes of 1.2.0 and 1.2.1.
The internal changes are basically the re-implementation of the macros that draw the path elements
(to[...]), which have been completely rewritten. Please be sure to read the possible incompatibil-
ities in the manual (section 1.9).
214
– Blocks and component for three-phase networks (3-lines wire, AC/DC and DC/AC converters
blocks and grid node block) added by user @olfline on GitHub
– added transformer sources with optional vector groups for three-phase networks by @olfline
on Github
– added subsections to the examples
– fixed position of american voltages on open circuits (suggested by user @rhandley on GitHub)
– The manual has been reorganized and extended, with the addition of a tutorial part; tens of
examples have been added all over the map.
– Around 74 new shapes where added. Notably, now there are chips, mux-demuxes, multi-
terminal transistors, several types of switches, flip-flops, vacuum tubes, 7-segment displays,
more amplifiers, and so on.
– Several existing shapes have been enhanced; for example, logic gates have a variable number
of inputs, transistors are more configurable, resistors can be shaped more, and more.
215
– You can style your circuit, changing relative sizes, default thickness and fill color, and more
details of how you like your circuit to look; the same you can do with labels (voltages, currents,
names of components and so on).
– A lot of bugs have been squashed; especially the (very complex) voltage direction conundrum
has been clarified and you can choose your preferred style here too.
– Fix the position of transistor’s text. There is an option to revert to the old behavior.
– Added anchors for adding circuits (like snubbers) to the flyback diodes in transistors (after a
suggestion from @EdAlvesSilva on GitHub).
216
– Added the possibility to style each one of the two coils in a transformer independently
– Added bulk connection to normal MOSFETs and the respective anchors
– Added “text” anchor to the flow arrows, to use them alone in a consistent way
– Fixed flow, voltage, and current arrow positioning when “auto” is active on the path
– Fixed transistors arrows overshooting the connection point, added a couple of anchors
– Fixed a spelling error on op-amp key “noinv input down”
– Fixed a problem with “quadpoles style=inner” and “transformer core” having the core lines
running too near
– Added a “midtap” anchor for coils and exposed the inner coils shapes in the transformers
– Added a “curved capacitor” with polarity coherent with “ecapacitor”
– Added the possibility to apply style and access the nodes of bipole’s text ornaments (labels,
annotations, voltages, currents and flows)
– Added the possibility to move the wiper in resistive potentiometers
– Added a command to load and set a style in one go
– Fixed internal font changing commands for compatibility with ConTeXt
– Fixed hardcoded black color in “elko” and “elmech”
– Fixed a bug with “inline” gyrators, now the circle will not overlap
– Fixed a bug in input anchors of european not ports
– Fixed “tlinestub” so that it has the same default size than “tline” (TL)
– Fixed the “transistor arrows at end” feature, added to styling
– Changed the behavior of “voltage shift” and voltage label positioning to be more robust
– Added several new anchors for “elmech” element
– Several minor fixes in some component drawings to allow fill and thickness styles
– Add 0.9.3 version snapshots.
– Added styling of relative size of components (at a global or local level)
– Added styling for fill color and thickeness
– Added style files
– Added the option to have “dotless” P-MOS (to use with arrowmos option)
– Fixed a (puzzling) problem with coupler2
– Fixed a compatibility problem with newer PGF (>3.0.1a)
217
– (hopefully) fixed ConTeXt compatibility. Most new functionality is not tested; testers and
developers for the ConTeXt side are needed.
– Added old ConTeXt version for 0.8.3
– Added tailless ground
– Added old LaTeX versions for 0.8.3, 0.7, 0.6 and 0.4
– Added the option to have inline transformers and gyrators
– Added rotary switches
– Added more configurable bipole nodes (connectors) and more shapes
– Added 7-segment displays
– Added vacuum tubes by J. op den Brouw
– Made the open shape of dcisources configurable
– Made the arrows on vcc and vee configurable
– Fixed anchors of diamondpole nodes
– Fixed a bug (#205) about unstable anchors in the chip components
– Fixed a regression in label placement for some values of scaling
– Fixed problems with cute switches anchors
218
• Version 0.8.3 (2017-05-28)
– Removed unwanted lines at to-paths if the starting point is a node without a explicit anchor.
– Fixed scaling option, now all parts are scaled by bipoles/length
– Surge arrester appears no more if a to path is used without []-options
– Fixed current placement now possible with paths at an angle of around 280°
– Fixed voltage placement now possible with paths at an angle of around 280°
– Fixed label and annotation placement (at some angles position not changable)
– Adjustable default distance for straight-voltages: ‘bipoles/voltage/straight label distance’
– Added Symbol for bandstop filter
– New annotation type to show flows using f=… like currents, can be used for thermal, power or
current flows
– Fixes pgfkeys error using alternatively specified mixed colors(see pgfplots manual section “4.7.5
Colors”)
– Added new switches “ncs” and “nos”
– Reworked arrows at spst-switches
– Fixed direction of controlled american voltage source
– “v<=” and “i<=” do not rotate the sources anymore(see them as “counting direction indica-
tion”, this can be different then the shape orientation); Use the option “invert” to change the
direction of the source/apperance of the shape.
– current label “i=” can now be used independent of the regular label “l=” at current sources
– rewrite of current arrow placement. Current arrows can now also be rotated on zero-length
paths
– New DIN/EN compliant operational amplifier symbol “en amp”
219
– New packet-option ”straightvoltages, to draw straight(no curved) voltage arrows
– New option “invert” to revert the node direction at paths
– Fixed american voltage label at special sources and battery
– Fixed/rotated battery symbol(longer lines by default positive voltage)
– New symbol Schmitttrigger
• Version 0.4
• Version 0.3.1
• Version 0.3.0
220
– added fully differential op amp (by Kristofer M. Monisit)
– now general settings for the drawing of voltage can be overridden for specific components
– made arrows more homogeneous (either the current one, or latex’ bt pgf)
– added the single battery cell
– added fuse and asymmetric fuse
– added toggle switch
– added varistor, photoresistor, thermocouple, push button
– added thermistor, thermistor ptc, thermistor ptc
– fixed misalignment of voltage label in vertical bipoles with names
– added isfet
– added noiseless, protective, chassis, signal and reference grounds (Luigi «Liverpool»)
• Version 0.2.4
• Version 0.2.3
221
– backward incompatibility transformer now linked with the chosen type of inductor, and version
with core, too. Similarly for variable inductor
– backward incompatibility styles for selecting shape variants now end are in the plural to avoid
conflict with paths
– new placing option for some tripoles (mostly transistors)
– mirror path style
– Op-amps added
– added options arrowmos and noarrowmos, to add arrows to pmos and nmos
– Backward incompatibility: labels ending with :angle are not parsed for positioning anymore.
– Full use of TikZ keyval features.
– White background is not filled anymore: now the network can be drawn on a background
picture as well.
– Several new components added (logical ports, transistors, double bipoles, …).
– Color support.
– Integration with {siunitx}.
– Voltage, american style.
– Better code, perhaps. General cleanup at the very least.
222
Index of the components
223
cvsource, see european controlled voltage source european nand port, 134
cvsourceAM, see american controlled voltage european nor port, 134
source european not port, 135
cvsourceC, see cute european controlled voltage european or port, 134
source european potentiometer, see pR
cvsourcesin, see controlled sinusoidal voltage european resistive sensor, see sR
source european resistor, see R
european voltage source, 63
D*, see full diode, see full diode european xnor port, 134
D-, see stroke diode european xor port, 134
dac, 83
damper, 75, 198 fd inst amp, 119
dcisource, 67 fd op amp, 118
dcvsource, 67 feC, 52
demux, 150 ferrocap, see feC
detector, 84 fft, 83
diamondpole, 81 flipflop, 145
diodetube, 106 flipflop AB, 145
diodetube,filament, 107 flipflop D, 146
diodetube,filament,nocathode, 107 flipflop JK, 146
diodetube,fullcathode, 107 flipflop JK, add async SR, 147
dipchip, 154 flipflop JK, add async SR, external pins
Do, see empty diode width=0, 148
dsp, 83 flipflop JK, dot on notQ, 146
dynode, 109 flipflop myJK, 147
flipflop SR, 146
eC, see ecapacitor flipflop T, 146
ecapacitor, 52 flowarrow, 79
ecsource, see empty controlled source fourport, 85
eground, 46 full agtobar, 60
eground2, 46 full bidirectionaldiode, 58
elko, see ecapacitor full diode, 57, 59
elmech, 112 full gto, 60
empty agtobar, 60 full gtobar, 60
empty bidirectionaldiode, 57 full led, 58
empty controlled source, 65 full photodiode, 57
empty diode, 57 full put, 59
empty gto, 60 full Schottky diode, 57
empty gtobar, 60 full thyristor, 59
empty led, 57 full triac, 59
empty photodiode, 57 full tunnel diode, 57
empty put, 59 full varcap, 58
empty Schottky diode, 57 full Zener diode, 57
empty thyristor, 59 full ZZener diode, 57
empty triac, 59 fuse, 76
empty tunnel diode, 57
empty varcap, 57 generic, 48
empty Zener diode, 57 gm amp, 118
empty ZZener diode, 57 gridnode, 82
en amp, 118 ground, 46
esource, 66 GTO, see gto
european and port, 134 gto, 60, 61
european buffer port, 134 GTO*, see full gto
european controlled current source, 64 GTO-, see stroke gto
european controlled voltage source, 64 GTOb, see gtobar
european current source, 63 GTOb*, see full gtobar
european gas filled surge arrester, 76 GTOb-, see stroke gtobar
european inductive sensor, see sL gtobar, 60, 61
european inductor, see L GTObo, see empty gtobar
224
GTOo, see empty gto memristor, 49
gyrator, 114 mic, 77
mixer, 82
hemt, 90 Mr, see memristor
hemt, nobase, 90 mslstub, 110
highpass, 83 msport, 110
highpass2, 83 msrstub, 110
mstline, 110
ieee double tgate, 134 multiwire, 77, see multiwire
ieee tgate, 134 muxdemux, 150
ieeestd and port, 133 mzm, 83
ieeestd buffer port, 133
ieeestd invschmitt port, 134 ncpb, see normally closed push button
ieeestd nand port, 133 ncpbo, see normally closed push button open
ieeestd nor port, 133 ncs, see normal closed switch
ieeestd not port, 133 nfet, 91
ieeestd or port, 133 nfetd, 91
ieeestd schmitt port, 133 ngfet, 93
ieeestd xnor port, 133 nground, 46
ieeestd xor port, 133 nI, see noise current source
iloop, 70 nigbt, 89
iloop2, 70 nigfetd, 91
inerter, 75 nigfete, 91
inline buffer, 135 nigfete,solderdot, 91
inline double tgate, 135 nigfetebulk, 91
inline invschmitt, 135 njfet, 92
inline not, 135 nmos, 90, 94
inline schmitt, 135 nmos, bulk, 97
inline tgate, 135 nmosd, 90, 94
inputarrow, 79 nmosd, bulk, 98
inst amp, 118 noise current source, 65
inst amp ra, 119 noise voltage source, 65
invschmitt, 132 nopb, see push button
ioosource, 67 nopbc, see normally open push button closed
isfet, 92 normal closed switch, 125
isource, see european current source normal open switch, 125
isourceAM, see american current source normally closed push button, 125
isourceC, see cute european current source normally closed push button open, 125
isourceN, see noise current source normally open push button, see push button
isourcesin, see sinusoidal current source normally open push button closed, 125
nos, see normal open switch
jump crossing, 78 notcirc, 134
npn, 36, 88
L, 54 npn, bodydiode, 88
lamp, 77 npn, schottky base, 88
latch, 146 npn, tr circle, 100
leD*, see full led npn, tr circle, bodydiode, 100
leD-, see stroke led npn,photo, 89
leDo, see empty led nujt, 92
Lnigbt, 89 nujt, nobase, 92
loudspeaker, 77 nV, see noise voltage source
lowpass, 83
lowpass2, 83 ocirc, 81
Lpigbt, 89 odiamondpole, 81
Lpigbt, bodydiode, 89 ohmmeter, 69
one bit adder, 150
magnetron, 109 ooosource, 67
mass, 75 oosourcetrans, 67
match, 111 op amp, 19, 118
225
open, 48 reed, 125
openbarrier, 76 resistor, 34
opening switch, 125 rground, 46
oscillator, 82 rmeter, 69
oscope, 70 rmeterwa, 70
ospst, see opening switch rotaryswitch, 37, 128
osquarepole, 81 rxantenna, 111
226
thermistor ntc, see thRn variable european resistor, see vR
thermistor ptc, see thRp varistor, 49
thermocouple, 76 vC, see variable capacitor
thR, 49 VC*, see full varcap
thRn, 50 VC-, see stroke varcap
thRp, 50 vcc, 47
thyristor, 59, 61 VCo, see empty varcap
TL, 111 vco, 83
tlground, 46 vee, 47
tline, see TL viscoe, 75, 201
tlinestub, 111 vL, 54
tmultiwire, 77, see tmultiwire voltmeter, 69
toggle switch, 125 voosource, 67
Tr, see triac, see triac vphaseshifter, 84
Tr*, see full triac vpiattenuator, 84
transformer, 113, 114 vR, 49
transformer core, 114 vsource, see european voltage source
transmission line, see TL vsourceAM, see american voltage source
trarrow, 79 vsourceC, see cute european voltage source
triac, 59, 61 vsourceN, see noise voltage source
triode, 106 vsourcesin, see sinusoidal voltage source
Tro, see empty triac vsourcesquare, see square voltage source
tV, see vsourcetri vsourcetri, 66
twoport, 83 vtattenuator, 84
twoportsplit, 83
txantenna, 111 waves, 110
Ty, see thyristor, see thyristor wilkinson, 82
Ty*, see full thyristor
Ty-, see stroke thyristor xgeneric, 48
Tyo, see empty thyristor xing, see crossing
227