jiggzson / nerdamer

a symbolic math expression evaluator for javascript
http://www.nerdamer.com
MIT License
514 stars 82 forks source link

Is it possible for `nerdamer.convertFromLaTeX(TeX)` to support LaTex matrix? #584

Closed DylanXie123 closed 3 years ago

DylanXie123 commented 3 years ago

I want to parse LaTex matrix with nerdamer, but I find nerdamer.convertFromLaTeX(TeX) throw error when parsing

  \begin{matrix}
   1 & 2 \\
   7 & 8
  \end{matrix}

example code:

let expStr = '\\begin{matrix}1 & 2 \\ 7 & 8\\end{matrix}';
let expression = nerdamer.convertFromLaTeX(expStr);

this gives

ParseError: & is not a valid variable name: 19: undefined
jiggzson commented 3 years ago

@DylanXie123, I don't think it should be too difficult. I'll look into it.

jiggzson commented 3 years ago

@DylanXie123,

Correct me if I'm wrong but shouldn't it be?

let expStr = '\\begin{matrix}1 & 2 \\\\ 7 & 8\\end{matrix}';
let expression = nerdamer.convertFromLaTeX(expStr);
DylanXie123 commented 3 years ago

@jiggzson I think you are right.

jiggzson commented 3 years ago

@DylanXie123. I added an update on the dev branch. Let me know of that's what you had in mind.

DylanXie123 commented 3 years ago

@jiggzson That's exactly what I want, thanks!