Luxor.jl icon indicating copy to clipboard operation
Luxor.jl copied to clipboard

Incorrect rendering of Latex string with braces

Open bmxam opened this issue 8 months ago • 5 comments

Hi, I'm trying to render this (simple) Latex string with Luxor : L"\{42\}":

using Luxor
using MathTeXEngine

d = @draw begin
    fontsize(30)
    text(L"\{42\}", O)
end
display(d)

but the result is incorrect:

Image

It seems to me that the problem is coming from this line: https://github.com/JuliaGraphics/Luxor.jl/blob/0a9c129c3adbcb7cee5930181403b31ef1906924/ext/latex.jl#L205

Commenting this line leads to the correct (and expected) result. Could you please explain me why there is such a treatment for the braces? I won't dare to suggest removing it since I guess it was introduced for a good reason...

bmxam avatar Mar 19 '25 19:03 bmxam

Hi! Thanks ! I didn’t do any of the LaTEX stuff (since I don’t know LaTEX) so I can’t explain, and I can only assume this was an adjustment required for one use of curly braces that doesn’t work for others. Perhaps it’s a font-related thing?

If you can improve any of the LaTeX-handling code, it would be appreciated!

cormullion avatar Mar 19 '25 21:03 cormullion

Well I could submit a PR where this elseif bloc is removed but that wouldn't be a good idea if we don't know why the author of these lines wrote them...

bmxam avatar Mar 21 '25 07:03 bmxam

I’ll risk a ping - @davibarreira - sorry! Can you remember?

cormullion avatar Mar 21 '25 09:03 cormullion

Hey, folks! So this is based on MathTeXEngine.jl, which pretty much takes the latex string and returns the information for each character, such as placement and size. When I wrote the code, I used a specific version of MathTeXEngine, which had some issues depending on the character. Hence the manual corrections you see. If commenting this line makes it work, it is probably cause the character is now working "out of the box"! So feel free to modify.

davibarreira avatar Mar 21 '25 12:03 davibarreira

@davibarreira Thanks for revisiting Luxor!

cormullion avatar Mar 21 '25 12:03 cormullion

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jun 26 '25 20:06 stale[bot]