|
1 |
| -struct CustomLaTeXPrint end |
| 1 | +struct CustomLaTeXPrint |
| 2 | + s::String |
| 3 | +end |
2 | 4 |
|
3 |
| -Base.:-(::CustomLaTeXPrint) = CustomLaTeXPrint() |
| 5 | +Base.:-(s::CustomLaTeXPrint) = s |
4 | 6 | Base.iszero(::CustomLaTeXPrint) = false
|
5 |
| -function Base.show(io::IO, ::MIME"text/latex", ::CustomLaTeXPrint) |
6 |
| - return print(io, " \$\$ \\[\\(a_a \\) \\]\t \$\$") |
| 7 | +function Base.show(io::IO, ::MIME"text/latex", s::CustomLaTeXPrint) |
| 8 | + return print(io, s.s) |
7 | 9 | end
|
8 | 10 |
|
9 | 11 | @testset "Show" begin
|
|
57 | 59 | @test sprint(print, 2x[1]^2 + 3x[3] + 1 + x[4]) ==
|
58 | 60 | "1 + x[4] + 3*x[3] + 2*x[1]^2"
|
59 | 61 |
|
60 |
| - a = CustomLaTeXPrint() |
| 62 | + a = CustomLaTeXPrint(" \$\$ \\[\\(α_β∀ \\) \\]\t \$\$") |
61 | 63 | @test sprint((io, x) -> show(io, "text/latex", x), term(a, x[1]^2)) ==
|
62 |
| - "\$\$ (a_a)x_{1}^{2} \$\$" |
| 64 | + "\$\$ (α_β∀)x_{1}^{2} \$\$" |
63 | 65 | @test sprint(
|
64 | 66 | (io, x) -> show(io, "text/latex", x),
|
65 | 67 | polynomial([a, a], [x[1]^2, x[2]]),
|
66 |
| - ) == "\$\$ (a_a)x_{2} + (a_a)x_{1}^{2} \$\$" |
| 68 | + ) == "\$\$ (α_β∀)x_{2} + (α_β∀)x_{1}^{2} \$\$" |
| 69 | + # Test that the check for `\\)` handles unicode well |
| 70 | + a = CustomLaTeXPrint("\\(β∀") |
| 71 | + @test sprint((io, x) -> show(io, "text/latex", x), term(a, x[1]^2)) == |
| 72 | + "\$\$ (\\(β∀)x_{1}^{2} \$\$" |
67 | 73 | end
|
0 commit comments