This TikZ code is slightly adapted from Norbert Manthey’s “brief introduction to TikZ”:
\documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} [marked/.style = {red, very thick}] \draw (0,0) circle(0.5); \draw [marked] (-0.5, -0.5) -- (0.5, 0.5); \draw [marked, blue] (0.5, -0.5) -- (-0.5, 0.5); \end{tikzpicture} \end{document}
It looks very similar to, and is relatively structurally analogous to, this SVG:
<svg transform="scale(99) translate(1 1)"> <style>.marked { stroke: red; stroke-width: 0.03 }</style> <circle fill="none" stroke="black" stroke-width="0.01" r="0.5" /> <path class="marked" d="M.5 -.5 L-.5 .5" /> <path class="marked" d="M-.5 -.5 L.5 .5" style="stroke: blue !important" /> </svg>
The two graphics languages have relatively similar facilities. Both support vector drawing with Z-ordering, grouping, and overrideable styles to apply to groups of objects or individual objects. Both offer simple objects such as circles and ellipses, arbitrary paths made out of different kinds of segments which can be filled and stroked, both support α-blending; both allow you to define new object types in terms of old ones. There are some minor differences: their Y-coordinate conventions are opposite; SVG doesn’t automatically pick a viewport that can see the whole graphic; SVG stylesheet attributes override node attributes by default; and for computations that go beyond simple template repetition, SVG is typically extended in JS instead of TEΧ.
But the most surprising difference to me is that TikZ code is (leaving out the header and footer boilerplate) about 40% shorter and, to my mind, more readable. This is not anything I ever expected to say about a DSL defined in TEX. I might have expected something like TikZ to scale better to more advanced, difficult things, but not to be simpler for the simple things.
Up to this point, SVG had been my tool of choice for making structured vector graphics easily, having displaced PostScript in that role. Now it looks like TikZ is going to be my choice.
The TikZ manual is online at TUG.org, with a much more impressive example on its front cover. It’s a thousand-page tome that contains a reference manual in the standard reference-manual style, but the first hundred pages is a series of introductory tutorials. As the manual says, “The wealth of options offered by TikZ is often daunting to beginners” — among other things, it contains force-directed layout algorithms for graph layout, its own object-oriented programming system, a plotting library vaguely similar to matplotlib, schematic drawing commands, and a system for simulating plant growth.