Open Happypig375 opened 5 years ago
Ok cool. I'll continue with current solution. Just bear with me since I'm a little pressed for time at the moment but we'll get it done.
@tecosaur, This was added some time ago but I forgot to update you. Do you want to take a look at it? https://nerdamer.com/functions/nerdamer.convertFromLaTeX.html
Ah, I somewhat forgot about this so thanks for pinging me :)
// nerdamer.convertFromLaTeX("x_2+x_1").text() // "x_1+x_2" (Correct)
nerdamer.convertFromLaTeX("x\times3+x_1").text() // "imes3*x+x_1"
nerdamer.convertFromLaTeX("""x\times3+x_1""").text() // Expected ')'
nerdamer.convertFromLaTeX("x\\times3+x_1").text() // "x_1+xtimes3"
nerdamer.convertFromLaTeX("x \\times 3+x_1").text() // "x^3+x_1"
nerdamer.convertFromLaTeX("x\\times3+x_1").text() // "x_1+xtimes3"
nerdamer.convertFromLaTeX("x \\times 3+x_1").text() // "x^3+x_1"
nerdamer.convertFromLaTeX("x\\sqrt(x)").text() // "x*xsqrt"
nerdamer.convertFromLaTeX("x\\sqrt[3](x)").text() // "3*x*xsqrt"
nerdamer.convertFromLaTeX("x\\sqrt[3]{x}").text() // "3*x*xsqrt"
nerdamer.convertFromLaTeX("x\\sqrt[3]x").text() // "3*x*xsqrt"
nerdamer.convertFromLaTeX("x\\frac xy").text() // ParseError: * is not a valid postfix operator at 3: 3: undefined
// nerdamer.convertFromLaTeX("x\\frac{x}{y}").text() // "x^2*y^(-1)" (Correct)
nerdamer.convertFromLaTeX("x\\frac{x}y").text() // ParseError: / is not a valid postfix operator at 7: 7: undefined
nerdamer.convertFromLaTeX("x\\frac x{y}").text() // ParseError: * is not a valid postfix operator at 3: 3: undefined
nerdamer.convertFromLaTeX("x\\cdot 3").text() // "x^3"
nerdamer.convertFromLaTeX("x\\cdot3").text() // "xcdot3"
nerdamer.convertFromLaTeX("\\int^4_3x dx").text() // ParseError: , is not a valid postfix operator at 14: 14: undefined: undefined
nerdamer.convertFromLaTeX("\\int^4_3 x dx").text() // ParseError: , is not a valid postfix operator at 14: 14: undefined: undefined
nerdamer.convertFromLaTeX("\\frac{d}{dx}x^2").text() // "d*dx^(-1)*x^2"
nerdamer.convertFromLaTeX("\\lim_{x\\to3}x").text() // ParseError: , is not a valid postfix operator at 10: 10: undefined: undefined
nerdamer.convertFromLaTeX("\\sin^2{\\pi}").text() // ParseError: Unable to get property 'parent' of undefined or null reference: 2: undefined
// nerdamer.convertFromLaTeX("\\sin{\\pi}").text() // "0" (Correct)
nerdamer.convertFromLaTeX("\\sin\\pi").text() // ParseError: Unable to get property 'parent' of undefined or null reference: 2: undefined
nerdamer.convertFromLaTeX("x^6_3").text() // "_3*x^6"
Expected x_3^6
@Happypig375,
convertFromLaTeX
needs the whitespace. I'll work on correcting that. \\
not just \
. I guess since you didn't @mention me, I missed the notification at first. Thanks for pointing these out. I'll take care of them.
JS fiddle: https://jsfiddle.net/fkc0Lws3/
nerdamer.convertFromLaTeX('1\\frac{1}{2}').text() // results in: 1*0.5 -> 0.5 when evaluated.
Expected: 1.5
A whole number (an integer) combined with a proper fraction (numerator < denominator) should be treated as addition not multiplication, i.e. a mixed number.
You could also convert it to the improper fraction version if that is easier to do e.g. (3/2)
in the example case.
Since I am not sure editing an @-mention into a comment does anything, here: @jiggzson regarding https://github.com/jiggzson/nerdamer/issues/426#issuecomment-625065731 the previous comment.
If you already saw it then apologies for the spam 🙂
JS fiddle: https://jsfiddle.net/fkc0Lws3/
nerdamer.convertFromLaTeX('1\\frac{1}{2}').text() // results in: 1*0.5 -> 0.5 when evaluated.
Expected:
1.5
A whole number (an integer) combined with a proper fraction (numerator < denominator) should be treated as addition not multiplication, i.e. a mixed number.
You could also convert it to the improper fraction version if that is easier to do e.g.
(3/2)
in the example case.
I'm also working on a problem with mixed fractions lately. Has this issue been fixed? Thanks.
I'm also working on a problem with mixed fractions lately. Has this issue been fixed? Thanks.
@xream Assuming the jsfiddle is up to date, it should be always using the latest version, it appears this has not been fixed yet.
This may or may not help you, but the way I got around this problem back when this issue was discovered was simply to write a function that expanded the mixed fraction latex expression to an addition, before passing it to convertFromLatex
. This seemed to work well enough as a workaround so we moved past this issue.
This solution worked for us because we stored the original latex and evaluated nerdamer expressions separately in the system, so we only had to apply this workaround once.
So that any of these editors can be used with Nerdamer.