[tex4ht] is it possible to use KaTex with tex4ht?

Michal Hoftich michal.h21 at gmail.com
Tue May 7 16:30:07 CEST 2019


Hi Nasser,


> Since tex4ht now supports mathjax mode, I was just wondering,
> if it is even possible to make tex4ht also support katex mode
> as well? i.e. compile the latex file so that the HTML
> generated uses Katex for math rendering instead of mathjax.

yes, it is possible to support KaTeX. Try the following configuration file:

------------
\Preamble{xhtml,mathjax}
\Configure{MathjaxSource}{}
\Configure{@HEAD}{\HCode{
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css"
integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ"
crossorigin="anonymous">\Hnewline
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js"
integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij"
crossorigin="anonymous"></script>\Hnewline
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js"
integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI"
crossorigin="anonymous"
    onload="renderMathInElement(document.body);"></script>\Hnewline
}}
\begin{document}
\EndPreamble
------------

There is one downside: KaTeX supports even less LaTeX commands than
MathJax, not mentioning all custom commands you use in your documents.
So I can predict that you will have lot of troubles in trying to write
a support for your documents.
I am not sure it is worth the trouble, but you will see.

Best regards,
Michal


More information about the tex4ht mailing list