Support nicefrac
Please support the command \nicefrac as the one from package nicefrac.
This one allows for much nicer inline fractions (as long as (de)nominator stay short).
Thanks for making a feature request. These kinds of requests usually work best by writing an extension and making a PR to https://github.com/mathjax/MathJax-third-party-extensions.
If you want a starting point, see http://docs.mathjax.org/en/latest/extension-writing.html#more-advanced-extensions and https://github.com/mathjax/MathJax-docs/wiki/Beveled-fraction-like-sfrac,-nicefrac-bfrac for quick workarounds.
Would suggest xfrac instead of nicefrac: http://www.bakoma-tex.com/doc/latex/mh/xfrac.pdf
It's basically the same, but plays nice with more fonts than the default Computer Modern. No downsides as far as I can see, just newer.
Note that MathJax only supports a limited number of fonts, and doesn't support mixing fonts, so the font support in xfrac is unlikely to be transferable to MathJax.
On the other hand, you could get something like these macros using MathML's bevelled fractions. You can use
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {Augment: {
Definitions: {macros: {xfrac: 'XFrac'}},
Parse: {prototype: {
XFrac: function (name) {
var num = this.ParseArg(name);
var den = this.ParseArg(name);
this.Push(MathJax.ElementJax.mml.mfrac(num,den).With({bevelled: true}));
}
}}
}}
});
</script>
just before the script that loads MathJax.js in order to implement a simple bevelled fraction.
This would be really helpful for people on Lyx.
Notify me if it's added :)
Registering interest in an xfrac extension for use with PreTeXt. We have long-time built-in historical support for an \sfrac macro which has been downgraded before and which I may severly curtail since it is a real headache. We would gracefully support slanted fractions for authors if such an extension providing \sfrac existed. Thanks.
(Yes, we had the MathML solution above for some time, and had to remove it. I forget the exact reason provoking that.)
@rbeezer, v4 adds a units package that includes \nicefrac, which does bevelled fractions. Perhaps that will fit the bill?
Thanks! Yes, that could be a workable long-term solution. I'm just now working on a graceful "regression" that will put a small burden on authors on the LaTeX side. That will still mean changes on the HTML side, so moving to \nicefrac could mean a clean break, even.
Thanks again, I'll test as we migrate to v4.
@rbeezer, you might be able to do something like
\newcommand{\sfrac}[2]{\mathchoice{\textstyle\nicefrac{#1}{#2}}{\nicefrac{#1}{#2}}{\nicefrac{#1}{#2}}{\nicefrac{#1}{#2}}}
to define \sfrac.