Greek fonts for Katex

2019-09-13 19:42发布

I suceeded to use katex on my blog instead of MathJax. However some of the equations contained greek symbols and Katex does not contain the fonts for rendering the greek characters. (Matjax is very good at rendering the greek letters) Are there Katex fonts available to render an equation that contains greek characters? How to use these fonts (how to include them together with the Katex script on my site)?

For example the equation

hν0=hν+Ek+W(1)     

(ν is \nu) is rendering good with mathjax but not with Katex.

2条回答
做个烂人
2楼-- · 2019-09-13 20:20

Different formulae-rendering js libs behave in one of 3 different ways:

  • process \pi and tolerate π​​ (MathJax; MathQuill, although the result is somewhat different)
  • process \pi but don't tolerate π​​ (jsMath, KaTeX)
  • don't process \pi and tolerate π​​ (jqMath)

Unfortunately, like Ben has answered, KaTeX is not the one that tolerates raw greek characters. However, you may try to do some pre-parsing to "fix" this in a manner like this: before

<script>renderMathInElement(document.body,{delimiters:
  [{left: "$", right: "$", display: false}]
});</script>

add some "replace" stuff like desribed here (replace π with \pi and so on), although you should modify replaceTextOnPage function proposed there to replace all greek letters at once rather than launch a copy of replaceTextOnPage many times. You can do some other optimization since the solution there is somewhat general purpose but you know where to expect formulae on you pages.

查看更多
孤傲高冷的网名
3楼-- · 2019-09-13 20:22

KaTeX doesn't currently support Greek letters as input, though as the comment says, \nu does work. See this issue for more details: Symbol unicode replacement doesn’t work

查看更多
登录 后发表回答