Skip to main content
The difference between beginner and advanced TikZ is not knowing more commands — it’s structure. Beginners style every node inline until diagrams become unmaintainable; advanced users define styles once, position relatively, and let libraries do the arithmetic. This guide covers the three techniques with the highest payoff: tikzset styles, pgfplots for real data, and annotation layers over figures. (New to TikZ? Start with the TikZ basics tutorial first.)

Technique 1: Styles + Relative Positioning

The single biggest upgrade: define node styles once with \tikzset, and position nodes relative to each other with the positioning library instead of coordinates. The result is a flowchart you can actually edit later: Why this scales where inline styling doesn’t:
  • Change once, update everywhere. Making all steps green is a one-line edit in the stage style — not a hunt through every node.
  • right=of edit instead of (3.2,0). Insert a new step and the neighbors shift; with absolute coordinates, every downstream node needs re-measuring.
  • -{Stealth} from arrows.meta is the modern arrow-tip syntax — crisper heads than the legacy ->, and configurable (-{Stealth[length=3mm]}).
  • The |- and -| path operators produce clean right-angle connections for the “retry” loop — no manual waypoints.

Technique 2: Real Data with pgfplots

For data figures, don’t draw axes by hand — pgfplots builds publication-quality plots on top of TikZ, with the same fonts as your document: The habits that matter in practice:
  • Always set compat (\pgfplotsset{compat=1.18}) — it opts into current positioning behavior and silences the most common pgfplots warning.
  • Feed it files, not retyped numbers. \addplot table {results.csv}; reads your data file directly, so the figure updates when the data does — retyping coordinates is where plot errors come from.
  • Match the document, don’t fight it. Because pgfplots renders through TeX, labels automatically use your document’s fonts and math — the reason these plots look “native” next to matplotlib exports.

Technique 3: Annotation Layers

The third pattern: TikZ as an annotation layer — braces, callouts, and arrows over a schematic (or, with the same technique, over an included image): The decorations.pathreplacing library supplies the brace; amplitude controls its depth, and the node[midway, above] attaches the label at its center. To annotate an actual image instead of drawn shapes, the standard trick wraps it in a node and switches to relative coordinates so annotations survive image resizing:

Keeping Big TikZ Maintainable

  • One file per figure (figures/phase-diagram.tikz, pulled in with \input) keeps 200-line pictures out of your document body and makes figures reusable across paper, thesis, and slides.
  • Name your coordinates (\coordinate (inlet) at (2,1);) instead of repeating literals — the diagram becomes self-documenting and adjustable at one place.
  • Compile-time cost is real for many large TikZ figures; the external library caches compiled figures as PDFs so unchanged ones don’t recompile on every run.
TikZ’s compile-check-adjust loop is the most iteration-heavy work in LaTeX — exactly where having the PDF preview beside the source, with nothing to install for pgfplots or any TikZ library, pays off most. Open the editor and try these examples →