opencollab / jlatexmath

A Java API to render LaTeX
Other
507 stars 109 forks source link

unknown symbols brought by 'lvert' in latex formula expression #101

Closed Baiamanov closed 7 months ago

Baiamanov commented 11 months ago

Hi there,

As a user of oxygen xml editor, I encountered an error about unrecognized symbols when converting xml documents to html pages which includes the process of converting in-line latex formula expressions to SVGs.

The tech support engineer of oxygen said they call the jlatexmath library but did nothing else on the lib or the font family. Their advice was submit an issue here. So here I am. See the issue description below please.


When converting latex formulas of which the expressions contain "lvert", the webhelp transformation reports the following: CODE: SELECT ALL

... Caused by: org.scilab.forge.jlatexmath.ParseException: Problem with command genfrac at position 1:152 [pipeline] Unknown symbol or command or predefined TeXFormula: 'lvert' ... For example, in the formula for Elastic Net Regression Algorithm: CODE: SELECT ALL

\dfrac{1}{2*n\_samples}* \Bigl\lVert{y - Xw} \Bigr\rVert_2^2 + alpha * l1Ratio\Bigl\lVert{w}\Bigr\rVert_1 + \dfrac{alpha*(1-l1Ratio)}{2}\Bigl\lVert{w}\Bigr\rVert_2^2

It seems jlatexmath 1.0.7 cannot parse certain symbols converted from characters such as 'lvert' or 'rvert'. As it said the symbol expressed by 'lvert' is unknown (to its library).

I believe the latex plugin works well because there are many other latex formulas in the documents, none of them caused errors except for the ones containing 'lvert'.

Then I had a google search finding that eight years ago, someone encountered similar problem with 'lvert' and 'rvert': https://tex.stackexchange.com/questions ... -math-font

As the discussion went in that thread from stackexchange.com, it seems the problem was caused by the font-family, or in other words, the symbols converted from either 'lvert' or 'rvert' cannot be found in the library of specific font-family, then the jlatexmath parser detects it as unknown.

Since I was using the Inter font-family which was specified and imported in the css I used for webhelp, I had another test with default Webhelp Responsive transformation bundled with oxygen, the result was the same.

So, if it's caused by the compatibility issue of font-family, does it mean that I have only two workarounds for such issues?

  1. Simple but straightforward, replace formula expression with image (screenshot of those formulas)
  2. Use certain font-family to support latex formula, such as "Computer Modern", or "Latin Modern Math" and "TeX Gyre Math"? I checked the font-support page of mathJax: https://docs.mathjax.org/en/latest/output/fonts.html MathJax version 3 currently supports only one font, the MathJax TeX font. Version 2 provides the following fonts:

Really?

So... in short, does jlatexmath lib support presenting latex formula expressions that contain 'lVert' or 'rVert'?

Thanks and Regards, Galano

murkle commented 11 months ago
image

Seems fine with JLaTeXMath v2 - try with this branch https://github.com/opencollab/jlatexmath/tree/experimental

Baiamanov commented 11 months ago

Hi Michael(@murkle),

Thank you! I'll give it a try with this experimental version. Btw, how come it's still in the experimental branch now that it contained some bug fixes compared with v1.0.7 version?