math.js + MathJax: show fraction as inline or slash for units like m/s or mi/h

466 Views Asked by At

Need help with math.js and LaTeX using MathJax.

For example, at the moment: \frac{140.8~\mathrm{m}}{\mathrm{s}}

Will result to: enter image description here

Which is not what I want.

I want to force it to use slash (eg: 140.8 m/s) or display as 140.8 ms^(-1).

I'm new in using math.js with MathJax.

Any help appreciated.

1

There are 1 best solutions below

0
syed On

So I found out about macros, so created one to replace \frac with \flatfrac.

window.MathJax = {
  loader: {load: ['[tex]/physics']},
  tex: {
        packages: {'[+]': ['physics']},
        macros: {
            frac: "\\flatfrac"
        }
    }
};

Not sure this is the best thing or correct usage, but it works!