diff --git a/src/functions.js b/src/functions.js index 4360025a..7d663dda 100644 --- a/src/functions.js +++ b/src/functions.js @@ -118,32 +118,6 @@ defineFunction("xArrow", [ }; }); -// Infix generalized fractions -defineFunction("infix", ["\\over", "\\choose", "\\atop"], { - numArgs: 0, - infix: true, -}, function(context) { - let replaceWith; - switch (context.funcName) { - case "\\over": - replaceWith = "\\frac"; - break; - case "\\choose": - replaceWith = "\\binom"; - break; - case "\\atop": - replaceWith = "\\\\atopfrac"; - break; - default: - throw new Error("Unrecognized infix genfrac command"); - } - return { - type: "infix", - replaceWith: replaceWith, - token: context.token, - }; -}); - // Row and line breaks import "./functions/cr"; diff --git a/src/functions/genfrac.js b/src/functions/genfrac.js index b16bea65..ab0a38a8 100644 --- a/src/functions/genfrac.js +++ b/src/functions/genfrac.js @@ -251,3 +251,36 @@ defineFunction({ return node; }, }); + +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop"], + props: { + numArgs: 0, + infix: true, + }, + handler(context) { + let replaceWith; + switch (context.funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + replaceWith: replaceWith, + token: context.token, + }; + }, +}); +