希腊字体为Katex [英] Greek fonts for Katex
问题描述
(Matjax非常擅长渲染希腊字母)
是否有Katex字体可用于渲染包含希腊字符的公式?如何使用这些字体(如何将它们与我的网站上的Katex脚本一起使用)?
例如,等式
hν0= hv + Ek + W(1)
(v是\ nu)用mathjax渲染效果很好,但是不能和Katex一起渲染。解析方案
不同的公式 - 渲染js库行为有三种不同的方式:
- 进程
\pi
并且容忍π
(MathJax; MathQuill,尽管结果有所不同)
- 进程
\pi
code>但不能容忍 - 不处理
\pi
并容忍π
(jqMath)
不幸的是,像Ben一样回答,KaTeX并不是容忍原始希腊字符的人。然而,你可能会尝试做一些预解析,以这样的方式修复:在之前
< script> ; renderMathInElement(document.body,{分隔符:
[{left:$,right:$,display:false}]
});< / script>
添加一些替换的东西,如desribed (用
\pi $ c替换
π
$ c>等等),但是应该修改replaceTextOnPage
函数,以便一次性替换所有希腊字母,而不是启动replaceTextOnPage
多次。你可以做一些其他的优化,因为解决方案有一些普遍的用途,但你知道在哪里期望你的页面上的公式。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.
解决方案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 modifyreplaceTextOnPage
function proposed there to replace all greek letters at once rather than launch a copy ofreplaceTextOnPage
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.这篇关于希腊字体为Katex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- process
π
(jsMath,KaTeX)