Tx · LaTeX & TikZ

How to Draw Dashed Short Circuits in CircuitikZ

Published By the 9to5Science editorial team

At a glance

  1. 1. Draw the wire

    Use CircuitikZ’s short element between the two coordinates.

  2. 2. Apply a TikZ style

    Put [dashed] after \draw to make that path dashed.

  3. 3. Separate mixed styles

    Use separate draw commands when neighboring wire segments need different styles.

  4. 4. Check the notation

    A dashed line changes the drawing, not the circuit’s electrical meaning.

To draw a dashed short-circuit connection in CircuitikZ, apply TikZ’s dashed style to the path containing the short. The basic form is \draw[dashed] (a) to[short] (b);, where (a) and (b) are the endpoints.

The example below shows solid wire segments on either side of a dashed short. It is a complete LaTeX document you can compile as-is.

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
  \draw (0,0) to[short] (2,0);
  \draw[dashed] (2,0) to[short] (4,0)
    node[midway, above] {virtual short};
  \draw (4,0) to[short] (6,0);
\end{circuitikz}

\end{document}

The middle path is dashed because [dashed] is an ordinary TikZ drawing option. The to[short] part tells CircuitikZ to draw a short connection between the endpoints. The label is optional; remove the node[...] text if you do not need it.

Why the style goes after \draw

In a command such as \draw[dashed] ..., TikZ applies the style to the path being drawn. CircuitikZ’s to[short] element is part of that path, so its line is dashed too. This is usually the clearest and most reliable way to style a short connection.

For a diagram containing only dashed shorts, you can apply the option to each relevant path:

\draw[dashed] (0,0) to[short] (2,0);
\draw[dashed] (2,0) to[short] (2,1);

When a path contains multiple elements but only one should be dashed, split it into separate \draw commands. For example, the worked document draws the first and last segments normally and the middle segment with [dashed]. This also makes it easier to adjust the dashed segment’s label or appearance without affecting adjacent wires.

Changing the dash pattern

The built-in dashed style uses a standard dash pattern. If you need a different pattern, use TikZ’s dash pattern option on the same path. For example:

\draw[dash pattern=on 3pt off 2pt] (0,0) to[short] (2,0);

Here, each dash is 3 points long, followed by a 2-point gap. TikZ also provides styles such as densely dashed and loosely dashed if you want a quick variation. These are drawing styles, so they belong in the path options, as in \draw[densely dashed] ....

Common mistakes

  • Putting dashed in the wrong place: Use \draw[dashed] (a) to[short] (b);. The option is a TikZ path style; putting it among the short-element options may not apply it as intended.
  • Styling an entire path by accident: If several wires and components are in one \draw[dashed] command, the style applies to the whole path. Use separate commands for solid and dashed parts.
  • Treating the dash as an electrical property: A dashed line is a visual convention, not a different kind of electrical connection. Label it or explain it in the figure if readers might mistake what it represents.
  • Using coordinates that do not meet: To make the dashed connection appear joined to solid wires, use exactly matching endpoint coordinates, as in the example’s (2,0) and (4,0).

A dashed short is therefore just a normal CircuitikZ short drawn with a TikZ dash style. The circuit notation you intend to communicate is up to you; the style itself does not define a special electrical meaning.

References

  1. CircuitikZ — CTAN package page and documentation

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