Configure MathJax to always recognize comma as decimal separator in numbers

414 views
Skip to first unread message

blue

unread,
Feb 12, 2016, 3:25:50 AM2/12/16
to MathJax Users
In MathJax 2.5 release notes it is written about a new feature: "#856 Recognize comma as decimal delimiter in units." 

Is it possible to configure MathJax globally for a site (maybe in MathJax.Hub?) to do it, instead of surrounding the comma in curly brackets (e.g. $8{,}5$) each time?

Peter Krautzberger

unread,
Feb 12, 2016, 3:31:23 AM2/12/16
to mathja...@googlegroups.com
Hi,

That release notes for 2.5 refers to units, i.e., \hspace{0,5cm}, where TeX treats period and comma the same.

As mentioned in issue #856, you can switch comma and period yourself using the code at https://github.com/mathjax/MathJax/issues/169#issuecomment-2040235

Regards,
Peter.

On Fri, Feb 12, 2016 at 9:25 AM, blue <wend...@gmail.com> wrote:
In MathJax 2.5 release notes it is written about a new feature: "#856 Recognize comma as decimal delimiter in units." 

Is it possible to configure MathJax globally for a site (maybe in MathJax.Hub?) to do it, instead of surrounding the comma in curly brackets (e.g. $8{,}5$) each time?

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

santia...@gmail.com

unread,
May 27, 2016, 12:08:04 PM5/27/16
to MathJax Users
Hi,

MathJax has one class "mn" who adds a little space after the comma when is a decimal separator. 


You can eliminate this class by adding the following code after  your MathJax.Hub.Config({}):

MathJax.Hub.Register.StartupHook("End",function () { 
var mn = $('.mn')
mn.each(function(i,e){
var value = $(this).prev().text()
if(value == ','){
$(this).attr('style','font-family: MathJax_Main;')
}
})
});


and you can write your code without curly brackets $8,5$

Best regards,
Santiago

PD: sorry for my English.

Davide P. Cervone

unread,
May 27, 2016, 4:51:51 PM5/27/16
to mathja...@googlegroups.com
I think the solution at


is superior to this one.  Your hack only works for HTML-CSS output (not SVG, NativeMML, CommonHTML, or the other formats).  It doesn't produce the proper semantics for the output (in particular, it doesn't fix the underlying MathML that is being inserted for assistive technology).  It assumes you are using the MathJax TeX fonts, so it will fail for users who have the STIX fonts installed (most OS X users, for example).  It is a little too aggressive and can alter the output in places where the preceding comma isn't a decimal place holder.  It only works on the first typeset pass, so won't affect any math that is added dynamically to your page.  It relies on jQuery, which you haven't mentioned.

So for these reasons I'd recommend against using this approach and use the one linked above instead.

Davide


Reply all
Reply to author
Forward
0 new messages