JuliaHomotopyContinuation / HomotopyContinuation.jl

A Julia package for solving systems of polynomials via homotopy continuation.
https://www.JuliaHomotopyContinuation.org
MIT License
175 stars 30 forks source link

LaTeX pretty printing breaks for (negative) exponents #569

Closed b-reinke closed 2 months ago

b-reinke commented 2 months ago

The LaTeX pretty printing of expressions works badly with superscripts that are more than one letter long:

Using jupyter,

using HomotopyContinuation
@var x
x^-1

produces the latex output $$x^(-1)$$ as the string x^(-1) is passed to the latex output more or less directly.

I think there are proper LaTeX printers in SymEngine, see for example https://symengine.org/symengine/classSymEngine_1_1LatexPrinter.html I don't know how to call them from Julia though.

b-reinke commented 2 months ago

My hotfix (using Latexify) is the following:

using Latexify
Base.show(io::IO, ::MIME"text/latex", z::Expression) = println(io, latexify(string(z)))

This is good enough for me at the moment, but I guess you can avoid using Latexify by using the LaTeX printer of SymEngine.

PBrdng commented 2 months ago

Okay, thanks for noticing. I will keep it in mind for the next update.