Builtin macros, macro arguments, overset and underset

* Ship predefined macros with the library, in macros.js.
* Allow macro arguments #1 and so on, with argument count deduced from string.
* Use these features to implement \overset and \underset, fixes #484.
This commit is contained in:
Martin von Gagern
2017-01-06 18:52:50 +01:00
parent 40ec1b92b8
commit 7ec455083f
5 changed files with 98 additions and 3 deletions

15
src/macros.js Normal file
View File

@@ -0,0 +1,15 @@
/**
* Predefined macros for KaTeX.
* This can be used to define some commands in terms of others.
*/
module.exports = {
//////////////////////////////////////////////////////////////////////
// amsmath.sty
// \def\overset#1#2{\binrel@{#2}\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
"\\overset": "\\mathop{#2}\\limits^{#1}",
"\\underset": "\\mathop{#2}\\limits_{#1}",
};