← Back to blog

Blog & updates

TikZ Undefined control sequence on \\draw? Find the missing semicolon in 3 minutes

2026-05-21

Searching 'tikz undefined control sequence draw' usually means the previous line lacks a semicolon. Minimal examples, a 3-step checklist, and a DrawFig workflow to avoid syntax traps.

TikZ Undefined control sequence on \draw? Find the missing semicolon in 3 minutes

Published: 2026-05-21 Category: Tutorial / LaTeX figures Reading time: ~4 min Tags: TikZ compile errors, undefined control sequence, semicolon, drawfig, LaTeX figures
Error looks like this, but \draw is clearly correct?
! Undefined control sequence.
l.42 \draw (A) -- (B);
Many people edit line 42 — the real bug is often a missing semicolon ; at the end of line 41. This is the most common case behind searches like “tikz undefined control sequence draw” or “tikz missing semicolon”.
📌 Full overview of 7 error types: TikZ won't compile? Seven common errors and a DrawFig workflow

Why a missing semicolon makes \draw “undefined”

In TikZ, \node, \draw, \path, and similar commands usually end a path or node declaration with ;. TeX reads continuously: if the previous statement never closed, the next line's \draw is parsed as an illegal token inside that statement → Undefined control sequence, with the line number pointing at \draw.

Wrong

\begin{tikzpicture}
  \node (A) {A}          % ← missing semicolon
  \draw (A) circle (5pt); % error often reported here
\end{tikzpicture}

Correct

\begin{tikzpicture}
  \node (A) {A};         % ← semicolon required
  \draw (A) circle (5pt);
\end{tikzpicture}

3-step quick checklist

  1. Look at the line above the error — does it end with ;? (Comment lines with % excepted.)
  2. Try a minimal skeleton — keep only \node + one \draw; confirm the environment, then add complexity back.
  3. Binary search with comments — comment out half of tikzpicture, recompile, narrow to the statement missing ;.
Minimal compilable skeleton:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \node (A) at (0,0) {A};
  \draw (A) circle (3pt);
\end{tikzpicture}
\end{document}

Easy to confuse with “missing semicolon”

Symptom Might actually be
\end{tikzpicture} reported undefined Same as above, or unclosed environment
Error around right=of Missing \usetikzlibrary{positioning}tikzlibrary guide
Whole Overleaf project red Start with Overleaf TikZ checklist

DrawFig: write less code that forgets semicolons

In the DrawFig editor, drag or use AI — no need to type every \draw …;. When done, Export → TikZ and paste into your paper for one compile pass. Pricing: Canvas editing and SVG/PNG/PDF export are free, no sign-in. TikZ export costs 3 credits per use (sign-in required; 30 credits/day). See credits rules. Suggested flow: edit on canvas → export TikZ → compile standalone → merge into the main document.

Summary

  • Search undefined control sequence + draw → check the previous line for ; first.
  • Reported line numbers mislead — do not only edit \draw.
  • For other error types, see the hub post: 7 TikZ compile failure categories.