A guide to TikZ compile failures — undefined control sequence, missing tikzlibrary, xcolor clashes, LuaLaTeX — with fixes and a DrawFig visual-first + TikZ export path.
TikZ won't compile? Seven common errors, a checklist, and a DrawFig workflow
Published: 2026-05-20
Category: Tutorial / LaTeX figures
Reading time: ~12 min
Tags: TikZ compile errors, undefined control sequence, tikzlibrary, xcolor, LuaLaTeX, Overleaf, drawfig, academic figures
If you search for
“tikz compile failed” or
“undefined control sequence tikz”, you probably do not want a lecture on aesthetics — you want the PDF to build
after you already spent time on the figure.
These problems are everywhere: tutorials paste a
tikzpicture fragment without listing libraries; Stack Exchange answers assume LuaLaTeX while your project still uses pdfLaTeX; the log points at line 80 while the missing semicolon is on line 52. This post maps
real search intent to TikZ pain points and shows when
DrawFig (
drawfig.com) helps — draw visually first, export compilable TikZ, and keep “compile hell” off the critical path.
1 — Why “TikZ compile problems” dominate long-tail search
TikZ is not a standalone program; it sits on the LaTeX macro stack. Any layer can fail, and the symptom is always “the whole paper won't build” even when the root cause is a library, engine, or punctuation issue.
| Pain type |
Typical symptom |
Why people search |
| Syntax / punctuation |
Missing ;, unbalanced brackets |
Errors look like Undefined control sequence, not “forgot semicolon” |
| Library not loaded |
\node[cloud] fails |
Features live in dozens of tikzlibrary files with no IDE hint |
| Wrong engine |
graphdrawing silently fails |
Tutorial says LuaLaTeX; local setup is still pdfLaTeX |
| Package clash |
Option clash for package xcolor |
Beamer / tikz / journal templates load xcolor twice |
| Coordinates / paths |
Figure off-page or blank |
PGF transforms shift error line numbers |
| Environment nesting |
tikzpicture in wrong place |
Floats, subfigures, standalone mixed together |
| Time cost |
Hours on one figure |
People search “what do I do?” not “how do I draw?” |
Below: the
error phrases people actually paste into search, with causes, self-help fixes, and when to use DrawFig instead of hand-written code.
2 — Seven high-frequency compile errors (with fixes)
2.1 Undefined control sequence … \draw / \end{tikzpicture}
Most likely causes (by frequency):
- Missing semicolon on the previous line — In TikZ, almost every
\draw, \node, and \path must end with ;. Without it, TeX treats the next \draw as an undefined command.
- No
\usepackage{tikz}, or code pasted outside a proper tikzpicture environment.
- Unbalanced brackets or quotes — e.g.
{$\bullet$) with a closing parenthesis instead of }.
- Syntax that needs a library — e.g.
right=of A requires \usetikzlibrary{positioning}.
Quick check:
% Minimal compilable skeleton — confirm the environment first
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}
\node (A) {A};
\node (B) [right=of A] {B};
\draw (A) -- (B); % ← note the semicolon
\end{tikzpicture}
\end{document}
If the skeleton compiles but your snippet does not,
comment out half and recompile (binary search) — faster than trusting the reported line number.
2.2 Undefined control sequence … \usetikzlibrary{graphdrawing} / \usegdlibrary
Cause: Force-directed, layered, and other
automatic layout features belong to the
LuaTeX graph layout engine. pdfLaTeX / XeLaTeX report undefined commands.
Fix:
- Overleaf: Menu → Compiler → LuaLaTeX
- Local TeX:
lualatex main.tex
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{layered, force} % LuaLaTeX only
If you do not need auto-layout: drop
graphdrawing, place nodes manually, or lay out in DrawFig and export TikZ.
2.3 Option clash for package xcolor
Cause: tikz, Beamer,
pgfplots, and journal templates all touch
xcolor with
inconsistent options (e.g.
[dvips] vs
[xetex]).
Common fix:
% After \documentclass, before other packages — match engine
\usepackage[xetex]{xcolor} % XeLaTeX; pdfLaTeX → pdftex; LuaLaTeX → luatex
\usepackage{tikz}
Do not
\usepackage{xcolor} multiple times with different options.
2.4 cloud / diamond / chamfered rectangle still fail
Cause: Shapes live in
sub-libraries; the main package does not load them automatically.
| Shape |
Library |
Cloud cloud |
shapes.symbols |
Diamond diamond |
shapes.geometric |
| Chamfered rectangle, etc. |
shapes.misc |
Relative placement right=of |
positioning |
Coordinate math ($(A)!0.5!(B)$) |
calc |
\usetikzlibrary{shapes.geometric, shapes.symbols, shapes.misc, positioning, calc}
Many tutorials omit this table — hence endless
“tikz cloud compile error” searches.
2.5 Error line numbers do not match your editor
Cause: TikZ goes through several PGF parsing layers; TeX often reports
expanded line positions, not the line you see.
Suggested workflow:
- Move the figure to a separate
figure-tikz.tex and iterate with the standalone class;
- Compile every 5–10 lines you add;
- For complex figures, start from a visual draft, export code, then tweak — not 200 lines from scratch.
2.6 Compiles but blank or clipped
Common causes:
scale / transform canvas pushes content off the page;
clip or path picture hides geometry;
overlay + remember picture cross-page refs need two compilation passes;
pgfplots external data path wrong after moving directories.
2.7 Non-compile pain: time cost
Even with zero errors,
pure hand-written TikZ during a thesis often costs more wall-clock time than Visio or slides — debugging, forum threads, and waiting for answers add up. People stick with TikZ for
vector quality and
font consistency with the paper, not because typing coordinates is faster.
3 — Pre-submit compile checklist (bookmark this)
Before sending the paper or sharing sources:
- [ ] Preamble has
\usepackage{tikz} and every needed \usetikzlibrary{...}
- [ ] Every
\draw / \node / \path ends with ;
- [ ] Using
graphdrawing / \usegdlibrary → compiler is LuaLaTeX
- [ ]
xcolor loaded once, options match the engine
- [ ] Complex figures compile in
standalone or a separate .tex before \input into the main file
- [ ] Code copied from the web: check brackets, quotes, and punctuation
4 — DrawFig: when to use it and how
DrawFig (
https://drawfig.com/editor.html) does not replace LaTeX — it replaces the part where you
simulate the compiler in your head while typing TikZ.
Pricing (accurate): Canvas editing and common exports (SVG/PNG/PDF) are
free with no sign-in.
TikZ import (5 credits/use),
TikZ export (3 credits/use), and
AI canvas (5 credits/use) require sign-in and deduct credits;
30 credits are granted daily (they accumulate). Full rules:
Pricing & credits.
Good fits for DrawFig
| Your pain |
What DrawFig does |
| Repeated undefined control sequence |
Drag / AI on canvas — fewer syntax typos |
| Graph theory, network topology, algorithm sketches |
Built-in graph shapes and layouts; edge weights and arrows in the UI |
Do not want to learn graphdrawing |
Lay out visually, export TikZ, decide on auto-layout later |
| Collaborators do not know TikZ |
Share a visual draft; you export for the paper |
| Need LaTeX-quality vector output |
Export → TikZ, paste into tikzpicture |
Recommended five-step workflow
- Open the DrawFig editor; use AI chat or drag-and-drop for nodes, edges, and labels.
- Fine-tune position, line style, and arrows on canvas (WYSIWYG — no compile preview loop).
- File → Export → TikZ; copy the generated code.
- Paste into your paper; merge any
usetikzlibrary hints with the main preamble — avoid duplicate loads.
- Run your usual engine (pdfLaTeX / XeLaTeX / LuaLaTeX) once for a final check.
Spend time on
layout and content, not on “did line 47 miss a semicolon?”.
When hand-written TikZ still wins
- Heavy use of
tikz-cd, custom macros, or \ref-coupled figures tied to the prose;
- Journal rules requiring figures to share the same macro definitions as the body, with a mature TikZ template;
- You need a pure-text diff of every coordinate in version control.
Even then,
DrawFig sketch → export TikZ → hand polish beats a blank
.tex file.
Already have compilable TikZ and want visual edits?
You do not need to redraw from scratch:
paste-import a
tikzpicture into DrawFig, edit, and export again. Steps:
Import TikZ and keep editing (
File → Export → Import from TikZ code…, shortcut
Ctrl+Shift+I). TikZ import costs
5 credits per use (sign-in required).
5 — Long-tail search phrases → sections in this guide
6 — Summary
- TikZ's real difficulty is often not beauty but LaTeX-chain debugging: libraries, engine, package clashes, semicolons, misleading line numbers.
- Those failures drive long-tail search (paste the error + “how to fix”) — exactly where many users get stuck.
- DrawFig = visual + AI for ~80% of composition, TikZ export for paper-grade vectors and LaTeX integration; compile risk shrinks to paste + one final check.
👉
Try it: Open the DrawFig editor → sketch a small graph → export TikZ → paste into
standalone and compile. If it still fails, use the §3 checklist on your preamble — usually a library or engine mismatch.
Further reading (by error type):
Further reading (tools & workflow):