# 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: 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.

3 Likes

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

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

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!

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

1 Like

+1 for this functionality, it would be useful to have a preamble with macros that can be loaded and used at all times.

I’d also love to have this functionality in dynalist. I do a lot of writing in latex and have quite a few convenience macros that I’d like to be able to use in my notes.

Would love this functionality as well for the reasons above.
This would save a lot of time spent typing for sure !