The story about italic correction in LuaLaTeX when using unicode-math
seems to be an old one. However, the issue does not appear to be fixed. Here is what it looks like with unicode-math
and without
Note the yellow box right to the second f, which indicates kerning. It looks even worse when using the Libertinus font, then the f and the > really overlap:
I guess this is because Libertinus defines the right border of the f to be different.
Here is the code used to generate the last screenshots:
%! TEX program = lualatex
\documentclass{article}
\usepackage{lua-visual-debug}
\usepackage{unicode-math}
\setmathfont{Libertinus Math}
% enable italic correction
\everymath\expandafter{\the \everymath \luatexcatcodetable\CatcodeTableLaTeX}
\everydisplay\expandafter{\th[enter image description here][4]e \everydisplay \luatexcatcodetable\CatcodeTableLaTeX}
\newcommand{\luatexcatcodetable}{}
\newcommand{\CatcodeTableLaTeX}{}
\newcommand*{\norm}[1]{{\ensuremath{\left\|{#1}\right\|}}}
\newcommand*{\inner}[1]{{\ensuremath{\left\langle{#1}\right\rangle}}}
\begin{document}
\[
\inner{f, f} \hspace{2em}
\norm{f}_2^2 \hspace{2em}
\inner{g, g} \hspace{2em}
\norm{g}_2^2 \hspace{2em}
\]
\end{document}
Also, dropping the \left
and \right
makes it looks as it should:
Unfortunately the once recommended workaround
\everymath\expandafter{\the\everymath\luatexcatcodetable\CatcodeTableLaTeX}
\everydisplay\expandafter{\the\everydisplay\luatexcatcodetable\CatcodeTableLaTeX}
gives me the following error:
! Undefined control sequence.
<inserted text> \@displaytrue \luatexcatcodetable
\CatcodeTableLaTeX
It looks like both commands \luatexcatcodetable
and CatcodeTableLaTeX
do not exist anymore. Adding
\newcommand{\luatexcatcodetable}{}
\newcommand{\CatcodeTableLaTeX}{}
makes my code compile (note that I did not have to use \renewcommand
!), but obviously this has then no effect on italic correction. Any idea how to get italic correction now?
\documentclass{article} \usepackage{mathtools,unicode-math} \setmathfont{Libertinus Math} \begin{document} \[ \langle f,f\rangle \quad \lVert f\rVert_2^2 \quad \langle g,g\rangle \quad \lVert g\rVert_2^2 \] \end{document}