Is there a way to get katex global macros working?

In the katex website it says global macros persist between math expressions: https://katex.org/docs/supported.html#macros

So in theory I could do:

$$
\gdef\matrix#1{\begin{bmatrix}#1\end{bmatrix}}
$$
$$
\matrix{1&2&4\1&2&3}
$$

But it doesn’t seem to work. The macro does work if it’s in the same expression. So:

$$
\gdef\matrix#1{\begin{bmatrix}#1\end{bmatrix}}
\matrix{1&2&4\1&2&3}
$$

works. Is there a way of getting this working?

1 Like

Not sure but I’ve created an issue so that it will be checked - https://github.com/laurent22/joplin/issues/1105

It does seem to work now. What I now wonder about is, continuing this line of thought, whether there might not be a way to have a common block of \gdefs include-able in all katex-including notes. I did that back when I was taking notes with markdown/mathjax/pandoc via some hackish workarounds.