From c3183d6ff7714d6a13c4ae019d94b58ccc27b1e1 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Sat, 7 Oct 2023 15:46:26 +0200 Subject: [PATCH] Fix text/latex printing of Interval sets (#3537) --- src/print.jl | 2 +- test/test_print.jl | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/print.jl b/src/print.jl index 521f1b860d2..c48269fafb1 100644 --- a/src/print.jl +++ b/src/print.jl @@ -741,7 +741,7 @@ end function in_set_string(::MIME"text/latex", set::MOI.Interval) lower, upper = _string_round(set.lower), _string_round(set.upper) - return string("\\in \\[", lower, ", ", upper, "\\]") + return string("\\in [", lower, ", ", upper, "]") end function in_set_string(mode::MIME"text/plain", set::MOI.Interval) diff --git a/test/test_print.jl b/test/test_print.jl index faae676ec67..761f5776e69 100644 --- a/test/test_print.jl +++ b/test/test_print.jl @@ -502,8 +502,7 @@ function test_extension_printing_scalaraffinefunction_constraints( @test sprint(show, "text/latex", linear_le) == "\$\$ x \\leq 1 \$\$" @test sprint(show, "text/latex", linear_ge) == "\$\$ x \\geq 1 \$\$" @test sprint(show, "text/latex", linear_eq) == "\$\$ x = 1 \$\$" - @test sprint(show, "text/latex", linear_range) == - "\$\$ x \\in \\[-1, 1\\] \$\$" + @test sprint(show, "text/latex", linear_range) == "\$\$ x \\in [-1, 1] \$\$" @test sprint(show, "text/latex", linear_noname) == "\$\$ x \\leq 1 \$\$" return end @@ -963,4 +962,9 @@ function test_print_model_with_huge_integers() return end +function test_print_text_latex_interval_set() + @test in_set_string(MIME("text/latex"), MOI.Interval(1, 2)) == "\\in [1, 2]" + return +end + end