What circuitikz does
circuitikz is a package that builds on TikZ to draw electrical and electronic circuits. You draw wires with coordinates and place components with a to[...] path, which takes a component name and optional labels. The code stays short, and you control the layout.
Load circuitikz
\usepackage{circuitikz}
Pass american or european as an option to choose the symbol style, for example \usepackage[american]{circuitikz}. Use the style your course, lab, or journal expects.
Draw your first circuit
This series loop has a battery, a resistor, and a capacitor:
\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[battery1, l=$V_s$] (0,3)
-- (2,3) to[R, l=$R$] (4,3)
-- (4,0) to[C, l=$C$] (2,0)
-- (0,0);
\end{circuitikz}
\end{document}
Read the path from left to right. It starts at (0,0), goes up through the battery to (0,3), runs right to (2,3), passes through the resistor to (4,3), then goes down to (4,0). From there it passes through the capacitor back to (2,0) and returns to the start. l= puts a label beside the component.
Component names you will use most
| Component | Name | Example |
|---|---|---|
| Resistor | R |
to[R, l=$R$] |
| Capacitor | C |
to[C, l=$C$] |
| Inductor | L |
to[L, l=$L$] |
| Battery | battery1 |
to[battery1, l=$V_s$] |
| Voltage source | V |
to[V, l=$V$] |
| Current source | I |
to[I, l=$I$] |
| Plain wire | short |
to[short] |
| Ground | ground (a node, not a to component) |
\draw (0,0) node[ground] {}; |
Most components go inside to[...]. Ground is a node, so you place it with node[ground] at a point.
Add labels, voltages, and currents
Three keys annotate a component:
l=puts a label beside the component. Usel_=to place it on the other side.v=draws a voltage arrow across the component.i=draws a current arrow along the component.
\draw (0,0) to[R, l=$R$, v=$V_R$, i=$I_R$] (3,0);
Connect branches with coordinates
Parallel branches come from drawing a path between two wires. This example places two resistors between a top wire and a bottom wire:
\begin{circuitikz}
\draw (0,0) to[battery1, l=$V_s$] (0,3) -- (4,3);
\draw (0,0) -- (4,0);
\draw (2,3) to[R, l=$R_1$] (2,0);
\draw (4,3) to[R, l=$R_2$] (4,0);
\end{circuitikz}
If your circuit needs a junction dot where a branch meets a wire, add one with \node[circ] at (x,y) {};.
Common problems
- The
to[...]path gives an error. Path commands liketo[...]only work insidecircuitikzortikzpicture. Wrap the code in\begin{circuitikz}and\end{circuitikz}. - A label overlaps a wire or another label. Move it to the other side with
l_=, or shorten it. - A component is missing. Check its name against the table above. An unknown name produces an error in the log.
Frequently asked questions
Is circuitikz part of TikZ?
No. circuitikz is a separate package that uses TikZ to draw. Loading circuitikz also loads TikZ, so you do not need to load it yourself.
Which package should I use for block diagrams?
Use TikZ for block diagrams and flowcharts, and circuitikz for electrical schematics. The block diagrams and flowcharts guide covers TikZ basics.