Skip to content

Beveled fraction like sfrac, nicefrac bfrac

Davide P. Cervone edited this page May 26, 2013 · 3 revisions

From https://groups.google.com/d/msg/mathjax-users/u8LgFmPl8wo/cQqX4KkpQo4J

MathJax doesn't have a method to specify the bevelled attribute on <mfrac> directly from TeX, but you could define your own macro that would accomplish that. For example

<html>
<head>
<title>Add Bevelled Fraction Macro</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  var MML = MathJax.ElementJax.mml,
      TEX = MathJax.InputJax.TeX;

  TEX.Definitions.macros.bfrac = "myBevelFraction";

  TEX.Parse.Augment({
    myBevelFraction: function (name) {
      var num = this.ParseArg(name),
          den = this.ParseArg(name);
      this.Push(MML.mfrac(num,den).With({bevelled: true}));
    }
  });
});
</script>
<script type="text/javascript"
  src="../MathJax/unpacked/MathJax.js?config=TeX-AMS_HTML">
</script>

</head>
<body>

<p>A bevelled fraction: \(\bfrac{1}{2}\)</p>

</body>
</html>

adds a \bfrac macro that you can use to get a bevelled fraction. The spacing will be better than trying to use \! and super- and subscripts to manage it by hand.

Davide

Clone this wiki locally