3

I'd like to manually fix some longstanding spacing issues between certain pairs of capital letters in Latin Modern Math, such as UF and YX. Because these pairs represent actual products, I'd rather not write \mathit{UF} on every occasion. Here's my attempt:

\documentclass{article}
\usepackage{unicode-math}
\directlua{
  fonts.handlers.otf.addfeature {
    name = "lmkern",
    type = "kern",
    data = {
      [0x1D434] = { [0x1D435] = -100 },
      [0x1D448] = { [0x1D439] = -100 },
      [0x1D44C] = { [0x1D44B] = -100 }
    }
  }
}
\setmathfont[RawFeature=+lmkern]{Latin Modern Math}
\begin{document}
\showoutput
$AB_{AB}$\quad$UF_{UF}$\quad$YX_{YX}$
\end{document}

The relevant bits of the output are:

....\TU/LatinModernMath(1)/m/n/10 
....\kern-1.0 (font)
....\TU/LatinModernMath(1)/m/n/10 
....\hbox(4.991+0.0)x12.61394, shifted 2.46974, direction TLT
.....\TU/LatinModernMath(1)/m/n/7 
.....\TU/LatinModernMath(1)/m/n/7 
....\TU/LatinModernMath(1)/m/n/10 
....\kern1.05 (italic)
....\TU/LatinModernMath(1)/m/n/10 
....\hbox(4.781+0.14)x11.66193, shifted 2.46974, direction TLT
.....\TU/LatinModernMath(1)/m/n/7 
.....\kern0.581 (italic)
.....\TU/LatinModernMath(1)/m/n/7 
....\TU/LatinModernMath(1)/m/n/10 
....\kern2.09 (italic)
....\TU/LatinModernMath(1)/m/n/10 
....\hbox(4.781+0.0)x13.28593, shifted 2.46974, direction TLT
.....\TU/LatinModernMath(1)/m/n/7 
.....\kern1.463 (italic)
.....\TU/LatinModernMath(1)/m/n/7 

What is the meaning of \kern … (italic)? How can I specify kerning for subscripts (or smaller font sizes), and how can I override the italic kerning?

  • I've had the same question some time ago and asked on the ConTeXt (or was it LuaTeX?) mailing list how to do this and got the answer “use mathkerns”, but I still don't know how to do that. – Henri Menke Jul 08 '20 at 01:50
  • Here we go: https://mailman.ntg.nl/pipermail/ntg-context/2019/094714.html – Henri Menke Jul 08 '20 at 01:55
  • \kern … (italic) is the italic correction, by the way. – Henri Menke Jul 08 '20 at 03:59
  • @HenriMenke If I understand this question correctly, it is about the case which you listed as "works fine" in that question: Kerning between "regular" characters (potentially in subscripts). That isn't really supported currently because mathematical content never hits the usual shaping callbacks and even if it did, automatically inserted kerns suppress most kerning opportunities. (The last thing is IIRC less of an issue in ConTeXt whereitalic correction is normally zero) – Marcel Krüger Jul 08 '20 at 04:43
  • @HenriMenke About mathkerns: There is some code for applying them in LaTeX at the end of the following answer: https://tex.stackexchange.com/a/505003/80496 – Marcel Krüger Jul 08 '20 at 04:44
  • @HenriMenke Thanks, I found your link before, but I didn't see a way to adapt a .lfg file to the current context. Also, my question was about the difference between a regular \kern, which is explained in the TeXbook, and these categorized kerns LuaTeX reports. But now I see that they are just good old italic corrections (applied in places where they aren't needed?), only that plain TeX doesn't label those kerns as such. – photon.engine Jul 08 '20 at 05:12
  • Italic corrections are totally needed, otherwise fj would show up like in text and be way too close together. Compare \textit{fj} \textit{f\/j} $fj$ – Henri Menke Jul 08 '20 at 06:29
  • @HenriMenke Upon further reflection I think I'm mistaken: There is no italic correction per se (i.e. \/) in math mode, even though the kerns in $YX$ and \textit{f\/j} are both reported as "italic" kerns by LuaTeX. My question is rather: What is the difference between "italic" and "font" kerns, a difference that doesn't exist for TeX? Does the font decide which pairs receive "italic" kerns (e.g., UF but not AB), and can I override that decision? I was hoping there may be a simpler fix than what @MarcelKrüger suggested. – photon.engine Jul 08 '20 at 08:49

0 Answers0