@@ -80,13 +80,13 @@ unicode_superscript(i) = unicode_superscripts[i+1]
8080# TERM
8181function _show (io:: IO , mime, t:: AbstractTerm )
8282 if isconstant (t)
83- print_coefficient (io, coefficient (t))
83+ print_coefficient (io, mime, coefficient (t))
8484 else
8585 if should_print_coefficient (coefficient (t))
8686 if ! should_print_coefficient (- coefficient (t))
8787 print (io, ' -' )
8888 else
89- print_coefficient (io, coefficient (t))
89+ print_coefficient (io, mime, coefficient (t))
9090 if ! iszero (t)
9191 # Print a multiplication sign between coefficent and monmomial
9292 # depending on the mime type
@@ -110,8 +110,22 @@ print_maybe_multiplication_sign(io::IO, mime) = nothing
110110
111111should_print_coefficient (x) = true # By default, just print all coefficients
112112should_print_coefficient (x:: Number ) = ! isone (x) # For numbers, we omit any "one" coefficients
113- print_coefficient (io:: IO , coeff:: Real ) = print (io, coeff)
114- print_coefficient (io:: IO , coeff) = print (io, " (" , coeff, " )" )
113+ # `Int`, `Float64` don't support MIME"text/latex".
114+ # We could add a check with `showable` if a `Real` subtype supports it and
115+ # the feature is requested.
116+ print_coefficient (io:: IO , mime, coeff:: Real ) = print (io, coeff)
117+ # JuMP expressions supports LaTeX output so `showable` will return `true`
118+ # for them. It is important for anonymous variables to display properly as well:
119+ # https://github.com/jump-dev/SumOfSquares.jl/issues/256
120+ function print_coefficient (io:: IO , mime, coeff)
121+ print (io, " (" )
122+ if showable (mime, coeff)
123+ show (io, mime, coeff)
124+ else
125+ show (io, coeff)
126+ end
127+ print (io, " )" )
128+ end
115129
116130# POLYNOMIAL
117131function _show (io:: IO , mime, p:: AbstractPolynomial{T} ) where T
0 commit comments