How can I render all inline formulas in $..$ with KaTeX?

前端 未结 3 759
无人及你
无人及你 2021-02-05 13:37

So I want to have KaTeX inline formulas like with MathJax.
But so far I\'ve found only render() function which \"draws\" a string to an element.
And I need

3条回答
  •  不知归路
    2021-02-05 14:36

    Yes, you can render all $-delimited formulas inline using KaTeX's auto-render extension. Per the documentation on that page, $ is not one of the default delimiters so you'll need to set it when you call renderMathInElement() and set display to false, which renders inline. Below is one example and another from KaTeX can be found here.

    Note that \\ in the JavaScript corresponds to \ in the HTML.

    
    
    
        
        
        
    
    
        
    The formula $a^2+b^2=c^2$ will be rendered inline, but $$a^2+b^2=c^2$$ will be rendered as a block element.

    The formula \(a^2+b^2=c^2\) will be rendered inline, but \[a^2+b^2=c^2\] will be rendered as a block element.

提交回复
热议问题