Kolaru / Kolaru/MathTeXEngine.jl

Don't use minus sign in text block in math mode

Open
#168 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
106
Forks
25
PR merge metrics
No merged PRs in 30d

Description

When writing text in math mode using `\text{}`, the usual `-` symbol gets rendered as a minus instead of a short hyphen. Possibly related to https://github.com/Kolaru/MathTeXEngine.jl/issues/128 as it defines the exception for not using the minus symbol outside `$...$` delimiters, but even when in math mode usual LaTeX renders hyphens correctly when typesetting math using the 2 envs above.

Short way of reproducing it is to directly insert the hyphen unicode, which also serves as a workaround:
```julia
# normal way of writing using the - symbol
julia> generate_tex_elements(L"A_\text{1-2}")
4-element Vector{Any}:
(TeXChar 'A' [index 34 in NewComputerModern - 10 Italic], [0.0, 0.0], 1.0)
(TeXChar '1' [index 18 in NewComputerModern Math - Regular], [0.7429999709129333, -0.20000000298023224], 0.6)
(TeXChar '−' [index 853 in NewComputerModern Math - Regular], [1.0909999698400499, -0.20000000298023224], 0.6)
(TeXChar '2' [index 19 in NewComputerModern Math - Regular], [1.605799949169159, -0.20000000298023224], 0.6)

# using minus unicode symbol
julia> generate_tex_elements(L"$A_\text{1−2}$")
4-element Vector{Any}:
(TeXChar 'A' [index 34 in NewComputerModern - 10 Italic], [0.0, 0.0], 1.0)
(TeXChar '1' [index 18 in NewComputerModern Math - Regular], [0.7429999709129333, -0.20000000298023224], 0.6)
(TeXChar '−' [index 853 in NewComputerModern Math - Regular], [1.0909999698400499, -0.20000000298023224], 0.6)
(TeXChar '2' [index 19 in NewComputerModern Math - Regular], [1.605799949169159, -0.20000000298023224], 0.6)

# using the hyphen unicode symbol
julia> generate_tex_elements(L"$A_\text{1‐2}$")
4-element Vector{Any}:
(TeXChar 'A' [index 34 in NewComputerModern - 10 Italic], [0.0, 0.0], 1.0)
(TeXChar '1' [index 18 in NewComputerModern Math - Regular], [0.7429999709129333, -0.20000000298023224], 0.6)
(TeXChar '‐' [index 535 in NewComputerModern Math - Regular], [1.0429999709129334, -0.20000000298023224], 0.6)
(TeXChar '2' [index 19 in NewComputerModern Math - Regular], [1.242799973487854, -0.20000000298023224], 0.6)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the generate_tex_elements entry point and reproduce the three Julia examples for L"A_\text{1-2}" using the provided Unicode variants. Trace how the hyphen inside \text{} is converted to a TeXChar, then verify that the ordinary hyphen renders as a short hyphen while the existing minus behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, latex
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.