Q: using Latexify.jl in VS Code

Hello,

I would like to display an equation using Latexify in the VS Code IDE.
The MWE is

# test_latexify_main.jl

using Symbolics
using Latexify 

function main()

    @variables x, t
    @variables Φ(x, t)

    Dx = Differential(x)
    D2x = Dx * Dx

    Dt = Differential(t)

    # Dimensionless simple reaction-diffusion equation
    ∂Φ∂t = D2x(Φ) - Φ^2
    println("∂Φ∂t = ", ∂Φ∂t, "\n")

    display(latexify(∂Φ∂t))

end

begin
    main()

end

which I runs as a script in the Julia REPL
julia> include(“test_latexify_main.jl”)

resulting in the output to terminal

∂Φ∂t = Differential(x)(Differential(x)(Φ(x, t))) - (Φ(x, t)^2)

L"\begin{equation}
 - \left( \Phi\left( x, t \right) \right)^{2} + \frac{d(d / (d * x))(\Phi(x, t))}{dx}
\end{equation}

How to render this to a PDF or graphical image?

Julia 1.7.3
Windows 11

You need render not display.

https://korsbo.github.io/Latexify.jl/stable/#External-rendering

Thanks for your suggestion and link.

I had tried using render rather than display as per the documentation

render(latexify(∂Φ∂t))

which resulted in the following output

julia> include("test_latexify_main.jl")
∂Φ∂t = Differential(x)(Differential(x)(Φ(x, t))) - (Φ(x, t)^2)

L"\begin{equation}
 - \left( \Phi\left( x, t \right) \right)^{2} + \frac{d(d / (d * x))(\Phi(x, t))}{dx}
\end{equation}
"
dvilualatex: security risk: running with elevated privileges
ERROR: LoadError: failed process: Process(`dvilualatex --interaction=batchmode 'C:\Users\AUDRIU~1\AppData\Local\Temp\jl_Pf2Br11rCk.tex'`, ProcessExited(1)) [1]

I have no idea what the above error message means.

It means this command failed:

dvilualatex --interaction=batchmode 'C:\Users\AUDRIU~1\AppData\Local\Temp\jl_Pf2Br11rCk.tex'

To debug it, try opening PowerShell (or some other shell if you have a favorite), and run

cd C:\Users\AUDRIU~1\AppData\Local\Temp
dvilualatex --interaction=batchmode jl_Pf2Br11rCk.tex

This may be off topic, but unless you need to generate a lot of these fully automatically, you might want to try something like KLatexFormula with the latexify code pasted in. It’s easier to control the latex enviro, make adjustments, choose output format, etc.

2 Likes

You also need the package: “LaTeXStrings” to render a LaTeX-String
i.e.

using Latexify, LaTeXStrings
latexify(L"\Huge\int_0^\infty \frac{x^3}{e^x-1},dx = \frac{\pi^4}{15}", render=true);

Ran your example in a script and directly in the REPL.
Same error message for both

julia> using LaTeXStrings
julia> using Latexify
julia> latexify(L"\Huge\int_0^\infty \frac{x^3}{e^x-1},dx = \frac{\pi^4}{15}", render=true);
ERROR: failed process: Process(`lualatex --interaction=batchmode 'C:\Users\AUDRIU~1\AppData\Local\Temp\jl_9VPRJ56YK7.tex'`, ProcessExited(1)) [1]

Perhaps you have another problem in your OS ?

On my PC the script and in the REPL the LaTEX-strings are rendered correct.
.

Julia (not in VSC) renders a .PDF