krater icon indicating copy to clipboard operation
krater copied to clipboard

Improve macro sharing mechanism

Open paolobrasolin opened this issue 3 years ago • 3 comments

@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!

paolobrasolin avatar Jan 07 '22 09:01 paolobrasolin

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.

jonsterling avatar Jan 07 '22 09:01 jonsterling

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!

paolobrasolin avatar Jan 07 '22 09:01 paolobrasolin

So my code is now available here: https://github.com/jonsterling/math

  1. 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)

  2. 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.

  3. 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 set macrolib: topos. Then in your page-local antex prelude, write \usepackage{topos}

The way that this works is as follows:

  1. 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.

  2. The antex configuration in _config.yml has been upgraded to allow latexmk to search assets/macros/ for packages.

jonsterling avatar Jan 07 '22 13:01 jonsterling