Luatex – How to Enable Italic Correction for LuaTeX

italic-correctionluatexmath-modeopentype

LuaTeX ignores mathematical italic correction by default, as noted by Khaled Hosny.

This leads to some awful errors when using some alphabet which is very slanted, like XITS' mathematical script glyphs. For example, both $𝒯^*$ and $𝒯[ρ]$ result in intersecting glyphs. (As a side note, ConTeXt renders both correctly, while XeLaTeX renders the first correctly but not the second).

Khaled did propose a workaround, but since it involves rebuilding the format, I'm not interested. Also, I can't wait for the bugfix to happen (I have a thesis to deliver). So, is there a workaround that only involves some code in the preamble?

A solution for XeLaTeX would also be valuable for me, since it's very easy to switch to it (although I'd prefer to use LuaLaTeX).

Best Answer

If you are using AMSLaTeX, then, following Vafa Khalighi's email at http://tug.org/pipermail/tex-live/2011-October/030337.html you seem to need to do (1):

\everymath\expandafter{\the \everymath \luatexcatcodetable\CatcodeTableLaTeX}
\everydisplay\expandafter{\the\everydisplay \luatexcatcodetable\CatcodeTableLaTeX}

instead of simply (2)

\everymath{\luatexcatcodetable\CatcodeTableLaTeX}
\everydisplay{\luatexcatcodetable\CatcodeTableLaTeX}

I myself found on a big book with a lot of AMSLaTeX that LuaLaTeX gave errors with (2) but worked fine with (1).