Spring til indhold
  • Book review: LaTeX Graphics with TikZ by Stefan Kottwitz

    Posted by LianTze on July 26, 2023

    Note: LianTze was one of the technical reviewers for Stefan Kottwitz’s second edition of LaTeX Beginner’s Guide, reviewed here.

    TikZ is an immensely powerful LaTeX package for creating diagrams and graphics. TikZ has grown immensely popular since its first release in 2005, and there are now many other LaTeX packages that are based on it. This includes dedicated packages for drawing specific kinds of diagrams: tikz-cd, tikz-feynman, chemfig, etc.; as well as classes and packages that use TikZ to enhance various typesetting elements: beamer, tcolorbox, etc. Its underlying system is called PGF (a "portable graphics format" for TeX), so you may also see "pgf" in articles that discuss TikZ.

    Examples of diagrams and graphics created with TikZ

    The TikZ/pgf package manual itself is chock full of information, contains all definitive references of various features and capabilities of TikZ, and includes 5 guided tutorials that simulate specific scenarios. But at 1271 pages with an additional 50 pages of indices, it can be hard to navigate, and isn't exactly easy to digest in a couple of afternoons. That’s where LaTeX Graphics with TikZ by Stefan Kottwitz comes in. With 272 pages of main content, the book is easier to navigate and digest. The full package manual is still indispensable as a reference, for looking up specific commands and options; but Stefan's book may be more accessible for readers with some LaTeX background who want to learn TikZ.

    Stefan's new book employs his usual style of illustrating a concept with practical code examples. The book is printed in full-colour; an e-book version is available. I personally also find the code examples to be easier to read compared to Stefan's previous book — the grey background was a bit too dark for my eyes.

    Photo comparing the code example blocks between LaTeX Beginner’s Guide and LaTeX Graphics with TikZ, both written by Stefan Kottwitz

    All code examples from this book are available at TikZ.org; and you can open the entire code bundle as a single project on Overleaf using this link.

    Personally I categorise this book's chapters into 3 categories: fundamentals, common graphic design software operations in TikZ, and special TikZ packages. These break down as follows:

    Fundamentals (Chapters 1–6)

    • Basic syntax of TikZ
    • Coordinate systems
    • Nodes and edges — fundamental building blocks in TikZ
    • Styles and pics
    • Trees and graphs

    Even if you're familiar with TikZ, it may still be worth revisiting these chapters. TikZ has had many new developments, and while the core syntax is unchanged, there may be some new extensions that are pleasantly surprising e.g. the "quotes" syntax.

    Diagram created with TikZ using the new quotes syntax

    Another thing that impressed me: Stefan doesn't shy away from mentioning advanced level packages like tikzpeople and tikzlings this early in the book, as long as they help to explain certain concepts like anchors of different node shapes. (These packages are discussed in more detail later on in the book.)

    An example of anchors of different node shapes

    Common graphic design software operations, but with TikZ (Chapters 7–12)

    If you're familiar with graphic design software like Illustrator or Photoshop, you would be familiar with these common operations — which you can do in LaTeX, too, by coding with TikZ.

    • Filling, clipping, and shading paths; decorations, layers, overlays, transparency

      • Explains important computer graphics concepts, such as the nonzero and even odd rules, with simple examples and language

      • Layers, overlays: Remember that we're really doing typesetting with LaTeX so combining concepts like layers, path decorations, overlays etc with typeset material including math expressions can yield very aesthetically pleasing results — both from a graphical and a typesetting point of view.

        Example of layers and overlays

    • Coordinate and path calculations

    • Canvas and coordinate transformations

    • Drawing curves, including Bézier curves and splines

      Example of a Bézier curve segment

    Special TikZ packages (Chapters 13–15)

    As we said at the beginning, TikZ is a very versatile and powerful package. So many libraries and packages have been built upon it for drawing and plotting specialised kinds of diagrams with specialized syntax.

    • pgfplots: a very versatile package for plotting mathematical functions and data points

      Example of two plots done with pgfplots

    • smartdiagrams: a lá ‘SmartArt’ feature in Microsoft Office programs; but with easy-to-write code

      Example of a diagram done with smartdiagrams

    • And finally — have fun drawing with TikZ!

      • tikzpeople: provides people-shaped nodes in the style of Microsoft Visio clip art, to be used with TikZ.

        Example of tikzpeople, a package that provides people-shaped nodes

      • tikzlings: like tikzpeople, but for drawing cute creatures

        Example of tikzlings, a package that provides cute creature-shaped nodes

      • jigsaw: drawing jigsaw pieces

        Example of jigsaw, a package for drawing jigsaw pieces

      • tikzbricks: drawing Lego-like bricks

        Example of tikzbricks, a package for drawing Lego-like bricks

      • …and more!

    Considerations when using TikZ on Overleaf

    TikZ is very powerful. Including many TikZ drawings in your Overleaf project, especially if they're complex and/or use huge datasets, can take a lot of compiling resources: this can sometimes lead to compile timeouts in your Overleaf projects. If that happens, you may want to consider these suggestions.

Opret gratis konto og modtag regelmæssige opdateringer

Registrer

Populære tags


Start writing now!

Create A New Paper

Overleaf is Gratis

New to LaTeX?
Start with a template

Company