7

I would like to add italic correction at the end of inline math, depending on the italic correction of the last math character. Here is a MWE showing why I would like to have that:

%! TEX program = lualatex
\documentclass{article}

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}

\begin{document}
Some text interlaced with an \(f\) here.
\end{document}

As you can see, the f is pretty near the word "here". Of course I could just add some constant space, but ideally LaTeX would use the italic correction provided from the math font. In that way, only characters that lean heavily to the right would get an additional space (provided the font has correct italic correction). Is that possible?

I tried adding \/ both at the end of the math (\(f\/\)) and after the math mode (\(f\)\/), but neither had any effect. Using \(f\) \/ had some effect, though I guess latex just inserted an additional space there, not really the italic correction.

4
  • 1
    If you want \/ to have an effect you have to set \mathitalicsmode=1. Apr 27 at 8:04
  • @HenriMenke Right, that works. In my original situation I actually had it enabled, but also had \(overline f\), and only tried \(\overline f\/\) instead of \(\overline{f\/}\). This is why I figured it had no effect... Apr 27 at 8:11
  • Is this a kerning problem in the particular fonts? May 4 at 9:13
  • @AndrewSwann No it is not. The Libertinus font has correct kernings and italics correction. It just is not applied by latex. May 27 at 9:06

1 Answer 1

6

If one adds \mathitalicsmode=1, the italic correction \/ will have an effect inside math mode. Also note that if one uses a command, like \(\overline{f}\), then \/ has to be added inside the braces, so only \(\overline{f\/}\) works as intended. So this example works as intended:

%! TEX program = lualatex
\documentclass{article}

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}

\mmathitalicsmode=1

\begin{document}
Some text interlaced with an \(f\/\) here. Again with an overline \(\overline{f\/}\) here.
\end{document}

working italic correction

1
  • 1
    I assume that the \overline problem pertains to the same issue as the previously discussed sub_mlist ({f,f}\rangle). Apr 27 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.