In this answer, I used \tikzmark to mark the extent of a typeset piece of text, so I could draw changebars next to it. But it initially seemed that the changebars "disappear" with math-mode content. After some debugging, I whittled it down to the following MWE:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{amsmath}
\newlength\aLength
\newcommand{\tester}[1]{%
\setlength{\aLength}{50pt}%
\def\aMacro{Hello}%
\typeout{Before: \the\aLength, and \aMacro}%
#1%
\typeout{After: \the\aLength, and \ifdef{\aMacro}{\aMacro}{undefined!!}}
}%
\begin{document}
\begin{align*}
\tester{0}
\tester{ 0 & 1 }
\end{align*}
\end{document}
This yields the following behavior:
Before: 50.0pt, and Hello
After: 50.0pt, and Hello
Before: 50.0pt, and Hello
After: 0.0pt, and undefined!!
Before: 50.0pt, and Hello
After: 50.0pt, and Hello
Before: 50.0pt, and Hello
After: 0.0pt, and undefined!!
I have two questions on this output:
- Why are there four sets of output? The MWE calls
\testeronly twice. - What exactly is
&doing to cause\aLengthand\aMacroto revert to their previous values?