korsbo / Latexify.jl

Convert julia objects to LaTeX equations, arrays or other environments.
MIT License
542 stars 55 forks source link

Incorrect Unicode to LaTeX Conversion for Double-Digit Subscripts #293

Closed bowenszhu closed 1 day ago

bowenszhu commented 1 week ago

Latexify.jl incorrectly converts Unicode characters for double-digit subscripts to LaTeX code. This issue appears to be present in version v0.16.3 and was originally discovered while investigating a problem with Symbolics.jl. See

The following code snippet demonstrates the issue:

using Latexify
str = "h₁₀ˏ₁₀ˏ₁₀"
Latexify.unicode2latex(str)

Expected Output: "h_{10}ˏ_{10}ˏ_{10}" Actual Output: "h_1_{0}ˏ_1_{0}ˏ_{1 0}"

The conversion splits double-digit subscripts like "₁₀" into separate single-digit subscripts ("1{0}"), leading to incorrect LaTeX output.

gustaphe commented 3 days ago
@latexify x₁₀

correctly creates $x_{1 0}$, so it's not really about double-digit subscripts, but rather whatever ˏ is. Your "expected" result is not legal LaTeX either (or rather, prints really weird). Unless this is common notation somewhere else in the ecosystem, I'm tempted to say that the latexrecipe for Symbolic matrices should generate a correct $h_{10,10,10}$.