Greek fonts for Katex

*爱你&永不变心* 提交于 2019-12-12 02:53:23

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/36666141/greek-fonts-for-katex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!