regebro / hovercraft

Make dynamic impressive presentations from text files!
https://hovercraft.readthedocs.org
MIT License
1.48k stars 209 forks source link

An option to support alternative LaTeX rendering engines #190

Closed deadmorous closed 4 years ago

deadmorous commented 5 years ago

I've been using hovercraft for a couple of years for making presentations with LaTeX formulas. Since there was no support for rendering math at that time, I added some scripts to do that. But my choice was KaTeX, rather than MathJax, for some reason. Is it possible to implement an option to choose math rendering engine among MathJax, KaTeX, and probably other hyphotetical engines?

regebro commented 5 years ago

There's basically two parts to the mathjax support, one is that if you have a .. math:: block then the mathjax JS will be included, and the other is that mathjax is initialized in the templates.

Mathjax does the rest.

A flag that allows you to have a .. math:: block without the mathjax headers, would allow you to use those blocks if you want to, without getting Mathjax included. You could then do a custom template that includes and initializes KaTeX. Does that sound reasonable?

Or you can just not use the .. math:: blocks.. Or point the --mathjax= to KaTeX. But a custom template is still needed, I think.

deadmorous commented 5 years ago

I added KaTeX scripts katex.min.js, contrib/auto-render.min.js, plus my own one to initialize KaTeX, to the list in the [hovercraft]/js-body parameter in the template.cfg file, and used .. math:: blocks in the presentation. I will try to experiment with --mathjax=path/to/KaTeX, as you suggested. If it effectively replaces MathJax with KaTeX, we're done :) Thank you!

deadmorous commented 5 years ago

Well, --mathjax=path/to/KaTeX works, but path/to/KaTeX has to be a directory, so I have to rename katex.min.js to MathJax.js. And I have to add katex.min.css to template.cfg Then it almost works. The problems are that KaTeX doesn't support the align environment and its formatted output is severely broken now (have no idea why), although its previous versions worked fine. Seems I'm going back to MathJax :)

regebro commented 4 years ago

Well, sorry to hear that, but yeah, MathJax is going to be the easiest.