ArticleslgStudy

computer science

PGF/TikZ

PGF/TikZ is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand PGF/TikZ rather than just read about it. In short: 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.

PGF/TikZ — main illustration
PGF/TikZ — illustration

Key takeaways

  • PGF/TikZ belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect PGF/TikZ to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of PGF/TikZ from memory before moving on to harder problems.

Reference excerpt

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. 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. 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. 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):

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.

See also

Asymptote (vector graphics language)

References

Further reading

External links

PGF/TikZ on CTAN PGF/TikZ manual PGF/TikZ gallery at TeXample.net

Illustrations

PGF/TikZ illustration
PGF/TikZ illustration
PGF/TikZ illustration
PGF/TikZ illustration
PGF/TikZ illustration

Worked examples

Example 1 — a first encounter with PGF/TikZ

Start with the simplest possible case. Write down what PGF/TikZ claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to PGF/TikZ before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about PGF/TikZ ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of PGF/TikZ

In research
PGF/TikZ appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses PGF/TikZ in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
PGF/TikZ is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cross-platform free software, Free TeX software, Graph description languages, so understanding it makes those chapters shorter.
In everyday life
Look for PGF/TikZ outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “PGF/TikZ” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study PGF/TikZ in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what PGF/TikZ means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain PGF/TikZ out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is PGF/TikZ in simple terms?

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…

Why does PGF/TikZ matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study PGF/TikZ?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on PGF/TikZ.

Tags

  • Cross-platform free software
  • Free TeX software
  • Graph description languages
  • Graph drawing software
  • Object-oriented programming languages
  • TeX SourceForge projects
  • Vector graphics markup languages

Keep exploring