krater
krater copied to clipboard
Improve macro sharing mechanism
@jonsterling has implemented some high level mechanism to define and share macros between LaTeX/KaTeX/AnTeX. Context:
- https://categorytheory.zulipchat.com/#narrow/stream/241990-general.3A-values/topic/goals.20and.20questions/near/267130230
- https://twitter.com/jonmsterling/status/1479238208391110659
Hopefully we can use some oh his ideas to improve the setup, once he publish them!
I’ll share my code with you! it may or may not be the way that you want to proceed, but it could be potentially helpful.
I’ll share my code with you! it may or may not be the way that you want to proceed, but it could be potentially helpful.
That'd be great!
So my code is now available here: https://github.com/jonsterling/math
-
I am targeting mathjax right now, but what I did can easily be adapted to katex, which takes as input only a slightly different format of macro definition. (update: I switched to KaTeX)
-
The file macros/topos.rkt demonstrates how you might create a platform-agnostic macro library. When this file is executed by Racket, it replaces assets/macros/topos.sty and assets/macros/topos.json which are in format that can be understood by LaTeX and MathJax respectively.
-
In a Jekyll page, set the variable
macrolib
to the name of the macro library that you wish to be exposed to MathJax. In our running example, I setmacrolib: topos
. Then in your page-localantex
prelude, write\usepackage{topos}
The way that this works is as follows:
-
The custom-head.html template has been upgraded to read the
macrolib
variable, and if it is set, dynamically load the corresponding json file, and then use it to dynamically set up the MathJax configuration. -
The
antex
configuration in_config.yml
has been upgraded to allowlatexmk
to searchassets/macros/
for packages.