Tx · LaTeX & TikZ

How to Draw a Transformer in CircuitikZ

Published By the 9to5Science editorial team

At a glance

  1. 1. Load CircuitikZ

    Include the circuitikz package in your document preamble.

  2. 2. Place the symbol

    Create a named transformer node with node[transformer].

  3. 3. Connect the windings

    Use anchors A1, A2, B1, and B2 to draw wires to the four terminals.

  4. 4. Add labels

    Place voltage, current, or turns-ratio labels with ordinary TikZ nodes.

CircuitikZ draws a transformer as a four-terminal symbol: one pair of terminals for each winding. The practical approach is to place a named transformer node, then connect wires to its terminal anchors. This gives you direct control over the primary and secondary connections and avoids treating the transformer like a two-terminal resistor or inductor.

Minimal compilable example

The following document places a transformer between two pairs of wires and labels the winding voltages. Save it as a .tex file and compile it with a LaTeX engine that supports TikZ.

\documentclass[tikz,border=5pt]{standalone}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
  % Place and name the transformer.
  \draw (0,0) node[transformer] (T) {};

  % Connect to the two terminals of winding A.
  \draw (T.A1) -- ++(-1,0) node[left] {$v_1^+$};
  \draw (T.A2) -- ++(-1,0) node[left] {$v_1^-$};

  % Connect to the two terminals of winding B.
  \draw (T.B1) -- ++(1,0) node[right] {$v_2^+$};
  \draw (T.B2) -- ++(1,0) node[right] {$v_2^-$};
\end{circuitikz}
\end{document}

The circuitikz package loads the circuit-drawing tools, and standalone makes a compact output page. The statement node[transformer] (T) {} creates the symbol and assigns it the name T. The anchor names are then written with that name: T.A1, T.A2, T.B1, and T.B2.

In this example, the A terminals are on the left and the B terminals are on the right. A1 and B1 are the upper terminals; A2 and B2 are the lower ones. The ++ coordinates extend each wire from its terminal by one unit. Change the distance or direction to suit your drawing.

Add a turns ratio or other annotation

The transformer symbol does not require a turns-ratio label. Add one as normal TikZ text, positioned relative to the named node. For example, insert this inside the circuitikz environment:

\node[above=8mm] at (T) {$N_1:N_2=2:1$};

The value 2:1 is just an example; use the ratio appropriate to your circuit. You can similarly add current labels, winding names, or a note about the dot convention. Check that added text does not overlap the symbol or nearby wires.

Why use a node rather than to[transformer]?

The to[...] syntax is convenient for many components that have two ends along a path. A transformer has two separate windings, so it needs four connection points. Placing it as a named node gives you access to each terminal individually and makes it straightforward to connect the two sides independently.

This also makes a useful workflow for larger schematics: place the transformer first, then draw each circuit path to the appropriate anchor. You can route the wires around other components without changing how the transformer itself is drawn.

Common mistakes

  • Using the wrong connection syntax: Treating a transformer as a two-terminal to[transformer] component does not provide clear access to both windings. Use a named node[transformer] and its terminal anchors.
  • Leaving out the node name: If you write node[transformer] {} without (T), you cannot refer to the terminals as (T.A1) and so on. Give the node a name when you place it.
  • Mixing up the terminal pairs: A1 and A2 belong to one winding; B1 and B2 belong to the other. Connect each pair to its intended circuit, and verify upper and lower terminal placement in the compiled output.
  • Assuming the labels define polarity: Names such as $v_1^+$ and $v_2^+$ are just text. They do not set an electrical polarity or guarantee a particular dot convention. Show polarity explicitly if it matters to your analysis.
  • Forgetting the package: The document needs \usepackage{circuitikz} in its preamble. If the transformer style or anchors are reported as unknown, check the spelling and update an outdated CircuitikZ installation.

For a different layout, you can change the wire directions and label positions while keeping the same four anchors. Compile after adjusting the drawing to confirm that the chosen orientation and labels are clear.

References

  1. CTAN: CircuiTikZ package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.