I'm having an issue with matrix names in tikz being "persistent".
Consider the two matrices:
These matrices were generated with the following code:
\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
$
\begin{tikzpicture}
\matrix[
, matrix of math nodes
, left delimiter = {[}
, right delimiter = {]}
] (m)
{
1 & -32 & 0 & 15 \
16 & -138 & -3 & 5 \
4 & 14 & 11 & 19 \
};
\end{tikzpicture}
$
$
\begin{tikzpicture}
\matrix[
, matrix of math nodes
, left delimiter = {[}
, right delimiter = {]}
] (a)
{
1 \
16 \
4 \
};
\draw[red, thick] (m-1-4) -- (m-3-1);
\end{tikzpicture}
$
\end{document}
The two matrices are constructed in different tikzpicture environments. The one on the left is named m and the one on the right is named a.
The second tikzpicture has a \draw command that references nodes in a matrix from a previous tikzpicture. I actually want this code to throw an error, since this tikzpicture has no matrix named m.
Is it possible to ask tikz to "forget" the matrix m?

tikzpictureor even if you go on the next page. So the answer is no. You can create mechanisms that produce the error message by installing some coordinate prefixes, say. – Nov 12 '20 at 20:51tikzgraphs instandalonedocumentclass, and just\includegraphicsthe result. That way, no residue of the original code would be in the document. – Steven B. Segletes Nov 18 '20 at 18:47