MathJax inside SVG

前端 未结 3 1427
春和景丽
春和景丽 2021-02-03 23:59

I\'m doing some writing where I use MathJax to render the math. I also occasionally include SVG diagrams which are generated dynamically by javascript. Those SVG diagrams occasi

3条回答
  •  伪装坚强ぢ
    2021-02-04 00:12

    Currently, the only way to include MathJax within an SVG diagram is through . Yes, it is not ideal, not only because you need to provide a size, but also because IE9+ doesn't support .

    As for the SVG output, if you have used the MathJax contextual menu to select a math render, that will override the renderer choice in the document, so you may still be seeing HTML-CSS output for that reason. The value is stored in a cookie, so that it will be remembered from session to session. You can delete the cookie to remove the setting, or use the MathJax menu again to select SVG rendering.

    Note, however, that this isn't going to help you either, as MathJax's SVG output is not just an SVG snippet that can be included into a larger SVG file, but include some HTML and the element itself. Moreover, MathJax needs the surrounding HTML to determine things like the font-size to use, and some other factors, so it is not going to be able to placed directly into your SVG diagram.

    The approach is really the only reliable way at the moment.

    Edit: Here is a full example:

    
    
    
    MathJax in SVG diagram
    
    
    
    
      
      
      
        
    \(\displaystyle{x+1\over y-1}\)

提交回复
热议问题