Search code examples
julialatexatom-editorsymbolic-math

Latex output in Julia with Symbolics.jl


I am new in Julia and using Symbolics. I wanna make Latex output. In Symbolics' docs there is an easy example:

using Latexify
latexify(A) # A - some symbolic expression

And in their example they have a beautiful Latex output. But in my case I have Latex code as output.

julia> expr = 2x + y^2
       2x + y^2

julia> latexify(expr)
 L"\begin{equation*}
 2 x + y^{2}
 \end{equation*}
"

How can I fix it?


Solution

  • latexify produces an LaTeXString objects that does not provide any visualization of its own. However there are many renderers that can display contents havingtext/latex MIME type. Have a look at https://github.com/stevengj/LaTeXStrings.jl

    Perhaps your best bet is IJulia (Jupyter notebook)

    enter image description here

    Note that Symbolics object get correctly displayed regardless whether you use latexify.

    Another possible renderers could be plotting packages that support LaTeX annotations on plots via functions such as annotate!.