-
I want to create a macro macros: {
'\\tabs': (arg1) => '\\quad'.repeat(arg1),
} Or is there any way to do what I want? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, it's possible, but I don't think it's documented currently. See katex.renderToString('\\tabs{10}', {
macros: {
'\\tabs': (context) => {
let [arg] = context.consumeArgs(1);
arg = arg.reverse().map(token => token.text).join('');
arg = Number(arg);
return '\\quad'.repeat(arg)
}
}
}) |
Beta Was this translation helpful? Give feedback.
Yes, it's possible, but I don't think it's documented currently. See
src/macros.js
for a bunch of examples. Dealing with numbers is unfortunately a bit painful, because each character becomes its own token, and the tokens are in reverse order. This should do what you want: