User-defined LaTeX macros


I would love to be able to define new LaTeX commands. This could be implemented as a user-defined preamble (text settable in settings) that would be injected to MathJax on every page.

Why I want it: Because I don’t enjoy typing $$\mathbb{R}$$ and such whenever I want to jot down a quick note at school.

The preamble would just need to go into a display: none div at the beginning of the document (inside LaTeX marks, of course). I have done it here:

Slightly OT, but it would also be pretty awesome to enable AsciiMath in addition to LaTeX. MathJax supports it.


We’re using KaTeX, not MathJAX, to render LaTeX.

Not sure if that’ll still work?


Aaah, OK, sorry, I thought it was MathJax. For KaTeX I am not sure how to implement it. But it would still be nice :smiley:


No worries, we looked at MathJAX when first implementing this, since it’s more well-established and has more functions. But it didn’t suit our needs to get the HTML to display inline (MathJAX wants to take over the whole rendering process), and MathJAX is slower.

For KaTeX, I believe macros aren’t working yet, from the looks of this pull request:


Makes sense. Knowing MathJax, I was actually wondering how you managed to make the rendering so fast! :slight_smile:

The PR looks merged, so \def and such should work. I am not sure how or where it would need to be injected for KaTeX, though.

EDIT: Not that PR, that one is not merged. This PR: – looks like macros of a sort can go into the settings?

BTW, I just want to say that you’re pretty cool – your responses are really useful and interesting! That is a welcome sight :smiley: Keep up the awesomeness!


I see, this setting was set in our code (hard-coded), but I guess it’s possible to open that up for hardcore LaTeX users some day. Thanks for digging this up.

Thanks :slight_smile: