# Nested MathJax environments render correctly in the preview, but are broken in the final post

It seems like \\ doesn't work correctly here, and I need \newline instead:

$$\vec{\nabla} \times \vec{A}(\,\vec{r}) = \begin{cases} B_0\hat{z} && \text{if \vec{r} \in some cylinder} \ \vec{0} && \text{ otherwise} \end{cases}$$

• This seems to be related to this question, see Willie Wong's answer that recommends that you try to avoid nesting math environments. Write \text{if } \vec{r} \text{ lies in some cylinder} instead of \text{if $\vec{r}$ lies in some cylinder}. Note that adding spaces at the beginning and end of the \text environment (whenever appropriate) also results in the correct spacing. – t.b. Apr 7 '12 at 21:46
• What is very irritating, though, is that your code renders just fine in the preview I get when I edit the source, but that it doesn't work in the posted version. – t.b. Apr 7 '12 at 21:58
• @t.b.: Yeah, that's what made me mark it as a bug – user541686 Apr 7 '12 at 23:06
• Using $within \text environment is just... wrong. – Asaf Karagila Apr 8 '12 at 6:18 • @t.b. apparently two different individuals/teams are responsible for the code in the preview and in the actual presentation... hence sometimes they don't behave exactly the same. – Willie Wong Apr 9 '12 at 15:25 • @Willie: thanks for that info. However, it does lead errors. Earlier today I edited a post in which all braces had disappeared once submitted, while the braces are displayed in the preview (and since the preview doesn't doesn't let you tell I happened to overlook one instance). – t.b. Apr 9 '12 at 15:56 • @t.b. I'm not playing apologist. Just stating a fact about why the preview, unfortunately, is not absolutely trustworthy. – Willie Wong Apr 9 '12 at 16:00 ## 1 Answer Davide Cervone has generously created an improved parser for us that makes the separation of Markdown and MathJax much more reliable. So far, it's only running client-side, i.e. it's used in the preview, but not in the final rendered version. A side effect of your bug report is that you've proven that the new parser is indeed better – it handles your case, while the old one doesn't. Either way, we've now ported the parser to also work during the final rendering of the post on the server. This will be enabled in the next build of the site (probably within the next 24 hours; likely less), after which the behaviors should be identical again. • It looks like the changes have worked. Here is the original example again: $$\vec{\nabla} \times \vec{A}(\,\vec{r}) = \begin{cases} B_0\hat{z} && \text{if \vec{r} \in some cylinder} \\ \vec{0} && \text{ otherwise} \end{cases}$$ with the nested dollars. – Davide Cervone Apr 13 '12 at 13:06 • Note that this should also mean that you can use$\rm\LaTeX\$ environments without surrounding them with dollar signs. E.g. $$E=mc^2$$ produces $$E=mc^2$$ even though there are not dollars in this comment anywhere. – Davide Cervone Apr 13 '12 at 13:08
• do the changes you mention to the code on the server apply to all SE sites? This post seems to indicate that they are still having problems on the chemistry site. – Davide Cervone May 14 '12 at 13:23
• @DavideCervone No, the new stuff is currently only running here. But I'd think it's fine to eneable it everywhere soon. – balpha May 18 '12 at 7:29
• OK, thanks for the info. That would explain the problem they had over at chemistry. – Davide Cervone May 18 '12 at 10:31