From 754141ab36a6e5f7aa7e0cfbef51c1c819e2d0c4 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Mon, 2 Sep 2024 14:52:23 +0200 Subject: [PATCH 1/2] Suppress identity transformation in Latexified expressions --- src/latexify_recipes.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 2b42953d1..7f801b6c9 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -230,6 +230,8 @@ function _toexpr(O) return :(solve($(_toexpr(args[1])), $(_toexpr(args[2])))) elseif issym(op) && symtype(op) <: AbstractArray return :(_textbf($(nameof(op)))) + elseif op === identity + return _toexpr(only(args)) # suppress identity transformations (e.g. "identity(π)" -> "π") end return Expr(:call, Symbol(op), _toexpr(args)...) end From 2759c1b3142b07aeb9a496f100f2ad22ba862c06 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Mon, 2 Sep 2024 15:10:45 +0200 Subject: [PATCH 2/2] Add test --- test/latexify.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/latexify.jl b/test/latexify.jl index d5249abc8..23d005cae 100644 --- a/test/latexify.jl +++ b/test/latexify.jl @@ -57,3 +57,5 @@ Dy = Differential(y) @test_reference "latexify_refs/indices1.txt" latexify(h[10,10]) @test_reference "latexify_refs/indices2.txt" latexify(h[10,10], index=:bracket) + +@test !occursin("identity", latexify(Num(π))) # issue #1254