@@ -80,13 +80,13 @@ unicode_superscript(i) = unicode_superscripts[i+1]
80
80
# TERM
81
81
function _show (io:: IO , mime, t:: AbstractTerm )
82
82
if isconstant (t)
83
- print_coefficient (io, coefficient (t))
83
+ print_coefficient (io, mime, coefficient (t))
84
84
else
85
85
if should_print_coefficient (coefficient (t))
86
86
if ! should_print_coefficient (- coefficient (t))
87
87
print (io, ' -' )
88
88
else
89
- print_coefficient (io, coefficient (t))
89
+ print_coefficient (io, mime, coefficient (t))
90
90
if ! iszero (t)
91
91
# Print a multiplication sign between coefficent and monmomial
92
92
# depending on the mime type
@@ -110,8 +110,22 @@ print_maybe_multiplication_sign(io::IO, mime) = nothing
110
110
111
111
should_print_coefficient (x) = true # By default, just print all coefficients
112
112
should_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
115
129
116
130
# POLYNOMIAL
117
131
function _show (io:: IO , mime, p:: AbstractPolynomial{T} ) where T
0 commit comments