# CircuiTikZ: drawing circuits in LaTeX

> Draw circuits in LaTeX with CircuiTikZ 1.8.7: the to[R=$R_1$] syntax, sources, switches, labels, ground, op-amps, transistors, logic gates, full examples.

URL: https://www.labcanvas.com/tikz/circuitikz

Updated 2026-11-22. Pictures typeset with TeX Live 2026 and PGF 3.1.12; each is made from the code under it, in a standalone document with the preamble lines shown. Code on this page: CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/), copy freely. Try any snippet in the TikZ editor: https://www.labcanvas.com/tools/tikz-editor

## Quick answer

Load `\usepackage{circuitikz}` (it loads TikZ) and draw inside `\begin{circuitikz} … \end{circuitikz}`. Two-terminal components sit on a path: `\draw (0,0) to[R=$R_1$] (2,0);` draws a resistor labelled *R* 1 between the two points, `to[C]`, `to[L]`, `to[V]`, `to[battery1]` or `to[spst]` work the same way, and `--` is plain wire. Parts with more pins (op-amps, transistors, logic gates, ground) are nodes, placed with `node[op amp] (OA) {}` and wired through anchors such as `(OA.out)`. Package options choose the symbols: `\usepackage[american]{circuitikz}` or `[european]`.

![Circuit: a voltage source V_in on the left with + on top, resistors R1 and R2 in series on the right, a junction between them leading to an open terminal V_out, another terminal at the bottom, and a ground symbol.](https://www.labcanvas.com/tikz-snippets/circuitikz/voltage-divider.webp)

*Voltage divider: a source and two resistors drawn with to[…], output terminals and ground*

Preamble: `\usepackage{tikz}`, `\usepackage[american, RPvoltages]{circuitikz}`

```latex
\begin{circuitikz}
  \draw (0,0) to[V, l=$V_\mathrm{in}$] (0,4)
        -- (2,4) to[R, l=$R_1$] (2,2)
        to[R, l=$R_2$] (2,0) -- (0,0);
  \draw (2,2) to[short, *-o] (4,2) node[right] {$V_\mathrm{out}$};
  \draw (2,0) to[short, *-o] (4,0);
  \draw (0,0) node[ground] {};
\end{circuitikz}
```

## Loading CircuiTikZ: package options and styles

CircuiTikZ (current version 1.8.7 of 2026-09-12, included in TeX Live and MiKTeX) loads TikZ and the TikZ libraries `calc`, `arrows.meta`, `bending` and `fpu`. The `circuitikz` environment is an alias of `tikzpicture`, so all TikZ commands work inside it. Without options you get a mix: American zig-zag resistors and logic ports, “cute” curly inductors, and European voltage and current sources. The options that matter, as named in the manual:

| Option | Effect |
| --- | --- |
| american | American currents, voltages (+/− signs), resistors (zig-zag), inductors (bumps), ports and surge arresters |
| european | The European versions of all of these: rectangle resistors, filled-rectangle inductors, voltage arrows, rectangular logic ports |
| RPvoltages, EFvoltages | Direction of voltages: arrows towards rising potential (RP) or along the electric field (EF). The default is the older nooldvoltagedirection; the manual advises choosing one explicitly |
| siunitx | Lets labels written 2<\ohm> mean \SI{2}{\ohm}. Marked experimental; the maintainers suggest plain \qty{2}{\ohm} from siunitx instead |
| americanresistors, europeanresistors, cuteinductors, americaninductors, europeaninductors, americanvoltages, europeanvoltages, straightvoltages, americancurrents, europeancurrents, americanports, europeanports | One family at a time |
| smartlabels (default), rotatelabels, straightlabels | Whether labels turn with the component |

The same names work as styles for one circuit or scope, `\begin{circuitikz}[european]`, so one document can mix them. Every example on this page that has voltage signs uses `[american, RPvoltages]`.

![Three rows of the same four components: default (zig-zag resistor, curly inductor, circle voltage and current sources), american (zig-zag, bumps, source with + and −, source with an arrow), european (rectangle resistor, filled rectangle inductor, circle sources).](https://www.labcanvas.com/tikz-snippets/circuitikz/styles.webp)

*R, L, V and I with the default options, american and european*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  % the same code, R, L, V and I, in three styles
  \draw (0,0) node[left] {default} to[R] ++(2,0) to[L] ++(2,0) to[V] ++(2,0) to[I] ++(2,0);
  \begin{scope}[american, yshift=-1.6cm]
    \draw (0,0) node[left] {\texttt{american}} to[R] ++(2,0) to[L] ++(2,0) to[V] ++(2,0) to[I] ++(2,0);
  \end{scope}
  \begin{scope}[european, yshift=-3.2cm]
    \draw (0,0) node[left] {\texttt{european}} to[R] ++(2,0) to[L] ++(2,0) to[V] ++(2,0) to[I] ++(2,0);
  \end{scope}
\end{circuitikz}
```

## The to[ ] syntax: components on a path

Two-terminal (“path-style”) components are drawn with TikZ’s `to` operation: `(a) to[⟨component⟩, ⟨options⟩] (b)` places the component in the middle of the segment from *a* to *b* and fills the rest with wire. The component itself keeps its size (`bipoles/length`, 1.4 cm by default), so a longer segment just means longer leads; `\ctikzset{bipoles/length=.8cm}` makes every component smaller.

- `to[R=$R_1$]` is short for `to[R, l=$R_1$]` on passive parts; on a voltage source it sets the voltage `v=`, on a current source the current `i=`.
- `to[short]` is a wire that can carry labels and poles, `to[open]` draws nothing but can carry a voltage.
- The direction of the path matters: labels are placed relative to it, and the polarity of sources and diodes follows it. To change a component’s orientation use `invert` and `mirror`, never `xscale=-1` or `yscale=-1` (the manual warns that they mess up the path); `invert` is the one that swaps the + and − of a source.
- `name=D1` (or `n=D1`) names a component, so you can connect to its anchors later.

Names are case-sensitive and short: `R`, `vR` (variable), `pR` (potentiometer), `C`, `eC` (electrolytic), `L`, `D`, `leD` (LED), `lamp`, `fuse`; chapter 4 of the manual lists every one with its aliases and anchors.

![Grid of circuit symbols with their names: R (zig-zag resistor), vR (variable resistor), pR (potentiometer), C (capacitor), eC (electrolytic capacitor), L (inductor), D (diode), leD (LED), lamp.](https://www.labcanvas.com/tikz-snippets/circuitikz/components.webp)

*Common passive components and the names that draw them*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  \draw (0,0)    to[R, l_=\texttt{R}]       ++(2,0);
  \draw (3,0)    to[vR, l_=\texttt{vR}]     ++(2,0);
  \draw (6,0)    to[pR, l_=\texttt{pR}]     ++(2,0);
  \draw (0,-1.8) to[C, l_=\texttt{C}]       ++(2,0);
  \draw (3,-1.8) to[eC, l_=\texttt{eC}]     ++(2,0);
  \draw (6,-1.8) to[L, l_=\texttt{L}]       ++(2,0);
  \draw (0,-3.6) to[D, l_=\texttt{D}]       ++(2,0);
  \draw (3,-3.6) to[leD, l_=\texttt{leD}]   ++(2,0);
  \draw (6,-3.6) to[lamp, l_=\texttt{lamp}] ++(2,0);
\end{circuitikz}
```

## Voltage and current sources

`V` (also `vsource`) and `I` (`isource`) follow the chosen style: a circle crossed along the wire (European voltage), across it (European current), +/− signs or an arrow (American). To get one style whatever the options, use the explicit names `vsourceAM` and `isourceAM` (American) or `vsourceEU` and `isourceEU` (European). Also available: `sV` and `sI` (sinusoidal), `dcvsource` and `dcisource`, the batteries `battery1` (one cell), `battery` (two cells) and `battery2`, and the controlled (dependent) sources `cV` and `cI`, drawn as diamonds.

**Polarity.** Where the + of a source or the long plate of a battery ends up depends on the direction you draw it *and* on the voltage-direction option. With `RPvoltages` the + is at the end of the path, so a source drawn upwards from ground, `(0,0) to[V] (0,4)`, has its + on top, as in the voltage divider above. With the default `nooldvoltagedirection` the same code puts the + at the bottom (the catalogue below uses the default options). Add `invert` to turn one source round.

![Grid of source symbols with names: V, vsourceAM, sV, dcvsource, battery1, battery, battery2, cV (diamond), I, isourceAM, sI, cI (diamond).](https://www.labcanvas.com/tikz-snippets/circuitikz/sources.webp)

*Voltage, current, sinusoidal, DC, battery and controlled sources*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  \draw (0,0)    to[V, l_=\texttt{V}]                 ++(2,0);
  \draw (3,0)    to[vsourceAM, l_=\texttt{vsourceAM}] ++(2,0);
  \draw (6,0)    to[sV, l_=\texttt{sV}]               ++(2,0);
  \draw (9,0)    to[dcvsource, l_=\texttt{dcvsource}] ++(2,0);
  \draw (0,-1.8) to[battery1, l_=\texttt{battery1}]   ++(2,0);
  \draw (3,-1.8) to[battery, l_=\texttt{battery}]     ++(2,0);
  \draw (6,-1.8) to[battery2, l_=\texttt{battery2}]   ++(2,0);
  \draw (9,-1.8) to[cV, l_=\texttt{cV}]               ++(2,0);
  \draw (0,-3.6) to[I, l_=\texttt{I}]                 ++(2,0);
  \draw (3,-3.6) to[isourceAM, l_=\texttt{isourceAM}] ++(2,0);
  \draw (6,-3.6) to[sI, l_=\texttt{sI}]               ++(2,0);
  \draw (9,-3.6) to[cI, l_=\texttt{cI}]               ++(2,0);
\end{circuitikz}
```

## Switches and push buttons

- `spst` (alias of `switch`) is drawn as a closing switch with an arrow, the same symbol as `cspst`; `ospst` is the opening switch. For the plain symbols use `nos` (normally open) and `ncs` (normally closed); `cnos`, `onos`, `cncs`, `oncs` add the closing/opening arrow.
- Push buttons: `nopb` (or `push button`), `ncpb`, and `nopbc` / `ncpbo` for the same buttons drawn in their operated position.
- “Cute” switches with round contacts: `cosw` (open), `ccsw` (closed), `cogsw` / `ccgsw` (opening/closing).
- Single-pole double-throw switches are nodes: `node[spdt] (S) {}` with anchors `S.in`, `S.out 1`, `S.out 2`, or `cute spdt up`, `cute spdt mid`, `cute spdt down`. There is also a path-style `toggle switch`, rotary switches and jumpers.

![Grid of switch symbols with names: spst and ospst with arrows, nos, ncs, push buttons nopb and ncpb, cute open and closed switches cosw and ccsw, and two single-pole double-throw switches with in, out 1 and out 2 labelled.](https://www.labcanvas.com/tikz-snippets/circuitikz/switches.webp)

*Switches, push buttons, cute switches and SPDT switches with their anchors*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  \draw (0,0)    to[spst, l_=\texttt{spst}]       ++(2,0);
  \draw (3,0)    to[nos, l_=\texttt{nos}]         ++(2,0);
  \draw (6,0)    to[ncs, l_=\texttt{ncs}]         ++(2,0);
  \draw (9,0)    to[ospst, l_=\texttt{ospst}]     ++(2,0);
  \draw (0,-1.8) to[nopb, l_=\texttt{nopb}]       ++(2,0);
  \draw (3,-1.8) to[ncpb, l_=\texttt{ncpb}]       ++(2,0);
  \draw (6,-1.8) to[cosw, l_=\texttt{cosw}]       ++(2,0);
  \draw (9,-1.8) to[ccsw, l_=\texttt{ccsw}]       ++(2,0);
  % single-pole double-throw switches are nodes with anchors
  \draw (1,-3.8) node[spdt] (S) {} (S.in) node[left] {\texttt{in}}
        (S.out 1) node[right] {\texttt{out 1}} (S.out 2) node[right] {\texttt{out 2}};
  \node at (1,-5.1) {\texttt{spdt}};
  \draw (7,-3.8) node[cute spdt up] (T) {} (T.in) node[left] {\texttt{in}}
        (T.out 1) node[right] {\texttt{out 1}} (T.out 2) node[right] {\texttt{out 2}};
  \node at (7,-5.1) {\texttt{cute spdt up}};
\end{circuitikz}
```

## Labels, annotations, voltages and currents

Every path-style component takes these keys; `_` or `^` after the key puts the text below or above (relative to the drawing direction):

| Key | Draws |
| --- | --- |
| l= | Label, above by default (the name, e.g. $R_1$) |
| a= | Annotation, below by default (the value) |
| v= | Voltage: +/− signs with American voltages, a curved arrow with European ones ( straight voltages and raised voltages are the other styles); v<= / v>= reverse it |
| i= | Current arrow on the wire: i_>, i^<, i>_ … choose side ( ^ _) and direction ( > <); the order of the two characters picks the lead before or after the component |
| f= | Flow arrow beside the wire, with the same modifiers |

The default direction of `v` and `i` differs between passive parts and sources and depends on the voltage-direction option, so check the first circuit you draw. Labels that contain `=` or `,` must be braced, `to[R={$R_1=10\,\Omega$}]`, or the option parser splits them. `l2=… and …` stacks a label on two lines. For the voltage between two terminals that are not joined by a component, draw `to[open, v=…]` between them, as in the RC filter below.

![Six resistors: R1 with 1 kΩ below; 2.2 kΩ above with R2 below; v1 with + and − signs and a current arrow i1; v2 reversed with a current arrow i2 pointing left; a curved voltage arrow v3; a flow arrow i4 below the wire.](https://www.labcanvas.com/tikz-snippets/circuitikz/labels.webp)

*l and a labels, American voltages and currents (v, i), a European voltage arrow and a flow (f)*

Preamble: `\usepackage{tikz}`, `\usepackage[american, RPvoltages]{circuitikz}`

```latex
\begin{circuitikz}
  % l = label, a = annotation; _ and ^ choose the side
  \draw (0,0) to[R, l=$R_1$, a=$1\,\mathrm{k\Omega}$] ++(3,0);
  \draw (4,0) to[R, l_=$R_2$, a^=$2.2\,\mathrm{k\Omega}$] ++(3,0);
  % v = voltage, i = current; > or < reverses the default direction
  \draw (0,-2.2) to[R, v=$v_1$, i=$i_1$] ++(3,0);
  \draw (4,-2.2) to[R, v>=$v_2$, i^<=$i_2$] ++(3,0);
  % european-style voltage arrow and a flow arrow f
  \begin{scope}[european voltages, yshift=-4.4cm]
    \draw (0,0) to[R, v=$v_3$] ++(3,0);
    \draw (4,0) to[R, f>_=$i_4$] ++(3,0);
  \end{scope}
\end{circuitikz}
```

## Poles (connection dots) and ground

The pole shortcuts go in the options of a component or a `short`: `*` is a filled dot (a junction), `o` an open circle (a terminal), `d` a diamond; `-*` puts one at the end only, `o-` at the start, `*-o` both. The general form is `bipole nodes={circ}{ocirc}`. Poles are added after the path is drawn and open ones are filled white, so draw a pole in the same `\draw` as the wires it covers. A dot on its own is `node[circ] {}`.

Grounds and supply rails are nodes whose anchor is the connection point: `node[ground] {}`, `rground`, `sground` (signal), `tlground` (tailless), `tground`, `nground`, `pground` (protective), `cground` (chassis), `eground` and `eground2` (European); `vcc` and `vee` for supply arrows.

![Resistors with open and filled end dots labelled o-o, *-* and o-*, a wire ending in an open terminal, and a row of ground symbols ground, rground, sground, tlground, cground, eground plus vcc and vee arrows.](https://www.labcanvas.com/tikz-snippets/circuitikz/poles-ground.webp)

*Poles (o-o, *-*, o-*) and ground, vcc and vee symbols*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  % poles at the ends of a component: o open, * filled, d diamond
  \draw (0,0) to[R, o-o, l=\texttt{o-o}] ++(2.4,0);
  \draw (3.2,0) to[R, *-*, l=\texttt{*-*}] ++(2.4,0);
  \draw (6.4,0) to[R, o-*, l=\texttt{o-*}] ++(2.4,0);
  \draw (9.6,0) to[short, -o, l=\texttt{short, -o}] ++(1.6,0);
  % grounds and supply rails are nodes: their anchor is where the wire connects
  \foreach \s [count=\i] in {ground, rground, sground, tlground, cground, eground} {
    \draw (1.6*\i-1.4,-1.4) node[above, font=\ttfamily\small] {\s} -- ++(0,-0.6) node[\s] {};
  }
  \draw (10,-2) node[vcc] {} -- ++(0,-0.5) node[below, font=\ttfamily\small] {vcc};
  \draw (11.2,-1.4) -- ++(0,-0.6) node[vee] {};
  \node[above, font=\ttfamily\small] at (11.2,-1.4) {vee};
\end{circuitikz}
```

## Op-amps

`node[op amp] (OA) {}` draws an operational amplifier with the anchors `OA.-` (inverting input), `OA.+`, `OA.out`, and `OA.up` / `OA.down` for the supplies. The inverting input is on top by default; `noinv input up` swaps the inputs. Other amplifiers: `en amp` (DIN/EN 60617 box), `fd op amp` (fully differential), `inst amp`, `gm amp`, `plain amp`, `buffer`.

In the inverting amplifier below, the input resistor ends at a `coordinate (J)` (a named point, not a node, so wires join without gaps) and `(T -| OA.out)` is the point above the output: x of `OA.out`, y of `T`.

![Op-amp circuit: v_in through R_in to the inverting input, feedback resistor R_f from the output back to the inverting input over the top, non-inverting input to ground, output to a terminal v_out, and the formula v_out = −R_f/R_in · v_in.](https://www.labcanvas.com/tikz-snippets/circuitikz/inverting-amplifier.webp)

*Inverting amplifier with an op amp node: anchors -, + and out*

Preamble: `\usepackage{tikz}`, `\usepackage[american, RPvoltages]{circuitikz}`

```latex
\begin{circuitikz}
  % op amp node: anchors -, + and out (the inverting input is on top)
  \draw (0,0) node[op amp] (OA) {};
  \draw (OA.-) ++(-3,0) node[left] {$v_\mathrm{in}$}
        to[R, l=$R_\mathrm{in}$, o-*] ++(2.4,0) coordinate (J) -- (OA.-);
  \draw (J) -- ++(0,1.5) coordinate (T)
        to[R, l=$R_\mathrm{f}$] (T -| OA.out) -- (OA.out);
  \draw (OA.out) to[short, *-o] ++(1,0) node[right] {$v_\mathrm{out}$};
  \draw (OA.+) -- ++(-0.6,0) -- ++(0,-0.6) node[ground] {};
  \node at (0,-1.8) {$v_\mathrm{out} = -\frac{R_\mathrm{f}}{R_\mathrm{in}}\,v_\mathrm{in}$};
\end{circuitikz}
```

## Transistors

Transistors are nodes. Bipolar `npn` and `pnp` have the anchors `B`, `C`, `E` (or `base`, `collector`, `emitter`); `nmos`, `pmos`, `nfet`, `pfet`, `nigfete` and the other MOSFETs have `G`, `D`, `S` (`gate`, `drain`, `source`), `njfet` / `pjfet` also have `G`, `D`, `S`, and `nigbt` / `pigbt` have `B`, `C`, `E`. Put a `T` in front to use one on a path, `to[Tnmos]`, with the gate at right angles to the path. Package options such as `arrowmos` and `fetbodydiode` change the MOSFET symbols.

![Four transistor symbols labelled npn and pnp with B, C, E at their terminals, and nmos and pmos with G, D, S at their terminals.](https://www.labcanvas.com/tikz-snippets/circuitikz/transistors.webp)

*npn, pnp, nmos and pmos nodes with their anchors*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}[font=\small]
  \foreach \t/\x in {npn/0, pnp/2.6} {
    \draw (\x,0) node[\t] (Q) {}
      (Q.B) node[left] {B} (Q.C) node[right] {C} (Q.E) node[right] {E};
    \node at (\x,-1.3) {\texttt{\t}};
  }
  \foreach \t/\x in {nmos/5.2, pmos/7.8} {
    \draw (\x,0) node[\t] (M) {}
      (M.G) node[left] {G} (M.D) node[right] {D} (M.S) node[right] {S};
    \node at (\x,-1.3) {\texttt{\t}};
  }
\end{circuitikz}
```

## Logic gates: American, European and IEEE ports

Logic gates are nodes named `and port`, `or port`, `nand port`, `nor port`, `xor port`, `xnor port`, `not port` and `buffer port`, with the anchors `in 1`, `in 2` (more with `number inputs=4`) and `out`. By default they use the legacy American shapes; the `europeanports` option gives the rectangular IEC ones. Since version 1.1.0 there is also a set drawn to the proportions of IEEE Std 91a-1991: write `ieeestd and port`, or set `\ctikzset{logic ports=ieee}` to make `and port` mean the IEEE shape. IEEE gates keep their proportions when resized and are sized to line up with the chip components; placed with `anchor=in 1` they stack neatly, as in the half adder further down.

![Two rows of logic gate symbols: and, or, xor, nand and not ports in the legacy American shapes, and below them the ieeestd versions with IEEE proportions.](https://www.labcanvas.com/tikz-snippets/circuitikz/logic-gates.webp)

*Legacy (American) logic ports and the IEEE Std 91a ports*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}[font=\small\ttfamily]
  \foreach \p [count=\i] in {and port, or port, xor port, nand port, not port} {
    % legacy (american) shapes: the default
    \node[\p] at (2.6*\i,0) {};
    \node at (2.6*\i,-0.9) {\p};
    % IEEE Std 91a shapes: prefix ieeestd (or \ctikzset{logic ports=ieee})
    \node[ieeestd \p] at (2.6*\i,-2.2) {};
    \node[align=center] at (2.6*\i,-3.3) {ieeestd\\\p};
  }
\end{circuitikz}
```

## Complete circuits: RC low-pass filter and half adder

A few habits make circuits easy to adjust: start from one absolute point and continue with relative coordinates (`++(2,0)`); name the points you reuse with `coordinate`; line things up with `|-` and `-|`; and write values with siunitx’s `\qty`. The RC filter’s corner frequency, 1/(2π · 1 kΩ · 100 nF), is about 1.59 kHz.

![Circuit: sinusoidal source v_in, series resistor R of 1 kΩ, capacitor C of 100 nF to the bottom wire, output terminals with + and − and v_out, and the formula f_c = 1/(2πRC) ≈ 1.59 kHz.](https://www.labcanvas.com/tikz-snippets/circuitikz/rc-lowpass.webp)

*RC low-pass filter with siunitx values and the output voltage between two terminals*

Preamble: `\usepackage{tikz}`, `\usepackage{siunitx}`, `\usepackage[american, RPvoltages]{circuitikz}`

```latex
\begin{circuitikz}
  \draw (0,0) to[sV, l=$v_\mathrm{in}$] (0,3)
        to[R, l=$R$, a=\qty{1}{\kilo\ohm}] (3,3)
        to[C, l=$C$, a=\qty{100}{\nano\farad}, *-*] (3,0) -- (0,0);
  \draw (3,3) to[short, -o] (5,3)
        (3,0) to[short, -o] (5,0);
  % the output voltage between two open terminals
  \draw (5,3) to[open, v^=$v_\mathrm{out}$] (5,0);
  \node at (2.5,-0.9) {$f_c = \frac{1}{2\pi RC} \approx \qty{1.59}{\kilo\hertz}$};
\end{circuitikz}
```

![Logic circuit: inputs A and B feed an XOR gate giving S = A ⊕ B and, through branches with junction dots, an AND gate giving C = AB.](https://www.labcanvas.com/tikz-snippets/circuitikz/half-adder.webp)

*Half adder with IEEE gates aligned on anchor=in 1*

Preamble: `\usepackage{tikz}`, `\usepackage{circuitikz}`

```latex
\begin{circuitikz}
  \ctikzset{logic ports=ieee}
  % anchor=in 1 keeps the gates aligned on their first input
  \draw (0,0) node[xor port, anchor=in 1] (X) {}
        (0,-1.6) node[and port, anchor=in 1] (Y) {};
  \draw (X.in 1) -- ++(-2.2,0) node[left] {$A$}
        (X.in 2) -- ++(-2.2,0) node[left] {$B$};
  \draw (X.in 1) ++(-1.6,0) node[circ] {} |- (Y.in 1)
        (X.in 2) ++(-1,0) node[circ] {} |- (Y.in 2);
  \draw (X.out) -- ++(0.8,0) node[right] {$S = A \oplus B$}
        (Y.out) -- ++(0.8,0) node[right] {$C = AB$};
\end{circuitikz}
```

## The CircuiTikZ manual

The official manual is the [CircuiTikZ manual on CTAN](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf) (PDF, about 300 pages, version 1.8.7); `texdoc circuitikz` opens the copy installed with your TeX distribution. The parts you will use most:

- §1.12 package options, §2 four tutorials (current shunt, non-inverting amplifier, transistor amplifier, logic circuit);
- §4 the complete list of components with every name, alias and anchor;
- §5 labels, voltages, currents and flows; §6.1 poles; §8 FAQ (gaps in wires, dashed wires, externalization, scaling).

Check the version you have with `\pgfcircversion`. If an update changes an old circuit, the package can roll back: `\usepackage{circuitikz}[=v1.7.2]` (eleven old versions, from 0.4 to 1.7.2, are kept). Questions go to the `circuitikz` tag on TeX Stack Exchange, bugs to the project’s GitHub issues.

## CircuiTikZ designer and other editors

- [CircuiTikZ Designer](https://circuit2tikz.tf.fau.de/designer/), from the Institute for Electronics Engineering at FAU Erlangen-Nürnberg, is a free browser application for drawing circuits with most CircuiTikZ components and right-angled wires; it exports CircuiTikZ code. The manual also mentions Heaviside, a desktop editor from the University of Colorado Colorado Springs that generates CircuiTikZ code with a live preview.
- The [LabCanvas TikZ editor](https://www.labcanvas.com/tools/tikz-editor) works from code: paste a `circuitikz` environment, with the package already loaded, and it is typeset with TeX Live as you type, the same renderer as the pictures on this page. Code exported from a designer can be finished there by hand.
- “TikZ circuit” can also mean TikZ’s own circuit libraries (`circuits.ee.IEC`, `circuits.logic.US` and others, §49 of the PGF manual), a separate system with its own syntax. They define some of the same style names as CircuiTikZ, so to load both use the `compatibility` package option, after which CircuiTikZ’s path components take an asterisk: `to[*R]`.

## Common errors and how to fix them

| LaTeX says (or you see) | Cause and fix |
| --- | --- |
| LaTeX Error: Environment circuitikz undefined. | Add `\usepackage{circuitikz}` to the preamble. |
| Package pgfkeys Error: I do not know the key '/tikz/R', to which you passed '$R_1$', and I am going to ignore it. | CircuiTikZ is not loaded (only TikZ is), or the component name is misspelt; names are case-sensitive (`R`, not `r`). |
| Extra }, or forgotten $. | A label contains `=` or `,`, as in `to[R=$R_1=10\,\Omega$]`. Brace it: `to[R={$R_1=10\,\Omega$}]`. |
| Undefined control sequence (in a label such as l=2) | The `<…>` unit syntax needs the `siunitx` package option. Better: `\usepackage{siunitx}` and `l=\qty{2}{\kilo\ohm}`. |
| Gaps in the wires at a named point | The point was named with an empty `node`, which has a size. Name points with `coordinate (A)` instead (manual FAQ 8.1). |
| A dashed or coloured wire makes the whole path dashed or coloured | Colour and dash options apply to an entire path. Draw that wire as a separate `\draw`, or as an `edge[dashed]` (manual FAQ 8.2). |
| ! Emergency stop. (with \tikzexternalize) | The externalization library expects pictures to end with `\end{tikzpicture}`: use `tikzpicture` instead of the `circuitikz` environment (manual FAQ 8.3). |
| The circuit is garbled after yscale=-1, rotate=… or unequal xscale/yscale | Global negative scaling, rotation and non-uniform scaling are not supported (manual §1.8). Flip single components with `mirror` or `invert`, and scale the whole circuit with `scale=…, transform shape` or `\scalebox`. |

## Frequently asked questions

### How do I draw a circuit in LaTeX?

Use CircuiTikZ: `\usepackage{circuitikz}`, then `\begin{circuitikz} \draw (0,0) to[V] (0,2) to[R=$R$] (2,2) to[C=$C$] (2,0) -- (0,0); \end{circuitikz}`. Each `to[…]` puts a component on the segment between two points.

### How do I draw a voltage source in CircuiTikZ?

`to[V]` draws the source of the current style (European by default; load `[american]` for the +/− symbol), `vsourceAM` always draws the American one, `battery1` a battery cell and `sV` an AC source. The + follows the drawing direction and the voltage option; with `RPvoltages` it is at the end of the path, and `invert` turns it round.

### How do I draw a switch in CircuiTikZ?

On a path: `to[nos]` (normally open), `to[ncs]` (normally closed), `to[spst]` (closing switch with arrow), `to[nopb]` (push button), `to[cosw]` (cute open switch). A changeover switch is a node: `node[spdt] (S) {}` with anchors `S.in`, `S.out 1`, `S.out 2`.

### Where is the CircuiTikZ manual?

On CTAN as a PDF (circuitikzmanual.pdf, linked below), and on your computer with `texdoc circuitikz`. Chapter 4 lists every component name and anchor.

### How do I make the components smaller or the circuit bigger?

`\ctikzset{bipoles/length=.8cm}` changes the size of all two-terminal components (default 1.4 cm) without changing your coordinates. To scale everything, use `\begin{circuitikz}[scale=.8, transform shape]`, or `\scalebox` for large factors.

### Is there a CircuiTikZ designer or GUI?

Yes: CircuiTikZ Designer (circuit2tikz.tf.fau.de/designer) is a free browser tool that exports CircuiTikZ code. To edit the code and see the result immediately, use the LabCanvas TikZ editor, which typesets circuitikz with TeX Live.

## References

- [CircuiTikZ package on CTAN (v1.8.7, 2026-09-12)](https://ctan.org/pkg/circuitikz)
- [CircuiTikZ manual (PDF on CTAN)](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf)
- [CircuiTikZ manual, §1.12 Package options](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=18)
- [CircuiTikZ manual, §2 Tutorials](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=22)
- [CircuiTikZ manual, §3.1 Path-style components](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=36)
- [CircuiTikZ manual, §4.1 Grounds and supply voltages](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=56)
- [CircuiTikZ manual, §4.5 Sources and generators](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=78)
- [CircuiTikZ manual, §4.15 Transistors](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=126)
- [CircuiTikZ manual, §4.20 Amplifiers](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=170)
- [CircuiTikZ manual, §4.21 Switches, buttons and jumpers](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=177)
- [CircuiTikZ manual, §4.22 Logic gates](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=188)
- [CircuiTikZ manual, §5 Labels, voltages and currents](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=222)
- [CircuiTikZ manual, §6.1 Nodes (poles)](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=254)
- [CircuiTikZ manual, §8 FAQ](https://mirrors.ctan.org/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf#page=265)
- [PGF/TikZ manual, §14.13 The To Path Operation](https://tikz.dev/tikz-paths#sec-14.13)
- [PGF/TikZ manual, §13.3.1 Intersections of Perpendicular Lines (-| and |-)](https://tikz.dev/tikz-coordinates#sec-13.3.1)
- [PGF/TikZ manual, §49 Circuit Libraries](https://tikz.dev/library-circuits)
- [CircuiTikZ Designer (FAU)](https://circuit2tikz.tf.fau.de/designer/)

## More TikZ guides

- [TikZ: what it is and how to use it in LaTeX](https://www.labcanvas.com/tikz): What TikZ (PGF/TikZ) is and how to use it in LaTeX: the minimal document, libraries, coordinates, a first figure in steps, Overleaf and TeX Live.
- [The tikzpicture environment: options, scaling and centring](https://www.labcanvas.com/tikz/tikzpicture): The tikzpicture environment: its options, scale vs transform shape vs \resizebox, centring it in a figure with a caption, and inline TikZ with baseline.
- [TikZ lines: dashed, dotted, thickness and line width](https://www.labcanvas.com/tikz/lines): TikZ lines: dashed and dotted styles with their exact patterns, ultra thin to ultra thick widths, dash pattern, caps and joins, double lines, grids.
- [TikZ arrows: arrow tips, sizes, curves and labels](https://www.labcanvas.com/tikz/arrows): All TikZ arrow tips in one rendered table, arrows.meta sizing (length, width, scale, open, round), and curved, labelled, thick, block and squiggly arrows.
- [TikZ examples: 179 figures with code, by field](https://www.labcanvas.com/tikz/examples): A gallery of 179 TikZ and pgfplots figures with their full code, from open-source collections (MIT or CC0): physics, maths, machine learning, plots, diagrams.
- [The PGF/TikZ manual: where to find it and which part to read](https://www.labcanvas.com/tikz/manual): Where the official PGF/TikZ manual is (CTAN PDF, texdoc tikz, the tikz.dev HTML edition), which version it describes, and which section to read for each task.
