Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use KaTeX instead of MathJax #97

Closed
VincentTam opened this issue Dec 25, 2018 · 5 comments
Closed

Use KaTeX instead of MathJax #97

VincentTam opened this issue Dec 25, 2018 · 5 comments

Comments

@VincentTam
Copy link

KaTeX renders math much quicker than MathJax. To get an idea of how slow the later can be, you may try Math Meta.SE's MathJax tutorial.

You may consult, for example, davidar/TeX.js#9 for more info. Despite the closing of this linked issue, KaTeX has eventually been implemented in that project.

Therefore, many Hugo themes ship with KaTeX, notably Beautiful Hugo.

@Hsins
Copy link

Hsins commented Dec 25, 2018

I think that this issue is not an issue because you can switch the math equation render between KaTeX and MathJax by modifying the import script resource.

Besides, there are some equations not parse in KaTeX but MathJax.

@VincentTam
Copy link
Author

A quick search for "mathjax" in this repo shows that MathJax is embedded in this theme's Go-HTML and SCSS template. I would like to know how you can "switch the math equation renderer between KaTeX and MathJax" without getting deep into the code.

Besides, there are some equations not parse in KaTeX but MathJax.

Mind giving an example? I only know that AMScd is not (and won't be) supported, and that it lacks support for equation auto-referencing. However, MathJax's support for AMScd is so primitive that professional mathematicians would hardly use them.

@Hsins
Copy link

Hsins commented Dec 25, 2018

Take a look in this file:

<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

It include a js file to render with MathJax. If you want to render with KaTeX, we can get the code from its offical site:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.css" integrity="sha384-xNwWFq3SIvM4dq/1RUyWumk8nj/0KFg4TOnNcfzUU4X2gNn3WoRML69gO7waf3xh" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.js" integrity="sha384-UP7zD+aGyuDvxWQEDSRYcvoTxJSD82C6VvuEBktJZGo25CVhDstY9sCDHvyceo9L" crossorigin="anonymous"></script>

Well, it seems that many rendering issues are done. But can we use something below in KaTeX?

% 定義指令
\newcommand{\water}{H_{2}O}
% 使用
\water

image

@VincentTam
Copy link
Author

VincentTam commented Dec 25, 2018

Thanks for your suggestion, but why don't we consider incorporating that into the project through a PR/a commit? In fact, many Hugo themes have chosen KaTeX instead of MathJax, such as BH, Finite, Minos, etc.

This has been documented in Macros section of supported functions.

$$\def\water{\rm H_2O} \rm 2\, H_2 + O_2 \to 2\, \water$$

@laozhu
Copy link
Owner

laozhu commented Dec 25, 2018

@VincentTam @Hsins Thanks for all of your suggestions, I haven't heard KaTeX before, but I will consider supporting KaTeX after an investigation.

Maybe KaTeX and MathJax can be both supported through a switcher in config.toml, the default is MathJax for compatibility, you can switch to KaTex if you like it.

@laozhu laozhu closed this as completed Dec 25, 2018
@laozhu laozhu mentioned this issue Dec 25, 2018
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants