0

I am using https://github.com/opencollab/jlatexmath to parse latex math formulas in java. When trying to parse a simple complex number:

TeXFormula tex = new TeXFormula("32 + 45~i");

I get the following exception:

org.scilab.forge.jlatexmath.ParseException: Unknown character : '~' (or 126)

The character '~' is supposed to be an unbreakable space as explained in this documentation. https://en.wikibooks.org/wiki/LaTeX/FAQ#Non-breaking_spaces

The reason of using '~' is because I want to render the latex formula returned by a different library: mathjs.org and it includes the '~' character in some formulas.

Does jlatexmath support '~' or do I have to use a different spacing command?

  • I don't know JLaTeXMath, but in math mode in LaTeX spacing is normally done with \, \; \: (see http://www.emerson.emory.edu/services/latex/latex_119.html) - Also note, that in math mode spacing is normally NOT done, as the formatter gets it right on its own. Your formula should rather be "32+45i" – mtj Sep 27 '16 at 11:29
  • The reason of using "~" it is because I want to render the latex formula returned by a different library: http://mathjs.org/ and it includes the "~" character in some formulas. I fixed it doing: latex.replaceAll("~", "\\,") Before rendering but it is a dirty hack. Do you have a better idea? – adrianromero Sep 30 '16 at 12:25
  • No, sorry. (Apart from using latex.replaceAll("~", " ") because you really should not do spacing in the formula and the normal space will only act as a token delimiter, but not as a visible element) – mtj Sep 30 '16 at 12:47
  • Thanks. I will keep the replaceAll. – adrianromero Sep 30 '16 at 14:34
  • How to make 'jlatexmath' with multi lines when latex is long? – Thearith Sok Mar 26 '21 at 04:26

1 Answers1

0

The ~ is now allowed in JLaTeXMath: https://github.com/opencollab/jlatexmath/commit/27ffa7082efa75e6f86e8788f5cbe2156aa15f5c

Feel free to report bugs.

calixte
  • 16