# MathJax in Comment Gets Corrupted

MathJax bug:

(Of course I don't know whether the bug is in the MathJax engine or in StackExchange code.)

When I enter the following comment in a math.stackexchange.com page, the second \alpha in sin(α_1+α_2) gets split up for some reason, yielding sin(α_1+\a lpha_2), which displays with the \a in red as an unrecognized escape sequence.

It depends on what you mean by "closed-form". Since it is only piecewise differentiable, I don't think you can avoid the presence of constructs like "max" that correspond to an "if-then" in a program, although they can be hidden using closed-form constructs like "if A then B else C"$=B\,sgn(A)^2+C(1-sgn(A)^2)$. Given 2 angles $\alpha_1,\alpha_2$, you can assume a unit-diameter circumcircle and construct all the other parameters: $(s_1,s_2,s_3,\phi_1,\phi_2,\phi_3)=(sin(\alpha_1),sin(\alpha_2),sin(\alpha_1+\alpha_2),0,\alpha_1+\alpha_2,\alpha_2)$. These two tricks should give you what you want.
• @Thursday Thanks for the tip!
– Matt
Sep 1, 2014 at 18:49
• Aug 19, 2018 at 10:19

This is the Stack Exchange™ WhiteSpace EnforcementOfficer™ at work. It inserts zero-width space in comments that have overly long strings of characters with no whitespace. When this happens inside your long formula, too bad: it's no longer valid markup for MathJax.

Workaround: use some whitespace in long formulas when you post them in comments. Something like $(s_1,s_2,s_3,\phi_1,\phi_2,\phi_3)= (sin(\alpha_1),sin(\alpha_2), sin(\alpha_1+\alpha_2),0, \alpha_1+\alpha_2,\alpha_2)$ is safe to use.

I think it's not feasible for the simple comment processor to correctly decide what's a formula and what's not. (Why, oh why did Knuth use symmetric delimiters for math?). Perhaps a more realistic solution would be to train MathJax to ignore HTML entities &zwnj;&#8203;, but this is something you'd need to bring up with MathJax team. For now, manual insertion of whitespace will have to do.

• I don't think the MathJax team would consider ignoring such characters just to work around this site's practice of blindly inserting these characters -- this would be like asking gnu to make their C preprocessor ignore such characters before tokenizing as a workaround for some other system that can't refrain from inserting them.
– Matt
Sep 1, 2014 at 19:08
• Currently there is no way for a person having the problem to figure out what the problem is. It would be very helpful for example for a panel to pop up (at least in MathJax enabled sites) saying something like "invisible spaces have been inserted due to lack of whitespace and the result should be checked for readability."
– Matt
Sep 1, 2014 at 19:14
• @Matt That's reasonable, and can be useful for more than MathJax: total lack of whitespace is a warning sign in general. Want to put in a feature request? I've made enough of my own already. :)
– user259867
Sep 1, 2014 at 19:17
• Sure, if you tell me the way to make a feature request! ;-)
– Matt
Sep 1, 2014 at 19:26
• Just post it here on Meta, with the tag (feature-request). Some recent examples.
– user259867
Sep 1, 2014 at 19:38