From 57747835a23bee7b7d791fa3cfd87c213cc248e7 Mon Sep 17 00:00:00 2001 From: karlwessel Date: Tue, 26 Nov 2024 15:55:19 +0100 Subject: [PATCH 1/2] fix latexify_recipes.jl for real values of type Complex A `Complex` value with no imaginary part `isreal` but is not comparable, but the real part is. --- src/latexify_recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index a36fd43d3..58dcdd3b4 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -185,7 +185,7 @@ function _toexpr(O) frac_expr = Expr(:call, :/, numer_expr, denom_expr) end - if isreal(m.coeff) && m.coeff < 0 + if isreal(m.coeff) && real(m.coeff) < 0 return Expr(:call, :-, frac_expr) else return frac_expr From 91b5dd9b79be1eba442c2fb51f04d2a5428f0e24 Mon Sep 17 00:00:00 2001 From: Karl Wessel Date: Wed, 27 Nov 2024 06:43:16 +0100 Subject: [PATCH 2/2] add test case for latexify of complex symbolics --- test/latexify.jl | 3 +++ test/latexify_refs/complex5.txt | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 test/latexify_refs/complex5.txt diff --git a/test/latexify.jl b/test/latexify.jl index 23d005cae..5d80cab52 100644 --- a/test/latexify.jl +++ b/test/latexify.jl @@ -55,6 +55,9 @@ Dy = Differential(y) @test_reference "latexify_refs/complex3.txt" latexify(1 - x + (1+2x)*im; imaginary_unit="\\mathbb{i}") @test_reference "latexify_refs/complex4.txt" latexify(im * Symbolics.Term(sqrt, [2])) +@syms c +@test_reference "latexify_refs/complex5.txt" latexify((3+im/im)c) + @test_reference "latexify_refs/indices1.txt" latexify(h[10,10]) @test_reference "latexify_refs/indices2.txt" latexify(h[10,10], index=:bracket) diff --git a/test/latexify_refs/complex5.txt b/test/latexify_refs/complex5.txt new file mode 100644 index 000000000..59f01d7aa --- /dev/null +++ b/test/latexify_refs/complex5.txt @@ -0,0 +1,3 @@ +\begin{equation} +4.0 c +\end{equation}