Second derivatives in Latexify

omerc
Wed, 26 Nov 2025 12:10:25 +0000
General Usage

Hi,
I’m using the Symbolics package to generate a partial differential equation, and then Latexify to turn that into a Latex string for use in a manuscript that I’m writing.
Essentially, I’m trying to write down the Laplacian of some function:

using Symbolics, Latexify, SymbolicUtils
@variables x[1:4]
@variables f(x...)
laplacian = sum(Symbolics.derivative.(Symbolics.gradient(f, [x...]), [x...]))

which seems to correctly produce the sum of second derivatives:

Differential(x[3], 2)(f(x[1], x[2], x[3], x[4])) + Differential(x[4], 2)(f(x[1], x[2], x[3], x[4])) + Differential(x[1], 2)(f(x[1], x[2], x[3], x[4])) + Differential(x[2], 2)(f(x[1], x[2], x[3], x[4]))

However, when using Latexify to create a Latex representation of this expression,

println(latexify(laplacian, env=:inline))

the result is
\frac{\mathrm{d}}{x_{3}} f\left( x_{1}, x_{2}, x_{3}, x_{4} \right) + \frac{\mathrm{d}}{x_{4}} f\left( x_{1}, x_{2}, x_{3}, x_{4} \right) + \frac{\mathrm{d}}{x_{1}} f\left( x_{1}, x_{2}, x_{3}, x_{4} \right) + \frac{\mathrm{d}}{x_{2}} f\left( x_{1}, x_{2}, x_{3}, x_{4} \right)
without indicating that the derivatives are second order, as in Differential(x[i], 2).
Also, the denominators are missing the “d” of the differentials.

Am I misusing any of the functions here, or is this a bug/missing feature? And is there an easy workaround/solution to this?

Thanks in advance!

1 post - 1 participant