Skip to content

Commit

Permalink
Improve printing of rational number
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 21, 2024
1 parent ba3697f commit 26ae5d3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ __needs_parens(a::AlgebraElement) = true
# We could add a check with `showable` if a `Real` subtype supports it and
# the feature is requested.
print_coefficient(io::IO, ::MIME, coeff::Real) = print(io, coeff)
function print_coefficient(io::IO, ::MIME"text/latex", coeff::Rational)
print(io, "\\frac{")
print(io, coeff.num)
print(io, "}{")
print(io, coeff.den)
print(io, "}")

Check warning on line 20 in src/show.jl

View check run for this annotation

Codecov / codecov/patch

src/show.jl#L15-L20

Added lines #L15 - L20 were not covered by tests
end
# Scientific notation does not display well in LaTeX so we rewrite it
function print_coefficient(io::IO, ::MIME"text/latex", coeff::AbstractFloat)
s = string(coeff)
Expand Down

0 comments on commit 26ae5d3

Please sign in to comment.