Symbolics.jl and Latexify.jl: customize latex representations?

adomasbaliuka
Sat, 27 Nov 2021 19:03:43 +0000
General Usage

(Julia 1.6)
I deal with equations from publications and the variables there have lots of subscripts and superscripts. They cannot be represented as Julia variable names and I would prefer not to compromise. For example, I might want something like this:

using LaTeXStrings,Latexify, Symbolics
@variables x_plus  # this is a variable
 # this is what I would like the variable to be written as
repr_map = Dict(x_plus => L"x^{+}_{A,\alpha_{1}}")

Now I want to do something like

@latexify x_plus + x_plus^2 + factorial(x_plus)
 # and also give the macro my `repr_map`, tell it somehow that I want factorial written as !...

and get x^{+}_{A,\alpha_{1}} + {(x^{+}_{A,\alpha_{1}})}^2 + (x^{+}_{A,\alpha_{1}})!.

Is there a way to do this? One thing I tried was modifying Latexify.jl (this file: Latexify.jl/…/function2latex.jl) to add my own symbols. This doesn’t really work for everything and of course having to modify the library isn’t a good solution. Is there a way to add “custom rules” to Latexify?

If there is no way currently, would such an idea be consistent with what Latexify.jl is trying to do? If so, I would be willing to help implement it.

5 posts - 3 participants