Overlaying LaTeX content with TikZ drawings
Our matrix example was fine for creating a diagram. However, mathematicians will typeset matrices using amsmath
matrix environments in LaTeX’s math mode.
In this section, we will explore how to draw within such text and math content created outside TikZ. There will be quite some code lines again; remember that you can view the complete example code at TikZ.org and on GitHub.
We will recreate our matrix example with standard LaTeX tools. First, we have to load the amsmath
package. Then, in the document, we write an equation with pmatrix
environments and a long extensible arrow. That’s straightforward LaTeXing. One thing will be new here: whenever we want to remember a current position, we insert the \tikzmark{x}
command, where x
stands for a coordinate name we choose. Let’s go:
\[ \begin{pmatrix} 1 & 2 & 3 \\ ...