haskellmathjaxhaskell-diagrams

How to place latex-like mathematical formulas (e.g. via mathjax) in Haskell Diagrams?


I am attempting to place latex-style math formulas into a haskell diagram.

The documentation pages http://projects.haskell.org/diagrams/doc/manual.html#essential-concepts and http://projects.haskell.org/diagrams/doc/tutorials.html suggest that one can use something called 'mathjax' to achieve this.

Is there an explanation or example somewhere of how to actually code this?


Attempting to follow the documentation at those links, my best guess for how would be something like:

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

But this of course gives an error:

induction.hs:13:35: error:
    lexical error in string/character literal at character 's'

Solution

  • You can do this using the diagrams-pgf backend. Just use the text function and put dollar signs around your text. Also, see here for an explanation of how to include diagrams in a LaTeX document: http://projects.haskell.org/diagrams/doc/latex.html .