§3.1 Draw a mathematical picture
A fenced tikz block with an explicit tikzpicture environment compiles into a drawing. The example below contains five rows of dots. Their lengths are , so the picture has fifteen dots, matching (2.1) with .
The surrounding example block uses the custom display name “Figure” and supplies a caption and a reference label.
::: example (Figure) [Five rows contain fifteen dots] {@fig:triangle}
```tikz
\begin{tikzpicture}[scale=0.65]
\foreach \row in {1,...,5} {
\foreach \col in {1,...,\row} {
\fill (\col,-\row) circle (2pt);
}
}
\end{tikzpicture}
```
:::
Figure 3.1 (Five rows contain fifteen dots)
You can link directly to Figure 3.1 from another chapter. A new drawing may take a moment to compile. Once it is ready, readers receive the saved result.
§3.2 Show two routes with the same result
A commutative diagram says that two paths give the same answer. In this example every corner is the integers. Going across multiplies an integer by two. Going down multiplies it by three. Either route from the upper left to the lower right multiplies it by six.
Use a tikz fence with an explicit tikzcd environment for arrows and their labels.
```tikz
\begin{tikzcd}
\mathbb{Z} \arrow[r, "2"] \arrow[d, "3"'] &
\mathbb{Z} \arrow[d, "3"] \\
\mathbb{Z} \arrow[r, "2"'] & \mathbb{Z}
\end{tikzcd}
```
§A simpler diagram with CD
For a small rectangular diagram, CD works inside a math display. Here stand for sets and the letters on the arrows stand for maps. The diagram expresses .
$$
\begin{CD}
A @>f>> B \\
@VgVV @VVhV \\
C @>k>> D
\end{CD}
$$
Keep diagrams self-contained. These blocks do not provide a full LaTeX project or load files from your computer.
License · CC0 1.0 · Peerpedia collaboration terms