What Is TikZ and How Does It Relate to TeX and LaTeX?
Updated
TikZ is a graphics package for TeX and LaTeX that defines TeX commands for drawing pictures directly inside your document, so the figures are typeset by the same engine as your text rather than imported from an external image file. It sits on top of the lower-level PGF system, works with pdfLaTeX, and has grown from a small style file into a full graphics language documented in a manual of over a thousand pages (Version 3.1.12, per the online manual at tikz.dev). Use it when you want vector diagrams—lines, shapes, nodes, graphs, plots—whose fonts, sizes, and positioning stay consistent with the surrounding LaTeX document.
The relationship in one sentence
LaTeX is the document preparation system; TeX is the typesetting engine underneath it; PGF is the graphics layer that computes and renders drawing commands; and TikZ is the friendly front-end syntax you actually write. When you type a TikZ command, it is translated into PGF-level operations, which in turn become drawing instructions in the PDF that pdfLaTeX produces.
| Layer | Role | What you interact with |
|---|---|---|
| TeX | Typesetting engine | Indirectly, via LaTeX |
| LaTeX | Document markup and structure | Your .tex file, preamble, packages |
| PGF | Low-level graphics system | Rarely directly; TikZ calls it for you |
| TikZ | High-level drawing syntax | \tikz, \draw, \node, \fill, etc. |
What a TikZ command actually does
TikZ commands are ordinary TeX commands, which is why they can appear anywhere LaTeX accepts text or a box. The manual's own first example is a single line:
\tikz \draw (0pt,0pt) -- (20pt,6pt);
This yields a straight line from one coordinate to another. A second example fills a circle:
\tikz \fill[orange] (1ex,1ex) circle (1ex);
Two things are worth noticing. First, the coordinates use TeX units (pt, ex), so a picture scales with your document's font metrics rather than with pixels. Second, the syntax is declarative: you describe the path ("from here to there", "a circle at this point") and TikZ handles the drawing.
For anything beyond a one-liner, you normally wrap the code in a tikzpicture environment:
\begin{tikzpicture}
\draw (0,0) -- (2,1);
\fill[orange] (1,1) circle (0.5);
\end{tikzpicture}
Why it is tied so closely to LaTeX
Because TikZ output is generated by the TeX engine, labels inside a picture use the same fonts, math mode, and macros as the rest of your document. You can write $x^2$ on a node and it is typeset exactly like body math. This is the main practical difference from exporting a figure from a separate drawing tool: there is no font mismatch and no separate file to keep in sync.
The manual describes the project's origin as a small LaTeX style for creating graphics in Till Tantau's PhD thesis directly with pdfLaTeX—which is why pdfLaTeX compatibility is a baseline assumption rather than an add-on.
What the manual covers, and where to start
The online manual at tikz.dev is an unofficial HTML rendering (maintained by Dominik Peters using the lwarp package) of the official documentation edited by Till Tantau. Its structure reflects how the package is meant to be learned:
- Tutorials first. The manual explicitly says the options are "often daunting to beginners" and that its slowly paced tutorials teach almost everything you need without reading the rest. The four listed are "A Picture for Karl's Students," "A Petri-Net for Hagen," "Euclid's Elements," and "Diagrams as Simple Graphs."
- Core language sections cover coordinates, path specifications, actions on paths, arrows, nodes and edges, pics, graphs, matrices and alignment, trees, function plots, transparency, decorations, transformations, and animations.
- Libraries extend the core for specific domains: circuits, automata, calendars, mindmaps, Petri nets, shadings, shadows, shapes, three-dimensional drawing, and more.
- Graph drawing and data visualization are treated as larger subsystems with their own layout algorithms (trees, layered, force-based, circular) and axis/legend tooling.
A sensible reading order for a new user is: one tutorial end to end, then the "Specifying Coordinates" and "Path Specifications" chapters, then the specific library matching your diagram type.
When TikZ is the right choice—and when it is not
TikZ fits well when a diagram must live inside a LaTeX document, when labels need document fonts or math, when the figure should be version-controlled as text, or when you need programmatic repetition (the \foreach utility is a core feature). It is a weaker fit for photographic content, for highly organic illustrations, or when a collaborator needs to edit the figure in a point-and-click tool.
If you are deciding between TikZ and an external drawing program, compare them on the same axes: font consistency with the document, editability by non-LaTeX users, reproducibility in version control, and the learning cost of the syntax. TikZ wins clearly on the first and third; external tools usually win on the second and, for complex artwork, on the fourth.