How to Fix “Package pgf Error: No Shape Named … Is Known”
At a glance
- 1. Find the name
Read the error message and identify the node or coordinate TikZ tried to use.
- 2. Check definitions
Confirm that the name is spelled consistently and that its node was created.
- 3. Inspect the path
Look for empty parentheses, missing coordinates, or malformed edge and tree syntax.
- 4. Compile again
Fix the earliest relevant error, then recompile to see whether later errors disappear.
The PGF error “No shape named … is known” usually means that a TikZ path refers to a node or coordinate that has not been defined. The name may be misspelled, used before its node is created, or absent because the path syntax is malformed.
The fastest way to fix it is to locate the name reported in the error, search for where it is defined, and compare the definition with every use. If the reported name is blank or looks unexpected, inspect the punctuation immediately around the failing path.
What the error means
In TikZ, a reference such as (A) means “use the node or coordinate named A.” It does not create that node. A named node must be defined first, for example with \node (A) {Text};, or a coordinate must be declared with \coordinate (A) at (0,0);.
If TikZ encounters (A) but no shape called A is available, PGF cannot determine the point or shape for the drawing operation and reports the error. Node names are identifiers: keep their spelling and capitalization consistent, and avoid spaces or punctuation in names.
A minimal example and fix
This document compiles because both endpoints are defined before the path refers to them:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (D) at (0,1) {D};
\node (B) at (-1,0) {B};
\node (E) at (1,0) {E};
\draw (D)
edge node[left] {$a$} (B)
edge node[right] {$b$} (E);
\end{tikzpicture}
\end{document}
If the definition \node (B) at (-1,0) {B}; is removed, the edge ending at (B) has no target shape, so PGF reports that shape B is unknown. Restore the definition, or change the edge to use the intended node’s actual name. A text label {B} inside a node does not give that node the name B; the name is the parenthesized identifier immediately after \node.
How to trace the error
- Read the full message. If it says
No shape named 'X' is known, search the source for(X). Also check generated or included TikZ code if the reference is not in the main file. - Find the definition. Look for
\node (X) ...or\coordinate (X) .... If there is no definition, add one or correct the reference. - Check exact spelling and order.
X,x, andXXare different names. In ordinary path construction, define the node before the path that uses it. - Check braces and parentheses. A missing
}or an extra)can make TikZ parse later tokens as a coordinate or node reference. - Fix the first relevant error and recompile. Later messages may be consequences of the first malformed command rather than separate problems.
The line number in a TeX error is a useful starting point, but it may point to the end of a path or to a macro containing the actual mistake. Read a few lines before and after it.
Edge and tree syntax to inspect
For a named-node diagram, this is a valid pattern:
\draw (D)
edge node {a} (B)
edge node {b} (E);
It assumes that D, B, and E have already been defined. The edge node part supplies a label along an edge; it does not define the endpoint. If the source contains an extra empty coordinate, such as (), remove it or replace it with the intended node name. Parentheses with nothing between them do not identify a valid named node and often signal that a name was accidentally omitted.
In a TikZ tree, child nodes can be created directly with child { node {…} }. If later drawing commands refer to those children by names, explicitly name them, for example child { node (leftchild) {…} }, and use (leftchild) consistently. A tree’s visible text is not automatically a reusable node name.
Common mistakes
- Confusing node text with its name:
\node {A};displays “A” but does not create a node namedA. Use\node (A) {A};if you need to refer to it later. - Using a name that was never declared: A path like
\draw (start) -- (finish);needs bothstartandfinishto exist as nodes or coordinates. - Leaving an empty reference: Check for
()near chainededgeoperations, tree children, or commands assembled from macros. - Assuming a library fixes a missing node: Loading a TikZ library can add drawing features, but it does not create an absent shape. Fix the reference or define the node.
- Ignoring an earlier syntax error: A missing brace or semicolon can cause a misleading later shape error. Correct the first error reported by the compiler before diagnosing subsequent messages.
If the message names a valid node that is defined later in the same tikzpicture, move the drawing operation after the definition or restructure the picture so the name is available when the path is processed. A node in a separate tikzpicture is not normally made available just by reordering commands; cross-picture references require TikZ’s cross-picture remembering mechanism, such as remember picture. For a complicated diagram, temporarily reduce it to a few node definitions and one failing edge; adding the remaining paths back in stages makes the first bad reference easier to identify.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.