Scaling in MathJax with respect to text direction

一笑奈何 提交于 2019-12-10 12:22:04

问题


I'm working on a site which is in Arabic (default text direction is "right to left") and I'm using "Noto Naskh Arabic" font for arabic text and Latin-Modern for latin text which I'm definig by the following css code:

*[dir="ltr"] {
        font-size: 20px !important;
        font-family:"Latin-Modern";
}

Users may need to enter mathematical equations and I'm using 'Mathjax' for this purpose, the problem is that:

  1. Fractions are displayed without the horizontal line
  2. Equations are displayed with different sizes between arabic and latin paragraph as when I write

    some text in english here $\int f(x)dx $

I have come to a slution to the first problem using css

span:lang(ar).MathJax { 
    direction: ltr !important;  
    font-family:"Latin-Modern";
    }

For the second problem, I need to know if there is a way to automatically specify scale separately for equation which are embedded in Arabic paragraph end those embedded in English paragraph.


回答1:


It seems like the main issue is that you have to scale in the first place. I'm guessing you did that because MathJax is rendering too large in RTL contexts.

It looks like MathJax is having issues detecting the correct ex-height of the surrounding font. That can be caused by various problems, from fonts not having a correct ex-height to bad CSS interactions; from a quick test it's not the fonts.

As a workaround you can disable font matching in the MathJax configuration

MathJax.Hub.Config({
     "HTML-CSS": {matchFontHeight: false},
     SVG: {matchFontHeight: false},
     CommonHTML: {matchFontHeight: false}
});

You should then also disable the scaling you applied.



来源:https://stackoverflow.com/questions/44870980/scaling-in-mathjax-with-respect-to-text-direction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!