I stumbled on a strange behavior with tikz. Here is a minimal example:
\documentclass[parskip]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node{
\tikz[remember picture] \coordinate (a);
$1+2$
\tikz[remember picture]\coordinate (b);
};
\begin{scope}
\draw (a.south west) -- (b.south east);
\end{scope}
\end{tikzpicture}
\end{document}
Each time I compile it with pdflatex the produced pdf has a different number of pages... It alternates between 1 and 3 pages.
The compilation always gives me the following warning:
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
The minimal example is an adaptation of the answer of Alain Matthes from this discussion. The behavior also happens with his code.
Is it normal? If not, can I fix it? I would like, as in the previous link, to make a brace under part of a mathematical expression and add text under the brace. The difference with the question asked at the link is that the size of the text under the brace should not impact the mathematical expression (that is why I considered the answer of Alain Matthes).

tikzmacros inside one another. This is known to result in unpredictable behaviour, as far as I know. Why don't you just name your node and refer to its name directly? – Jasper Habicht Nov 29 '21 at 18:26