2

I am making (almost) my first attempt with unicode-math and this is my first use of the STIXTwo fonts. I'm unhappy with the spacing around italic f in math mode. (And with the spacing before italic j in some cases.) I'm using Lualatex (up-to-date TL2021) and STIXTwo fonts from their Github site.

Can I adjust this somehow (in Latex, I have no font editor)? If so, will I need to specify an adjustment for every pair? I found this link, Change kerning for `f'` in math mode , but it did not help. This link (Two letter variable names) suggests that the problem is italic correction, and this one (Ugly spacing around f in math mode) indicates that the problem is with a math-mode bounding box. (Can I adjust that box?)

If it's possible, could someone show me the syntax of how to adjust a pair or two, so that I can go do others? (And if it's possible to just modify f itself or its "bounding box" instead of a bunch of pairs, that would of course be terrific.)

Here's an expression taken from the first link above that I think produces ugly output with unicode-math+STIXTwo:

\documentclass[varwidth,margin=10pt]{standalone}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{STIXTwoText-Regular}
\setmathfont{STIXTwoMath-Regular}

\begin{document} [ \frac{2\pi ft}{k} ] \end{document}

enter image description here

dedded
  • 2,236
  • 1
    Unrelated: unicode-math loads fontspec, so no need to load it manually. – Cicada Feb 14 '22 at 06:18
  • In ConTeXt this is possible via so-called goodie files. I don't know if there is a counterpart for LaTeX. But, are you sure you want to do this? Try for example e_2f^b. There is not too much space to take. – mickep Feb 14 '22 at 07:54
  • The more I look at the formula, the more I see the necessity of the italic correction. – egreg Feb 14 '22 at 09:11
  • @mickep So it looks like I would need to specify specific pairs, maybe just other letters after and letters and digits before. But is that possible? – dedded Feb 14 '22 at 12:31
  • As far as I know, configuring the kerning between specific pairs in math is not doable. But is this the true formula (it looks like the one in the question you linked to), or do you have some other real-life example where it looks worse? – mickep Feb 14 '22 at 13:04
  • This particular formula was copied from that other page. But 2πf is angular frequency (ω) and is common. And thus 2πft is angle. You also see a fair bit of df/dt in signals work. If it's known that math kerning is not possible, I'd accept that as an answer (unfortunately). – dedded Feb 14 '22 at 13:21

1 Answers1

0

You can kern.

Here I use \!\,:

italic f

I don't have STIX2, but TexGyrePagella shows the same.

MWE

\documentclass[varwidth,margin=10pt]{standalone}
%\usepackage{fontspec}
\usepackage{unicode-math}
%\setmainfont{STIXTwoText-Regular}
%\setmathfont{STIXTwoMath-Regular}
\setmainfont{TexGyrePagella}
\setmathfont{TexGyrePagellaMath}

\begin{document} [ \frac{2\pi ft}{k} ] [ \frac{2\pi f!,t}{k} ] \end{document}

Cicada
  • 10,129
  • Do texdoc latex2e, "16.6 Spacing in math mode", might help. – Cicada Feb 14 '22 at 06:20
  • With a macro solution, I would need to use it every time I use an f. I was hoping I could set something up once and get it over with. – dedded Feb 14 '22 at 12:29
  • Just an aside, you likely have an older STIXTwo available, looks like both Texlive 2020 and 2021, at least, came with it: texlive/2021/texmf-dist/fonts/opentype/public/stix2-otf/STIXTwoMath-Regular.otf – dedded Feb 14 '22 at 12:35
  • Latex2e manual says: One advantage of these commands is that they automatically insert italic corrections if needed (see Section 19.9 [\/], page 163). Specifically, they insert the italic correction unless the following character is in the list \nocorrlist, which by default consists of a period and a comma. To suppress the automatic insertion of italic correction, use \nocorr at the start or end of the command argument, such as \textit{\nocorr text} or \textsc{text \nocorr}. and There is no concept of italic correction in math mode; spacing is done in a different way. – Cicada Feb 15 '22 at 01:02
  • Would redefining unicode-maths \mitf macro be worthwhile: \UnicodeMathSymbol{"1D453}{\mitf }{\mathalpha}{mathematical italic small f}% (unicode-math-table.tex line 1535), or maybe defining a new symbol instead? However, some correction must be needed for italic f anyway, because of its lean: that is, see what f{} does. – Cicada Feb 15 '22 at 01:12
  • I'm not sure what you're suggesting. Redefine \mitf to what?

    In any case, looks like macros are the way to go, since no one seems to think spacing can be done another way.

    Do tables of kerning pairs even exist in the fonts for math mode? Or is that a text mode thing only?

    – dedded Feb 15 '22 at 02:43
  • (a) Redefine math italic f to cancel out italic correction. (b) kerning tables for maths - ask a separate question. Also, lua code could handle it. But wouldn't it be an open-ended set, since it's not only symbol x symbol, but also symbol x operator (plus user-defined symbols and operators). Possible, since the standard glyphs are all in the Math unicode blocks in the (unicode) font. Lot of work: ~1000 x 256 pairings. (c) Italic correction was done for a purpose; removing it will make things "wrong" to others. (d) You are in effect asking to design your own ligature(s), at the limit. – Cicada Feb 15 '22 at 07:06
  • I believe that both (a) and (b, if it can be done in Latex) are this question. I don't understand how to do either. But I'm not in for 1000x256, of course. Just f paired with a few others. If that's not possible, I'm out-of-luck, but will accept that as an answer. – dedded Feb 15 '22 at 12:45