Creating our first TikZ figure
Our first goal is to create a TikZ drawing that is the same as Figure 1.1, which we made in the classic LaTeX picture mode, to get a feeling of the TikZ basics.
To be able to use TikZ, you need to perform the following three steps:
- Load the
tikz
package in your document preamble:\usepackage{tikz}
- TikZ provides additional features with separate libraries. Here, we load the
quotes
library for adding annotations with an easy quoting syntax that we will use in the drawing:\usetikzlibrary{quotes}
- Use a
tikzpicture
environment for the drawing. The first code snippet we saw in this chapter, for the picture environment, will look like this with TikZ:\begin{tikzpicture}
\draw circle (0.5);
\draw (-0.5,0) to ["text"] (0.5,0);
\end{tikzpicture}
This results in the following output:
Figure 1.2 – Our first TikZ drawing
We draw a circle with a radius of 0.5 cm at the default...