# MathJax preview broken when equations contain \labels

One can use \tag, \label, \ref and \eqref the usual way in MathJax (including references turned into links), e.g.

$a = b \tag{a}\label{a}$


and later

$\eqref{a}$


$a = b \tag{a}\label{a}$

and later

$\eqref{a}$

but unfortunately the block containing the \label breaks once one further edits - this is probably due to the label being apparently "reused" for a "new" tag, as you can see in this screenshot:

I guess a simple fix would be not parsing \label while editing a question, although an even better solution would of course be somehow letting MathJax know the previous instance of the label shall be discarded.

• A suboptimal fix might be putting the whole post into $\begingroup$ ... $\endgroup$ – Tobias Kienzler Oct 24 '13 at 6:51
• The preview code could use MathJax's ability to reset the labels in order to resolve this issue (the preview code was written before \label and \ref were available in MathJax). – Davide Cervone Oct 24 '13 at 11:30
• As a temporary work-around, you could add $\def\label#1{}$ at the top of your question/answer while you are editing it, and remove it just before submitting the answer. – Davide Cervone Oct 24 '13 at 11:33
• @DavideCervone Nice workaround, thanks! I hope it'll be fixed though... – Tobias Kienzler Oct 25 '13 at 8:04
• See my post that includes a user-script to work around this issue until the editing code is updated. – Davide Cervone Apr 8 '16 at 23:35
• The editing code has been updated, so the preview code should now process \label macros properly. You should no longer need to use the temporary work-arounds that were necessary before. – Davide Cervone Apr 29 '16 at 19:47
• @DavideCervone Looks great, there also seems to be no more delay for reprogressing changed TeX – Tobias Kienzler May 2 '16 at 8:21