# PGF/TikZ

PGF/TikZ is a pair of languages for producing vector graphics (e.g., technical illustrations and drawings) from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipses and polygons. PGF is a lower-level language, while TikZ is a set of higher-level macros that use PGF. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost. Till Tantau is the designer of the PGF and TikZ languages. He is also the main developer of the only known interpreter for PGF and TikZ, which is written in TeX. PGF is an acronym for "Portable Graphics Format". TikZ was introduced in version 0.95 of PGF, and it is a recursive acronym for "TikZ ist kein Zeichenprogramm" (German for "TikZ is not a drawing program").

## Overview

The PGF/TikZ interpreter can be used from the popular LaTeX and ConTeXt macro packages, and also directly from the original TeX.$^{:116}$ Since TeX itself is not concerned with graphics, the interpreter supports multiple TeX output backends: dvips, dvipdfm/dvipdfmx/xdvipdfmx, TeX4ht, and pdftex's internal PDF output driver.$^{:117–120}$ Unlike PSTricks, PGF can thus directly produce either PostScript or PDF output, but it cannot use some of the more advanced PostScript programming features that PSTricks can use due to the "least common denominator" effect. PGF/TikZ comes with an extensive documentation; the version 3.1.4a of the manual has over 1300 pages.
The standard LaTeX picture environment can also be used as a front end for PGF by using the pgfpict2e package.$^{:27}$
The project has been under constant development since 2005. Most of the development until 2018 was done by Till Tantau and since then Henri Menke has been the main contributor. Version 3.0.0 was released on 20 December 2013. One of the major new features of this version was graph drawing using the graphdrawing package, which however requires LuaTeX. This version also added a new data visualization method and support for direct SVG output via the new dvisvgm driver.

## Export

Several graphical editors can produce output for PGF/TikZ, such as the KDE program Cirkuit and the math drawing program GeoGebra. Export to TikZ is also available as extensions for Inkscape, Blender, MATLAB, matplotlib, Gnuplot, Julia, and R. The circuit-macros package of m4 macros exports circuit diagrams to TikZ using the dpic -g command line option. The dot2tex program can convert files in the DOT graph description language to PGF/TikZ.

## Libraries

TikZ features libraries for easy drawing of many kinds of diagrams, such as the following (alphabetized by library name):
* 3D drawing – 3d
* Finite automata and Turing machines – automata
* Coordinate system calculations – calc
* Calendars – calendar
* Chains: nodes typically connected by edges and arranged in rows and columns – chain
* Logic circuit and electrical circuit diagrams – circuits.logic and circuits.ee
* Entity–relationship diagrams – er
* Polygon folding diagrams – folding
* Graph drawing with automatic layout options – graphdrawing
* L-system drawings – lindenmayersystems
* Sequences of basic math operations – math
* Matrices – matrix
* Mind maps – mindmap
* Three-point perspective drawings – perspective
* Petri nets – petri
* Quantum circuits – quantikz
* RDF semantic annotations (only in SVG output) – rdf
* Special shapes and symbols – shapes.geometric and shapes.symbols
* Magnification of part of a graphic in an inset – spy
* Paths in SVG syntax – svg.path
* Trees – trees
* Turtle graphics – turtle
* Zooming and panning graphics – views

## Gallery

The following images were created with TikZ and show some examples of the range of graphic types that can be produced. The link in each caption points to the source code for the image.
* Periodic table of chemical elements (libraries used: calc, shapes)
* Rooty helix (library used: calc)
* Mind map of To the Lighthouse (libraries used: mindmap, shapes.misc)
* Plot of two normal distributed variables with big variance (libraries used: arrows, positioning)
* Hypersurface rendering (libraries used: arrows, calc, decorations.markings, intersections, positioning)
* Bayesian Gaussian mixture model (libraries used: arrows, backgrounds, calc, fit, matrix, patterns, plotmarks, shadows)
* Capacitor equivalent circuits (library used: arrows)
* Diagram showing different types of mean-tests (libraries used: arrows, shapes)
* Gradient plot of a function (library used: arrows.meta)
* Multivariate Gaussian distributions (libraries used: arrows, positioning)
* Feed-forward perceptron (libraries used: arrows, arrows.meta)
* Shield of the trinity with the four relations (libraries used: graphdrawing, graphs, quotes)
* English length units graph
* Graph homomorphism into C5 (library used: calc)
* Subgraphs of the Krausz partition of a given line graph
* Adjacencylist of a graph implemented as array of linked lists (libraries used: arrows, calc, positioning, shapes.multipart)