In the LATEX book, I have examples printed side-by-side with their source code. This is managed by setting a pair of \vboxes inside an \hbox inside displayed math so I could take advantage of the display math spacing before and after. While working on the chapter on \newtheorem  I noticed that the cross-reference information was coming out wrong. It was somehow picking up the number of the subsection (the fact that it’s unnumbered and shouldn’t be calling \refstepcounter in the first place is its own issue I need to track down but never mind that for now). After far too long digging into source code (remember, \ShowCommand is your friend), I realized that what was happening was that I was getting the special handling of \label inside display math from the amsmath package. The simple fix was to change the \[\] entry into display math to $$$$.