Skip to content

Commit

Permalink
Fix text/latex printing of Interval sets (#3537)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Oct 7, 2023
1 parent 9460a0e commit c3183d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions test/test_print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit c3183d6

Please sign in to comment.