Background
Same as the last section in Beautiful Hugo Improvements.
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 inlayouts/partials/footer_custom.html
tostatic/js/katex-macros.js
- Wrapped the auto render function
renderMathInElement()
with a listener for theDOMContentLoaded
.
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.
Hugo interpreted (C)
as (C), even inside a pair of $...$
: $(C)
becomes
$(C)$.
In MathJax macros, one has to specify the total number of argument(s) for macros that accepts argument(s). As a result, I didn’t configure argument for operators for like “vol”, “Int”, etc. I would type “\vol(E)” on my old Octopress blog for convenience.
However, to avoid typos like “$\mathop{\mathrm{card}}(C)$”, I’m going to rewrite my $\KaTeX$ macros so that they will be capable of accepting arguments. This will be carried out gradually as I’m currently quite occupied with my studies in math.
Some macros Qike \N
, \R
, \Z
, etc, have been removed as they were already
supported by $\KaTeX$.
TODO list
- enable $\KaTeX$ auto-rendering
- port existing macros from my old blog
- write some math articles to test the macros
- rewrite my macros’ syntax to accept arguments
- promote $\KaTeX$ to the mathematical community
- watch $\KaTeX$ update for automatic equation referencing support