- Posted by LianTze on July 26, 2023
Book review: LaTeX Graphics with TikZ by Stefan Kottwitz
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:
chemfig, etc.; as well as classes and packages that use TikZ to enhance various typesetting elements:
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.
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.
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.
Another thing that impressed me: Stefan doesn't shy away from mentioning advanced level packages like
tikzlingsthis 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.)
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.
Coordinate and path calculations
Canvas and coordinate transformations
Drawing curves, including Bézier curves and splines
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
smartdiagrams: a lá ‘SmartArt’ feature in Microsoft Office programs; but with easy-to-write code
And finally — have fun drawing with TikZ!
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.