# User-defined LaTeX macros

#1

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: https://github.com/AnotherKamila/poznamky_ma/blob/master/Makefile#L10

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

#2

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

Not sure if that’ll still work?

#3

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

#4

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: https://github.com/Khan/KaTeX/issues/250

#5

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

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: https://github.com/Khan/KaTeX/pull/493 – 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 Keep up the awesomeness!

#6

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