Why tikzpicture fails on Overleaf — wrong compiler, log noise, missing libraries in subfiles, xcolor clashes, timeouts — plus a DrawFig export workflow.
tikzpicture on Overleaf and everything turns red with a long log — searches like “overleaf tikz compile failed” or “overleaf undefined control sequence” often hit several issues at once. This post is Overleaf-specific check order; error-type details live in the hub guide.
📌 7 TikZ error categories: TikZ won't compile?
| Your code contains | Compiler |
|---|---|
Plain \node, \draw |
pdfLaTeX or XeLaTeX (Chinese projects often XeLaTeX) |
\usegdlibrary, graphdrawing |
LuaLaTeX → dedicated guide |
.tex file.
!:
Undefined control sequence + \draw → likely missing semicolonOption clash for package xcolor → xcolor clashUnknown shape 'cloud' → missing tikzlibrarymain.textikz-test.tex with only:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (A) {A};
\node (B) [right=of A] {B};
\draw (A) -- (B);
\end{tikzpicture}
\end{document}
Set it as Main document and compile. If this passes but the full project fails, the issue is template preamble or libraries missing in subfiles.
\inputfigures/xxx.tex and \input them. \usetikzlibrary in a subfile does not magically apply elsewhere — libraries belong in the main preamble, or every file with tikzpicture must load them before inclusion.
\foreach) can time out. Options:
standalone class, upload PDF, \includegraphics on Overleaffigures/my-graph.tex or paste into tikzpicture\usetikzlibrary in the main preamble (respect xcolor load order)usegdlibrary and LuaLaTeX