Skip to content

Commit 4cff607

Browse files
authored
Merge pull request #96 from JuliaAlgebra/fix-show
Fix show for variables with indices larger than 9
2 parents dcf9c6c + c7df915 commit 4cff607

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/show.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function print_subscript(io::IO, mime, indices)
2929
end
3030

3131
const unicode_subscripts = ("","","","","","","","","","")
32-
unicode_subscript(i) = unicode_subscripts[i+1]
32+
unicode_subscript(i) = join(unicode_subscripts[d+1] for d in digits(i))
3333

3434
# MONOMIALS
3535

test/show.jl

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
@test sprint(show, sum(i*x[i]^i for i=1:10)) == "10x₉¹⁰ + 9x₈⁹ + 8x₇⁸ + 7x₆⁷ + 6x₅⁶ + 5x₄⁵ + 4x₃⁴ + 3x₂³ + 2x₁² + x₀"
3131
@test sprint(show, "text/latex", sum(i*x[i]^i for i=1:10)) == "10x_{9}^{10} + 9x_{8}^{9} + 8x_{7}^{8} + 7x_{6}^{7} + 6x_{5}^{6} + 5x_{4}^{5} + 4x_{3}^{4} + 3x_{2}^{3} + 2x_{1}^{2} + x_{0}"
3232

33+
Mod.@polyvar x[1:11]
34+
@test sprint(show, "text/latex", x[11]) == "x_{11}"
35+
@test sprint(show, x[11]) == "x₁₁"
36+
3337
# #This is only supported by DynamicPolynomials so far
3438
# Mod.@polyvar A[1:2, 1:2]
3539
# @test sprint(show, sum(A)) == "A₁₋₁ + A₂₋₁ + A₁₋₂ + A₂₋₂"

0 commit comments

Comments
 (0)