Professional Documents
Culture Documents
version 0.4
Massimo A. Redaelli
May 4, 2015
Contents
1 Introduction
1.1 About . . . . . . . . . . . . .
1.2 Loading the package . . . . .
1.3 License . . . . . . . . . . . .
1.4 Feedback . . . . . . . . . . .
1.5 Requirements . . . . . . . .
1.6 Incompatible packages . . .
1.7 Introduction to version 0.3.0
1.8 Introduction to version 0.2.3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2 Package options
2
3
3
3
3
3
4
4
4
4
3 The components
3.1 Monopoles . . . . . . . . . . . .
3.2 Bipoles . . . . . . . . . . . . . .
3.2.1 Instruments . . . . . . .
3.2.2 Basic resistive bipoles . .
3.2.3 Resistors and the like . .
3.2.4 Stationary sources . . . .
3.2.5 Diodes and such . . . . .
3.2.6 Basic dynamical bipoles .
3.2.7 Sinusoidal sources . . . .
3.2.8 Special sources . . . . .
3.2.9 DC sources . . . . . . . .
3.2.10 Switch . . . . . . . . . .
3.2.11 HF components . . . . .
3.3 Tripoles . . . . . . . . . . . . . .
3.3.1 Controlled sources . . .
3.3.2 Transistors . . . . . . . .
3.3.3 HF . . . . . . . . . . . . .
3.3.4 Switch . . . . . . . . . .
3.3.5 Other bipole-like tripoles
3.3.6 Misc . . . . . . . . . . .
3.4 Double bipoles . . . . . . . . . .
3.5 Logic gates . . . . . . . . . . . .
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
6
7
9
9
9
10
12
13
15
16
16
17
17
17
19
19
21
24
24
24
24
25
26
3.6
3.7
Amplifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Support shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Usage
4.1 Labels . . . . . . . . . . .
4.2 Currents . . . . . . . . .
4.3 Voltages . . . . . . . . .
4.3.1 European style . .
4.3.2 American style . .
4.4 Nodes . . . . . . . . . . .
4.5 Special components . . .
4.6 Integration with siunitx
4.7 Mirroring . . . . . . . . .
4.8 Putting them together . .
28
29
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
29
30
31
32
32
33
33
34
36
36
37
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
37
37
38
40
40
41
42
43
6 Customization
6.1 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Components size . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44
44
45
46
7 FAQ
48
8 Examples
49
9 Revision history
54
57
.
.
.
.
.
.
.
.
.
.
Introduction
After two years of little exposure only on my personal website1 , I did a major rehauling of the code of CircuiTikZ, fixing several problems and converting everything to
TikZ version 2.0.
Im not too sure about the result, because my (La)TEX skills are much to be
improved, but it seems its time for more user feedback. So, here it is
I know the documentation is somewhat scant. Hope to have time to improve it a
bit.
1 Now the package is moved to its own git repository: https://github.com/mredaelli/
circuitikz. Contributions are welcome.
1.1 About
This package provides a set of macros for naturally typesetting electrical and (somewhat less naturally, perhaps) electronical networks.
It was born mainly for writing my own exercise book and exams sheets for the
Elettrotecnica courses at Politecnico di Milano, Italy. I wanted a tool that was easy
to use, with a lean syntax, native to LATEX, and supporting directly PDF output format.
So I based everything with the very impressive (if somewhat verbose at times)
TikZ package.
ConTEXt2
\usepackage{circuitikz}
\usemodule[circuitikz]
1.3 License
Copyright 20072011 Massimo Redaelli. This package is author-maintained. Permission is granted to copy, distribute and/or modify this software under the terms
of the LATEXProject 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.
1.4 Feedback
Much appreciated: k mailto:m.redaelli@gmail.com. Although I dont guarantee
quick answers.
1.5 Requirements
tikz, version 2;
xstring, not older than 2009/03/13;
siunitx, if using siunitx option.
2 ConT Xt
suppurt was added mostly thanks to Mojca Miklavec and Aditya Mahajan.
Package options
Circuit people are very opinionated about their symbols. The package, left to its
own devices, loads with drawing conventions that I like, so for instance you get this:
\begin{ circuitikz }
\draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0)
3
(2,2) to[V=84<\volt>] (0,2)
4
(0,0);
5 \end{ circuitikz }
1
2
84 V
2
84 V
But if you really, really want your circuit ugly, you can load the package with:
LATEX
ConTEXt
\usepackage[american]{circuitikz}
\usemodule[circuitikz][american]
+
84 V
2
84 V
The components
Here follows the list of all the shapes defined by CircuiTikZ. These are all pgf nodes,
so they are usable in both pgf and TikZ.
Each bipole (plus triac and thyristors) are shown using the following command,
where #1 is the name of the component3 :
3 If
#1 is the name of the bipole/the style, then the actual name of the shape is #1shape.
\begin{center}\begin{circuitikz} \draw
(0,0) to[ #1 ] (2,0)
; \end{circuitikz} \end{center}
The other shapes are shown with:
\begin{center}\begin{circuitikz} \draw
(0,0) node[ #1 ] {}
; \end{circuitikz} \end{center}
Please notice that for user convenience transistors can also be inputted using
the syntax for bipoles. See section 5.3.
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 tikzpicture: everything will work there just fine.
3.1 Monopoles
Ground (ground)
4 These
Antenna (antenna)
VCC (vcc)
match (match)
LO5 (oscillator)
5 These
3.2 Bipoles
3.2.1 Instruments
Ammeter (ammeter)
A
Voltmeter (voltmeter)
V
Ohmmeter (ohmmeter)
Lamp (lamp)
Thermocouple (thermocouple)
Fuse (fuse)
11
12
13
The options fulldiodes and emptydiodes (and the styles [full diodes]
and [empty diodes]) define which shape will be used by abbreviated commands such that D, sD, zD, tD, pD, leD, and VC.
Squid (squid)
Barrier (barrier)
European gas filled surge arrester (european gas filled surge arrester)
American gas filled surge arrester (american gas filled surge arrester)
14
If (default behaviour) cuteinductors option is active (or the style [cute inductors]
is used), the inductors are displayed as follows:
Inductor (L, or cute inductor)
16
3.2.9 DC sources
DC voltage source (dcvsource)
3.2.10 Switch
Switch (switch, or spst)
3.2.11 HF components
Contributed by Stefan Erhardt.
generic two port6 (twoport)
vco (vco)
bandpass (bandpass)
6 To
17
text
highpass (highpass)
lowpass (lowpass)
DSP (dsp)
DSP
FFT (fft)
FFT
amplifier (amp)
VGA (vamp)
18
attenuator (piattenuator)
T attenuator (tattenuator)
detector (detector)
3.3 Tripoles
3.3.1 Controlled sources
Admittedly, graphically they are bipoles. But I couldnt
Controlled voltage source (european style) (european controlled voltage
source)
19
20
3.3.2 Transistors
nmos (nmos)
pmos (pmos)
npn (npn)
pnp (pnp)
npigbt (nigbt)
pigbt (pigbt)
If the option arrowmos is used (or after the commant \ctikzset{tripoles/mos style/arrows}
is given), this is the output:
nmos (nmos)
21
pmos (pmos)
nfets and pfets have been incorporated based on code provided by Clemens
Helfmeier and Theodor Borsche:
nfet (nfet)
nigfete (nigfete)
nigfetebulk (nigfetebulk)
nigfetd (nigfetd)
pfet (pfet)
22
pigfete (pigfete)
pigfetebulk (pigfetebulk)
pigfetd (pigfetd)
njfet and pjfet have been incorporated based on code provided by Danilo Piazzalunga:
njfet (njfet)
pjfet (pjfet)
isfet
isfet (isfet)
23
3.3.3 HF
These come from Stefan Erhardts contribution of HF components.
circulator (circulator)
3.3.4 Switch
spdt (spdt)
3.3.6 Misc
Mixer (mixer)
24
Gyrator (gyrator)
Coupler (coupler)
Coupler, 2 (coupler2)
26
1
European xor port (european xor port)
=1
European xnor port (european xnor port)
=1
3.6 Amplifiers
Operational amplifier (op amp)
by Kristofer M. Monisit.
28
Buffer (buffer)
Usage
\begin{ circuitikz }
\draw (0,0) to[R, l=$R_1$] (2,0);
3 \end{ circuitikz }
1
R1
\begin{ circuitikz }
\draw (0,0) to[R=$R_1$] (2,0);
3 \end{ circuitikz }
1
R1
\begin{ circuitikz }
\draw (0,0) to[R, i=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
29
\begin{ circuitikz }
\draw (0,0) to[R, v=$v_1$] (2,0);
3 \end{ circuitikz }
1
2
v1
R1
i1
v1
R1
i1
v1
\begin{ circuitikz }
\draw (0,0) to[R=$R_1$, i=$i _1$, v=$v_1$] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R=$R_1$, i=$i _1$, v=$v_1$] (2,0);
3 \end{ circuitikz }
1
2
1 k
4.1 Labels
\begin{ circuitikz }
\draw (0,0) to[R, l^=$R_1$] (2,0);
3 \end{ circuitikz }
1
R1
\begin{ circuitikz }
\draw (0,0) to[R, l_=$R_1$] (2,0);
3 \end{ circuitikz }
1
2
R1
90
45
\begin{ circuitikz }
\ ctikzset { label /align = straight }
3 \def\DIR{0,45,90,135,180,90,45,135}
4 \foreach \i in \DIR {
5
\draw (0,0) to[R=\i , *o] (\ i :2.5);
6 }
7 \end{ circuitikz }
1
2
135
180
-45
-135
-90
30
45
90
\begin{ circuitikz }
\ ctikzset { label /align = rotate }
3 \def\DIR{0,45,90,135,180,90,45,135}
4 \foreach \i in \DIR {
5
\draw (0,0) to[R=\i , *o] (\ i :2.5);
6 }
7 \end{ circuitikz }
1
2
5
13
-90
-1
35
5
-4
180
\begin{ circuitikz }
\ ctikzset { label /align = smart}
3 \def\DIR{0,45,90,135,180,90,45,135}
4 \foreach \i in \DIR {
5
\draw (0,0) to[R=\i , *o] (\ i :2.5);
6 }
7 \end{ circuitikz }
1
45
90
5
13
-1
35
-4
180
-90
4.2 Currents
\begin{ circuitikz }
\draw (0,0) to[R, i^>=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i_>=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i^<=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i_<=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i>^=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i>_=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
31
\begin{ circuitikz }
\draw (0,0) to[R, i<^=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i<_=$i_1$] (2,0);
3 \end{ circuitikz }
1
2
i1
Also
\begin{ circuitikz }
\draw (0,0) to[R, i<=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i>=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i^=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
\begin{ circuitikz }
\draw (0,0) to[R, i_=$i_1$] (2,0);
3 \end{ circuitikz }
1
i1
4.3 Voltages
4.3.1 European style
The default, with arrows. Use option europeanvoltage or style [european voltages].
v1
v1
v1
v1
32
v1
v1
v1
v1
4.4 Nodes
\begin{ circuitikz }
\draw (0,0) to[R, oo] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, o] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, o] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, **] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, *] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, *] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, o*] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[R, *o] (2,0);
3 \end{ circuitikz }
1
2
33
\begin{ circuitikz }
\draw (0,0) to[ I=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
a1
\begin{ circuitikz }
\draw (0,0) to[ I , i=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
k a1
\begin{ circuitikz }
\draw (0,0) to[ cI=$k\cdot a_1$] (2,0);
3 \end{ circuitikz }
1
2
a1
\begin{ circuitikz }
\draw (0,0) to[ sI=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
k a1
\begin{ circuitikz }
\draw (0,0) to[ csI =$k\cdot a_1$] (2,0);
3 \end{ circuitikz }
1
2
The following results from using the option americancurrent or using the style
[american currents].
a1
a1
k a1
a1
34
k a1
\begin{ circuitikz }
\draw (0,0) to[V=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
a1
\begin{ circuitikz }
\draw (0,0) to[V, v=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
k a1
\begin{ circuitikz }
\draw (0,0) to[cV=$k\cdot a_1$] (2,0);
3 \end{ circuitikz }
1
2
a1
\begin{ circuitikz }
\draw (0,0) to[sV=$a_1$] (2,0);
3 \end{ circuitikz }
1
2
k a1
\begin{ circuitikz }
\draw (0,0) to[csV=$k\cdot a_1$] (2,0);
3 \end{ circuitikz }
1
2
The following results from using the option americanvoltage or the style
[american voltages].
a1
a1
k a1
a1
35
k a1
1 k
\begin{ circuitikz }
\draw (0,0) to[R, l=$\SI {1}{\ kilo \ohm}$] (2,0);
3 \end{ circuitikz }
1
1 k
\begin{ circuitikz }
\draw (0,0) to[R, i=1<\ milli \ampere>] (2,0);
3 \end{ circuitikz }
1
1 mA
\begin{ circuitikz }
\draw (0,0) to[R, i=$\SI {1}{\ milli \ampere}$] (2,0);
3 \end{ circuitikz }
1
1 mA
\begin{ circuitikz }
\draw (0,0) to[R, v=1<\volt >] (2,0);
3 \end{ circuitikz }
1
2
1V
\begin{ circuitikz }
\draw (0,0) to[R, v=$\SI {1}{\ volt }$] (2,0);
3 \end{ circuitikz }
1
2
1V
4.7 Mirroring
\begin{ circuitikz }
\draw (0,0) to[pD] (2,0);
3 \end{ circuitikz }
1
2
\begin{ circuitikz }
\draw (0,0) to[pD, mirror] (2,0);
3 \end{ circuitikz }
1
2
i1
\begin{ circuitikz }
\draw (0,0) to[ospst=T, mirror, i=$i_1$] (2,0);
3 \end{ circuitikz }
1
2
36
1
2
1 k
1 mA
\begin{ circuitikz }
\draw (0,0) to[D*, v=$v_D$,
3
i=1<\ milli \ampere>, o*] (3,0);
4 \end{ circuitikz }
1
1 mA
vD
Since only bipoles (but see section 5.3) can be placed along a line, components
with more than two terminals are placed as nodes:
+5 V
\begin{ circuitikz }
\draw (0,0) node[npn](npn) at (0,0) {};
3 \draw (npn.C) ++(0,0.5) node[vcc ]{+5\,\ textnormal{V}};
4 \draw (npn.E) ++(0,0.5) node[vee]{5\,\textnormal{V}};
5 \end{ circuitikz }
1
2
-5 V
5.1 Anchors
In order to allow connections with other components, all components define anchors.
5.1.1 Logical ports
All logical ports, except not, have two inputs and one output. They are called
respectively in 1, in 2, out:
\begin{ circuitikz } \draw
(0,0) node[and port] (myand) {}
3
(myand.in 1) node[anchor=east] {1}
4
(myand.in 2) node[anchor=east] {2}
5
(myand.out) node[anchor=west] {3}
6 ;\end{ circuitikz }
1
2
1
2
37
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
(3,0) node[not port] (not2) {}
4
(0,0) (not1.in)
5
(not2.in) (not1.out)
6
++(0,1) node[ground] {} to[C] (not1.out)
7
(not2.out) | (4,1) | (0,0)
8 ;\end{ circuitikz }
1
2
5.1.2 Transistors
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):
\begin{ circuitikz } \draw
(0,0) node[nmos] (mos) {}
3
(mos.base) node[anchor=west] {B}
4
(mos.gate) node[anchor=east] {G}
5
(mos.drain) node[anchor=south] {D}
6
(mos.source) node[anchor=north] {S}
7 ;\end{ circuitikz }
1
D
G
B
S
G
S
Similarly njfet and pjfet have gate, source and drain anchors (which can be
abbreviated with G, S and D):
S
38
For npn, pnp, nigbt, and pigbt transistors the anchors are base, emitter and
collector anchors (which can be abbreviated with B, E and C):
\begin{ circuitikz } \draw
(0,0) node[npn] (npn) {}
3
(npn.base) node[anchor=east] {B}
4
(npn. collector ) node[anchor=south] {C}
5
(npn.emitter) node[anchor=north] {E}
6 ;\end{ circuitikz }
1
2
B
E
1
2
B
C
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) {2}
3
(pnp2.B) node[pnp, xscale=1, anchor=B] (pnp1) {}
4
(pnp1) node {1}
5
(pnp1.C) node[npn, anchor=C] (npn1) {}
6
(pnp2.C) node[npn, xscale=1, anchor=C] (npn2) {}
7
(pnp1.E) (pnp2.E) (npn1.E) (npn2.E)
8
(pnp1.B) node[circ ] {} | (pnp2.C) node[circ ] {}
9 ;\end{ circuitikz }
1
2
1
B
D
1
2
R1
3
4
5
6
39
{}
\begin{ circuitikz }
\draw (0,2)
node[rground, yscale=1] {}
to[R=$R_1$] (0,0)
node[sground] {};
\end{ circuitikz }
out 1
in
out 2
out
in 1
in 2
vo
v+
There are also two more anchors defined, up and down, for the power supplies:
40
12 V
v
vo
v+
v+
out +
out -
1
2
2
3
3
4
5
6
7
1
2
3 dB
out2
3
4
5
in
out1
7
8
9
10
41
A1
B1
B2
A2
A1
B1
B2
A2
However:
1
2
3
10 dB
3
4
5
6
7
8
9
10
11
12
1
2
3
3 dB
4
4
5
6
7
8
9
10
11
12
1
2
FFT
4
5
6
7
multi ports
Since inputs and outputs can vary, input arrows can be placed as nodes:
\begin{ circuitikz } \draw
(0,0) node[mixer] (m) {}
(m.in1) to[short,o] ++(1,0)
(m.in2) to[short,o] ++(0,1)
(m.out) to[short,o] ++(1,0)
(m.in1) node[inputarrow] {}
(m.in2) node[inputarrow,rotate=90] {};
\end{ circuitikz }
1
2
3
4
5
6
7
8
Access to the gate and/or base nodes can be gained by naming the transistors
with the n or name path style:
43
The name property is available also for bipoles, although this is useful mostly for
triac, potentiometer and thyristor (see 3.3.5).
Customization
6.1 Parameters
Pretty much all CircuiTikZ relies heavily on pgfkeys for value handling and configuration. Indeed, at the beginning of circuitikz.sty 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.
Shape of the components
1
\tikz \draw (0,0) to[R=1<\ohm>] (2,0); \par
\ ctikzset { bipoles/ resistor /height =.6}
3 \tikz \draw (0,0) to[R=1<\ohm>] (2,0);
1
(globally)
1F
\tikz \draw (0,0) to[C=1<\farad>] (2,0); \par
\ ctikzset { bipoles/thickness=1}
3 \tikz \draw (0,0) to[C=1<\farad>]
(2,0);
1
1F
44
Global properties
1V
1V
However, you can override the properties voltage/distance from node8 , voltage/bump b9
and voltage/european label distance10 on a per-component basis, in order to
fine-tune the voltages:
\tikz \draw (0,0) to[R, v=1<\volt >] (1.5,0)
to[C, v=2<\volt >] (3,0); \par
3 \ ctikzset { bipoles/capacitor/voltage/%
4
distance from node/. initial =.7}
5 \tikz \draw (0,0) to[R, v=1<\volt >]
(1.5,0)
6
to[C, v=2<\volt >] (3,0); \par
1
1V
1V
2V
2V
Admittedly, not all graphical properties have understandable names, but for the
time it will have to do:
\tikz \draw (0,0) node[xnor port] {};
\ ctikzset { tripoles /american xnor port/aaa=.2}
3 \ ctikzset { tripoles /american xnor port/bbb=.6}
4 \tikz \draw (0,0) node[xnor port] {};
1
2
is, how distant from the initial and final points of the path the arrow starts and ends.
how high the bump of the arrow is how curved it is.
10 Controlling how distant from the bipole the voltage label will be.
9 Controlling
45
10
A
vx
20
S
5 vx
B
\ ctikzset { bipoles/length=1.4cm}
\begin{ circuitikz }[ scale =1.2]\ draw
3
(0,0) node[anchor=east] {B}
4
to[short , o*] (1,0)
5
to[R=20<\ohm>, **] (1,2)
6
to[R=10<\ohm>, v=$v_x$] (3,2) (4,2)
7
to[ cI=$\frac{\ si {\siemens}}{5} v_x$, **] (4,0) (3,0)
8
to[R=5<\ohm>, **] (3,2)
9
(3,0) (1,0)
10
(1,2) to[short , o] (0,2) node[anchor=east]{A}
11 ;\end{ circuitikz }
1
2
10
A
vx
20
S
5 vx
B
\ ctikzset { bipoles/length=.8cm}
\begin{ circuitikz }[ scale =1.2]\ draw
3
(0,0) node[anchor=east] {B}
4
to[short , o*] (1,0)
5
to[R=20<\ohm>, **] (1,2)
6
to[R=10<\ohm>, v=$v_x$] (3,2) (4,2)
7
to[ cI=$\frac{\siemens}{5} v_x$, **] (4,0) (3,0)
8
to[R=5<\ohm>, **] (3,2)
9
(3,0) (1,0)
10
(1,2) to[short , o] (0,2) node[anchor=east]{A}
11 ;\end{ circuitikz }
1
2
6.3 Colors
The color of the components is stored in the key \circuitikzbasekey/color.
CircuiTikZ tries to follow the color set in TikZ, although sometimes it fails. If you
change color in the picture, please do not use just the color name as a style, like
[red], but rather assign the style [color=red].
Compare for instance
46
and
\begin{ circuitikz } \draw[color=red]
(0,2) node[and port] (myand1) {}
3
(0,0) node[and port] (myand2) {}
4
(2,1) node[xnor port] (myxnor) {}
5
(myand1.out) | (myxnor.in 1)
6
(myand2.out) | (myxnor.in 2)
7 ;\end{ circuitikz }
1
2
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
1V
1F
1V
1F
1V
1F
FAQ
Q: I cannot write to[R = $R_1=12V$] nor to[ospst = open, 3s]: I get errors.
A: It is a limitation of the TikZ parser. Use to[R = $R_1{=}12V$] and to[ospst = open{,} 3s]
instead.
48
Examples
2.2 k
0.3 ki1
1 k
10 F
12 mH
1 mA
i1
49
2 mH
4 nF
1
e(t)
0.25 k
1 k
2 nF
a(t)
10
11
12
{[ anchor=south east] (0,2) node {1} (2,2) node {2} (4,2) node {3}}
;\end{ circuitikz }
10
A
vx
20
S
5 vx
B
\begin{ circuitikz }[ scale =1.2]\ draw
(0,0) node[anchor=east] {B}
3
to[short , o*] (1,0)
4
to[R=20<\ohm>, **] (1,2)
5
to[R=10<\ohm>, v=$v_x$] (3,2) (4,2)
6
to[ cI=$\frac{\siemens}{5} v_x$, **] (4,0) (3,0)
7
to[R=5<\ohm>, **] (3,2)
8
(3,0) (1,0)
9
(1,2) to[short , o] (0,2) node[anchor=east]{A}
10 ;\end{ circuitikz }
1
2
50
Cd1
Rd
Uwy
Rd
Uwe
Cd2
51
i1 /mA
t0
2k
1 mA
2V
v1
-3
-2
i1
2 k
2
4
v1 /V
-4
1 k
4V
\begin{ circuitikz }[ scale =1.2, american]\draw
(0,2) to[ I=1<\ milli \ampere>] (2,2)
3
to[R, l_=2<\kilo\ohm>, **] (0,0)
4
to[R, l_=2<\kilo\ohm>] (2,0)
5
to[V, v_=2<\volt>] (2,2)
6
to[ cspst , l=$t_0$] (4,2) (4,1.5)
7
to [generic , i=$i _1$, v=$v_1$] (4,.5) (4,1.5)
8
(0,2) (0,1.5) to[V, v_=4<\volt>] (2,1.5)
9
to [R, l=1<\kilo\ohm>] (4,1.5);
1
2
10
52
RF
LO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
53
R1
1
\documentclass{standalone}
\usepackage{tikz}
\ usetikzlibrary { circuits . ee.IEC}
5 \ usetikzlibrary { positioning }
3
4
6
7
8
\usepackage[compatibility]{ circuitikz }
\ ctikzset { bipoles/length=.9cm}
\begin{document}
\begin{tikzpicture }[ circuit ee IEC]
12
\draw (0,0) to [ resistor ={name=R}] (0,2)
13
to[diode={name=D}] (3,2);
14
\draw (0,0) to[*R=$R_1$] (1.5,0) to[*Tnpn] (3,0)
15
to[*D ](3,2);
16 \end{tikzpicture }
17 \end{document}
10
11
Revision history
1. typo in documentation
2. fixed an error in the angle computation in voltage and current routines
3. fixed problem with label size when scaling a tikz picture
4. added gas filled surge arrester
5. added compatibility option to work with Tikzs own circuit library
54
4. now general settings for the drawing of voltage can be overridden for
specific components
5. made arrows more homogeneous (either the current/voltage one, or
latex by pgf)
6. added the single battery cell
7. added fuse and asymmetric fuse
8. added toggle switch
9. added varistor, photoresistor, thermocouple, push button
10. added thermistor, thermistor ptc, thermistor ptc
11. fixed misalignment of voltage label in vertical bipoles with names
12. added isfet
13. added noiseless, protective, chassis, signal and reference grounds (Luigi
Luigi Liverpool)
version 0.2.4 (20110911).
1. added square voltage source (contributed by Alistair Kwan)
2. added buffer and plain amplifier (contributed by Danilo Piazzalunga)
3. added squid and barrier (contributed by Cor Molenaar)
4. added antenna and transmission line symbols contributed by Leonardo
Azzinnari
5. added the changeover switch spdt (suggestion of Fabio Maria Antoniali)
6. rename of context.tex and context.pdf (thanks to Karl Berry)
7. updated the email address
8. in documentation, fixed wrong (non-standard) labelling of the axis in an
example (thanks to prof. Claudio Beccaria)
9. fixed scaling inconsistencies in quadrupoles
10. fixed division by zero error on certain vertical paths
11. introduced options straighlabels, rotatelabels, smartlabels
version 0.2.3 (20091118).
1. fixed compatibility problem with label option from tikz
2. Fixed resizing problem for shape ground
3. Variable capacitor
4. polarized capacitor
5. ConTEXt support (read the manual!)
6. nfet, nigfete, nigfetd, pfet, pigfete, pigfetd (contribution of Clemens
Helfmeier and Theodor Borsche)
7. njfet, pjfet (contribution of Danilo Piazzalunga)
8. pigbt, nigbt
9. backward incompatibility potentiometer is now the standard resistor-witharrow-in-the-middle; the old potentiometer is now known as variable
resistor (or vR), similarly to variable inductor and variable capacitor
55
56
coupler2, 26
csI, see controlled sinusoidal current
source
cspst, see closing switch
csV, see controlled sinusoidal voltage
source
currarrow, 29
cute inductor, see L
cvsourcesin, see controlled sinusoidal
voltage source
D*, see full diode
dac, 18
dcisource, 17
dcvsource, 17
detector, 19
Do, see empty diode
dsp, 18
empty diode, 13
empty led, 13
empty photodiode, 13
empty Schottky diode, 13
empty tunnel diode, 13
empty varcap, 13
empty Zener diode, 13
esource, 16
european and port, 27
european controlled current source,
20
european controlled voltage source,
19
european current source, 12
european gas filled surge arrester, 14
european inductor, see L
european nand port, 27
european nor port, 27
european not port, 27
european or port, 27
european potentiometer, see pR
european resistor, see R
european variable resistor, see vR
european voltage source, 12
european xnor port, 28
european xor port, 28
bandpass, 17
barrier, 14
battery, 12
battery1, 12
buffer, 29
C, see capacitor
capacitor, 15
cground, 7
circ, 29
circulator, 24
cisourcesin, see controlled sinusoidal
current source
closing switch, 17
controlled isourcesin, see controlled
sinusoidal current source
controlled sinusoidal current source,
20
controlled sinusoidal voltage source,
20
controlled vsourcesin, see controlled
sinusoidal voltage source
coupler, 26
fd op amp, 28
fft, 18
57
full diode, 13
full led, 14
full photodiode, 14
full Schottky diode, 13
full tunnel diode, 14
full varcap, 14
full Zener diode, 14
fullgeneric, 10
fuse, 11
generic, 9
gm amp, 28
ground, 7
gyrator, 26
highpass, 18
isfet, 23
isourcesin, see sinusoidal current
source
R, 10
rground, 7
rxantenna, 8
L, 15, 16
lamp, 9
leD*, see full led
leDo, see empty led
lowpass, 18
match, 8
memristor, 10
mixer, 24
Mr, see memristor
nfet, 22
nground, 7
nigbt, 21
nigfetd, 22
nigfete, 22
nigfetebulk, 22
njfet, 23
nmos, 21
npn, 21
tattenuator, 19
tD*, see full tunnel diode
tDo, see empty tunnel diode
tfullgeneric, 10
tgeneric, 9
thermistor, see thR
thermistor ntc, see thRn
thermistor ptc, see thRp
thermocouple, 11
thR, 11
thRn, 11
ocirc, 29
ohmmeter, 9
op amp, 28
open, 9
opening switch, 17
oscillator, 8
ospst, see opening switch
pC, see polar capacitor
58
thRp, 11
thyristor, 24
TL, 16
tline, see TL
tlinestub, 8
toggle switch, 24
Tr, see triac
transformer, 25
transformer core, 25
transmission line, see TL
triac, 24
twoport, 17
txantenna, 8
Ty, see thyristor
vamp, 18
variable american inductor, see vL
variable american resistor, see vR
variable capacitor, 15
variable cute inductor, see vL
variable european inductor, see vL
varistor, 11
wilkinson, 24
zD*, see full Zener diode
zDo, see empty Zener diode
59