Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve printing of rational number #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# 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
Loading