# Why would an equation render on preview and in an external TeX compiler, but not in post?

I know the general phenomenon is that rendering of previews differs from rendering of posts, but, presumably, the goal is to minimise unnecessary discrepancies—and that, in particular, non-esoteric TeX, in an "I know it when I see it" sense, that renders in an external compiler without special packages should render in posts.

The following equation appears in @SidharthGhoshal's answer to Is there a summation method where the divergent series $S = U_0+U_1+U_2+\dots$ converges to a finite value(V2)?:

U_n = M\left(c-\frac{1}{n+2}\right)-M\left(c-\frac{1}{n+1}\right)\label{1}\tag{$$U$$} = \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} -  \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}}
= m_0 \left( \frac{1}{\sqrt{\frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{1}{\sqrt{\frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}}  \right) = m_0 c \left( \frac{n+2}{\sqrt{2c(n+2) -1 }} - \frac{n+1}{\sqrt{2c(n+1)-1}}  \right) =


I have to admit that I haven't been patient enough to count that braces and \left(\right) pairs match, but it seems to me, if they didn't, then this shouldn't render at all anywhere—and it renders just fine in preview:

and in an external TeX compiler; but it doesn't render in the post:

Sometimes such errors can be fixed on refresh, but that doesn't seem to be happening to me.

• The preview only users an answer. I would guess that the problem might be that both the question and the answer contain \label{1}\tag{$U$} - but the problem that the same label is used twice on one page only manifests when both the question and the answer are displayed. This is what I recently edited. Jul 26, 2023 at 5:25
• This post on Mathematics Meta seems to be about a problem caused by the same thing: Equations not shown, as if there is a problem with MathJax. Jul 26, 2023 at 5:52
• There is no point in the equation having a label at all, as it is never referenced (and there is no reason it ever should be, in such a short post). Jul 26, 2023 at 5:59
• @EmilJeřábek, re, while each person has their own labelling preferences, I think that argument is easy to accept; but I think it is also probably orthogonal to the question—whether, as @‍MartinSleziak suggests, the problem is caused by the label probably has little to do with whether the label belongs. Jul 26, 2023 at 15:16
• Thank you for asking this. I was wondering the same and never got around to it! :) Jul 29, 2023 at 21:01

This is a CW answer - for experimenting.

Here is the equation copy-pasted from the (current revision of the) post:

$$U_n = M\left(c-\frac{1}{n+2}\right)-M\left(c-\frac{1}{n+1}\right)\label{1}\tag{U} = \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} = m_0 \left( \frac{1}{\sqrt{\frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{1}{\sqrt{\frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} \right) = m_0 c \left( \frac{n+2}{\sqrt{2c(n+2) -1 }} - \frac{n+1}{\sqrt{2c(n+1)-1}} \right) =$$

Here is the same question after omitting \label{1}\tag{$U$}

$$U_n = M\left(c-\frac{1}{n+2}\right)-M\left(c-\frac{1}{n+1}\right) = \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} = m_0 \left( \frac{1}{\sqrt{\frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{1}{\sqrt{\frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} \right) = m_0 c \left( \frac{n+2}{\sqrt{2c(n+2) -1 }} - \frac{n+1}{\sqrt{2c(n+1)-1}} \right) =$$

And here \label{1}\tag{$U$} was replaced by \label{2}\tag{U}

$$U_n = M\left(c-\frac{1}{n+2}\right)-M\left(c-\frac{1}{n+1}\right)\label{2}\tag{U} = \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} = m_0 \left( \frac{1}{\sqrt{\frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{1}{\sqrt{\frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} \right) = m_0 c \left( \frac{n+2}{\sqrt{2c(n+2) -1 }} - \frac{n+1}{\sqrt{2c(n+1)-1}} \right) =$$

When I copy-paste the very first equation once again - the one containing \label{1}\tag{$U$} - this one is not rendered correctly. Which suggests this might be some problem with duplicate label.

$$U_n = M\left(c-\frac{1}{n+2}\right)-M\left(c-\frac{1}{n+1}\right)\label{1}\tag{U} = \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{m_0}{\sqrt{1 - 1 + \frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} = m_0 \left( \frac{1}{\sqrt{\frac{2}{c(n+2)} - \frac{1}{c^2(n+2)^2}}} - \frac{1}{\sqrt{\frac{2}{c(n+1)} - \frac{1}{c^2(n+1)^2}}} \right) = m_0 c \left( \frac{n+2}{\sqrt{2c(n+2) -1 }} - \frac{n+1}{\sqrt{2c(n+1)-1}} \right) =$$

• "this might be some problem with duplicate label"—oh, that makes perfect sense! I was so focussed on the post in isolation that I forgot that labels are per-page things. It also makes sense of why things would be fine on preview—the 'other' U label isn't there yet. Thank you! Jul 26, 2023 at 15:14
• I would encourage users to use more expressive labels (not just 1, for example). In fact, including their userID or something unique to them would help. E.g., \label{LSpice-1} rather than \label{1} would be a useful way to avoid label clashes. Jul 26, 2023 at 19:55
• Of course, the \tag can be anything you want, it is the \label that is causing the expression to fail. Jul 26, 2023 at 23:43
• @DavideCervone, re, I look forward to everyone labelling their equations LSpice-1. 😄 (@‍IosifPinelis has the interesting approach of numbering equations by 10s, in the hope of avoiding conflicts.) Jul 27, 2023 at 1:11
• @DavideCervone I wonder whether \label{1} appears in some standard help file. Otherwise I can't understand why so many users are automatically putting it in all their tagged equations even though they do not use the \label-\ref facility at all. Jul 27, 2023 at 7:18
• @EmilJeřábek, I am not able to find anywhere that that is suggested. But I suppose they are doing it to make the label match the tag, which they probably start at equation number 1 (even if other answers already include an equation numbered 1). Jul 28, 2023 at 19:56
• @LSpice, no doubt you are right, now everyone will use LSpice-1 instead of 1. Sigh. Jul 28, 2023 at 19:57
• @DavideCervone I almost never use \label in MathJax - so here I was basically just trying what works without really understanding what I'm doing. And this post was meant as a "sandbox" for testing - not as a genuine answer. Would you perhaps be willing to post an answer explaining at least basic dos and don'ts concerning \label, \tag (and maybe some related commands)? (Or maybe some brief explanation with a link to some documentation - if something suitable is available on mathjax.org or elsewhere.) Jul 29, 2023 at 5:10
• Re, I second @‍MartinSleziak's suggestion/request. I'm not sure which answer would then be appropriate to accept, but I doubt @DavideCervone or @‍MartinSleziak would be much fussed either way. (Amusingly, I note that all of @‍DavideCervone's answers here are to my questions. 😄) Jul 29, 2023 at 22:31