TikZ

TikZ is the LaTeX drawing language, and it produces figures nothing else here can match for precision: Feynman diagrams, quantum circuits, chemical structures, mathematical plots.

It runs a full TeX engine, which is why it ships disabled and has to be turned on by an administrator.


#What it is good at

  • Papers, theses and technical notes.

  • Teaching material in physics, chemistry and mathematics.

  • Any figure where an approximation would be wrong.


#What it draws

Element

Syntax

Document

\documentclass[tikz,border=6pt]{standalone}

Libraries

\usetikzlibrary{quantikz} and friends

Picture

\begin{tikzpicture} ... \end{tikzpicture}

Common libraries

circuitikz, tikz-feynman, chemfig, pgfplots


#A worked example

A labelled state machine drawn with TikZ:

TikZ

The source, which you can paste into a new diagram and edit:

\documentclass[tikz,border=6pt]{standalone}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2.8cm,on grid,auto]
  \node[state,initial] (idle) {idle};
  \node[state] (run) [right=of idle] {running};
  \node[state,accepting] (done) [right=of run] {done};
  \path[->]
    (idle) edge node {start} (run)
    (run)  edge node {finish} (done)
    (run)  edge [loop below] node {tick} ()
    (done) edge [bend left] node {reset} (idle);
\end{tikzpicture}
\end{document}

Library

Draws

circuitikz

Electronic circuits with correct symbols

tikz-feynman

Feynman diagrams

quantikz

Quantum circuits

chemfig

Chemical structures

pgfplots

Plots from data or functions


#A few things that catch people out

  • TikZ is off by default. An administrator turns it on. See

  • Rendering is heavier than any other language here; expect it to take longer.

  • Compilation errors come from TeX, so they read like TeX errors rather than diagram errors.



Thirty-one languages. Nobody knows them all.