mathjax / MathJax-node

MathJax for Node
Apache License 2.0
615 stars 97 forks source link

TeX parse error: Missing close brace #287

Closed MissMyCat closed 7 years ago

MissMyCat commented 7 years ago

commend: node d:\node_modules\mathjax-node\bin\tex2svg E=n\frac{B{{a}^{2}}}{2\Delta t} while run this comend , TeX parse error: Missing close brace.

I do not change anything in tex2svg file, just generate svg. btw, when I use another tex, the result is wrong either for example: node d:\node_modules\mathjax-node\bin\tex2svg S=\frac{1}{2}{{a}^{2}} result is s = (1/2) a 2 rather than s = (1/2) * a ^ 2 os:win 10 MathJax-node version:0.5.2

dpvc commented 7 years ago

Make sure you enclose the TeX code in quotation marks, to make sure special characters aren't interpreted by the shell. For example, in your first example, the space between Delta and t is breaking the TeX into to parameters for tex2jax, and only the first one is processed. It is missing the closing brace (which is part of the second argument), which is the source of the error message you are receiving.

So use

node d:\node_modules\mathjax-node\bin\tex2svg 'E=n\frac{B{{a}^{2}}}{2\Delta t}'

instead.

MissMyCat commented 7 years ago

@dpvc thx I have tried use node d:\node_modules\mathjax-node\bin\tex2svg 'E=n\frac{B{{a}^{2}}}{2\Delta t}' but it does not work luckly, use node d:\node_modules\mathjax-node\bin\tex2svg "E=n\frac{B{{a}^{2}}}{2\Delta t}" is Ok

MissMyCat commented 7 years ago

@dpvc I'm sorry I have another question. when there is space in Latex content. such as : node D:/node_modules/mathjax-node/bin/tex2svg "-c\leqslant x\leqslant c" program will return error: Usage: tex2svg [options] 'math' > file.svg Options: --inline process as in-line TeX [boolean] --speech include speech text [boolean] --speechrules ruleset to use for speech text (chromevox or mathspeak) [default: "mathspeak"] --speechstyle style to use for speech text (default, brief, sbrief) [default: "default"] --linebreaks perform automatic line-breaking [boolean] --font web font to use [default: "TeX"] --ex ex-size in pixels [default: 6] --width width of container in ex [default: 100] --extensions extra MathJax extensions e.g. 'Safe,TeX/noUndefined' [default: ""]

Not enough non-option arguments: got 0, need at least 1

So. How can I transfer it ?

dpvc commented 7 years ago

The reason you get this message is because the -c from "-c\leqslant x\leqslant c" looks like a command line option (anything starting with a - does), and the tex2svg program complains.

Instead, use

node D:/node_modules/mathjax-node/bin/tex2svg -- "-c\leqslant x\leqslant c"

where the -- ends the the options allowing the "-c\leqslant x\leqslant c" to be treated as a non-option argument (the math). This is standard unix practice as a means of separating options from other arguments when the first argument contains a minus. Note that you can use -- even if the first argument doesn't start with -.

MissMyCat commented 7 years ago

@dpvc cool! It works!