代码之家  ›  专栏  ›  技术社区  ›  mherzl

如何在Haskell图中放置类似latex的数学公式(例如,通过mathjax)?

  •  2
  • mherzl  · 技术社区  · 9 年前

    我试图将latex风格的数学公式放入haskell图中。

    http://projects.haskell.org/diagrams/doc/manual.html#essential-concepts http://projects.haskell.org/diagrams/doc/tutorials.html 建议可以使用“mathjax”来实现这一点。

    是否有一个解释或示例,说明如何实际编写代码?


    尝试按照这些链接的文档进行操作,我的最佳猜测是:

    mathDiagram :: Diagram B
    mathDiagram = stroke $ textSVG "`2 + \sqrt{\pi}`:math:" 1
    

    但这当然给出了一个错误:

    induction.hs:13:35: error:
        lexical error in string/character literal at character 's'
    
    1 回复  |  直到 9 年前
        1
  •  2
  •   Brent Yorgey    9 年前

    您可以使用 diagrams-pgf 后端。只要使用 text 函数并在文本周围放置美元符号。此外,有关如何在LaTeX文档中包含图表的说明,请参见此处: http://projects.haskell.org/diagrams/doc/latex.html .

    推荐文章