Bug in 3.141592653-2.6-0.999995 (TeX Live 2023) with fontspec and tabularray?

Zdenek Wagner zdenek.wagner at gmail.com
Tue Jan 30 12:50:55 CET 2024


Hi all,

hyphen is one of places where linebreak is allowed, it is something
like implicite \discretionary{}{}{-}. It is penalized by
\exhyphenpenalty thus if you increase this penalty to 10000, linebreak
will not be allowed there but still allowed elsewhere. Anyway, I agree
that from the typographical reasons you should use math minus, not a
hyphen if you write negative numbers.

Zdeněk Wagner
https://www.zdenek-wagner.eu/

út 30. 1. 2024 v 12:41 odesílatel Bruno Voisin via tex-live
<tex-live at tug.org> napsal:
>
> > Ross Alexander wrote:
> >
> > When formatting a tabular with tabularray and setting \mainfont{Latin Modern Roman}[Scale=0.80] some cells are have incorrect line breaks.  This only happens in very particular circumstances, where the scale is set to exactly 0.8, the font is Latin Modern Roman (or TeX Gyre Termes) and this is the mainfont.  This doesn't happen if I use lualatex.
>
>
> When using tblr from tabulararray (second and third tables in your code):
>
> - The first time you're loading the font with
>
>         \setmainfont{Latin Modern Roman}[Scale=0.80]
>
> and the input -6" in the second column say gives output
>
>         -
>         6"
>
> where the minus sign is the hyphen glyph (U+002D HYPHEN MINUS), and the inch symbol the quotedblright glyph (U+201D RIGHT DOUBLE QUOTATION MARK).
>
> - The second time you're using
>
>         \newfontfamily{\lmscaleeight}{Latin Modern Roman}[Scale=0.8]
>         \lmscaleeight
>
> and the output is
>
>         -6"
>
> where the minus sign is the same and the inch symbol is now quotedbl (U+0022 QUOTATION MARK).
>
> As Jonathan Fine wrote, it seems your "-" is interpreted as a hyphenation character (TeX's \hyphenchar) the first time, causing the tabulararray package to insert a line break after it -- why I've no idea, I've never used that package --, but not the second time.
>
> \setmainfont and \newfontfamily do different things. It seems one initializes \hyphenchar while the other doesn't; they also deal with your input " differently. I tried looking at their code in the fontspec source, but it's all LaTeX 3 and I'm hopeless at it.
>
> Setting HyphenChar yourself, as in
>
>         \setmainfont{Latin Modern Roman}[Scale=0.80,HyphenChar=None]
>
> would prevent hyphenation. (But it would prevent it everywhere, not only in the tables.)
>
> As written in the fontspec doc, HyphenChar is a XeTeX-specific thing. LuaTeX treats hyphenation differently, it bypasses TeX's normal hyphenation mechanism and introduces its own, based on \prehyphenchar which affects all fonts and cannot be set individually per font.
>
> That said, I cannot understand why LuaTeX gets things right in your case, given the default value of \prehyphenchar is precisely "-".
>
> Anyway, the above would not be the proper way to go. To get a proper minus sign, matching the plus sign (same width, amongst other things), you should use something like
>
>         \RequirePackage{fontspec}
>         \RequirePackage{unicode-math}
>
>         \setmainfont{Latin Modern Roman}[Scale=0.80]
>         \setmathfont{Latin Modern Math}[Scale=0.80]
>
> then switch to math mode, using $-6"$ in the table. (Loading unicode-math after fontspec but before loading any text font causes fontspec to do specific things when loading the text font afterwards, preparing it for math.)
>
> All in all, I think the problem is in fontspec, tabularray or your use of them, not TeX Live, XeTeX nor Latin Modern.
>
> Hope this helps,
>
> Bruno Voisin
>
>
>
>
>



More information about the tex-live mailing list.