Latexify generating incorrect output with accented strings


Been hitting issues with Latexify-generated expressions when using accented characters. A simple example:

using Symbolics, Latexify
@variables x̄ ȳ z
latexify(x̄ + ȳ + z)
# Gives x\bar + z + ȳ

This is incorrect as LaTeX math environments place accents over the following character rather than the preceding (or at least in my environments?), so the \bar that should be over “x” is over the “+”. Is this easily fixed?

Additionally, I think it would be preferable to generate the typical LaTeX representation for accented characters even when the unicode character already exists as in ȳ, but not sure if this is possible.

On my system (Julia v1.8.5 with Latexify v0.15.18), I get from your code

\textnormal{\={x}} + z + \textnormal{\={y}}

which also renders correctly in LaTeX (well, up to re-ordering the terms…). Could latexify be dependent on some system-specific things?

PS: I don’t have a lot of experience with Latexify so far (only when using it in some plots and it did have some hiccups there, but that seemed to be a problem with the plotting library), so I don’t know much about the internals of latexify.

Ah yep, I get the same output after updating my Julia version and Latexify. Change might’ve come from commit 187ad86 in Latexify. Turns out there was an easy fix.

1 Like

Nice! Thanks for the info

Any particular reason? I think most people nowadays are using XeLaTeX or LuaLaTeX, which are fully Unicode aware.

But not all LaTeX generators are fully unicode aware, so a method using only ASCII characters e.g. \bar{y} works for all users, but using Unicode characters only works for a subset of users. In any case, the newest version of Latexify (v0.15.18) generates “\textnormal{\={y}}” from

@variables ȳ

so it’s a moot point I think.