mathquill icon indicating copy to clipboard operation
mathquill copied to clipboard

.mathquill('text'): power followed by multiplication

Open vyndor opened this issue 9 years ago • 3 comments

I have latex expression that looks like "x^23". Which is really "(x^2)*3". I assume that in text output should be something like "(x^2)*3", but I get "x^23". I'm using v0.9.4 Thank you!

vyndor avatar Aug 31 '15 03:08 vyndor

Yes that's really confusing and needs to be fixed; but technically, it's not wrong, as MathJax or CodeCogs or any other LaTeX renderer can demonstrate:

  • MathJax: http://mathb.in/42032
  • CodeCogs: http://latex.codecogs.com/gif.latex?x%5E23

Han

On Sun, Aug 30, 2015 at 8:17 PM, vyndor [email protected] wrote:

I have latex expression that looks like "x^23". Which is really "(x^2)_3". I assume that in text output should be something like "(x^2)_3", but I get "x^23". I'm using v0.9.4 Thank you!

— Reply to this email directly or view it on GitHub https://github.com/mathquill/mathquill/issues/461.

laughinghan avatar Aug 31 '15 03:08 laughinghan

I haven't found any docs about .mathquill('text') so I don't know it's real idea. Also the strange thing is that "x^2x" gives me a "x2*x" as expected. But "x^23" gives me "x23".

Also I found other cases with inconsistent behaviour for digits and characters. "\sqrt{4}8" -> "sqrt(4)8" "\sqrt{4}x" -> "sqrt(4)*x"

vyndor avatar Aug 31 '15 03:08 vyndor

I found a fix for this. You need to modify one line of the mathquill.js code. The problem is in the line

return block ? prefix + (l.length === 1 ? l : '{' + (l || ' ') + '}') : '';

The trouble is that if the exponent is a single character, it tdoesn't put the set brackets around the exponent.

drjmo avatar Aug 23 '22 19:08 drjmo