问题
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