# Custom $\KaTeX$ Macros

## More efficient math editing

### Goal

To write math efficiently by automatically loading longer code with shorter macro code.

For example, when I wrote Some Infinite Cardinality Identities, it would be ten times more quicker and efficient to type \card{C} than to write \mathop{\mathrm{card}}(C) all the time.

### Changes committed to my repo

The current version of Beautiful Hugo is still using $\KaTeX$ v0.7, which doesn't support macros in auto-rendering. It would be inconvenient to include the macros after invoking $\KaTeX$'s render function.

I spent a night trying to put my custom $\KaTeX$ macros into layouts/partials/footer_custom.html. Unaware of the $\KaTeX$ version, I couldn't find a solution from Google.

• Migrated the JavaScript code from the big <script> tag in layouts/partials/footer_custom.html to static/js/katex-macros.js
• Wrapped the auto render function renderMathInElement() with a listener for the DOMContentLoaded.

### Comparison with my MathJax macros

Once I had confirmed that $\KaTeX$'s support for equation tagging and custom macros worked on this site, I ported my MathJax macros to here.

Testing nested