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).


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)


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

  • Could you give an example of the errors that happened with (2)? – Mateus Araújo Nov 7 '11 at 15:46
  • 1
    @MateusAraújo You'll remove anything that has already been set up by packages, etc., which alter math mode behaviour. The AMS Math system in particular needs to use these hooks, and without them all sorts will go wrong. – Joseph Wright Nov 9 '11 at 8:38
  • Just for future reference: to use this with TikZ' matrix of math nodes, ampersand replacement=\& is needed. – sr_ May 12 '12 at 9:00

Incidentally I was thinking about less invasive solution last night and it occurred to me using LuaTeX's catcode tables might help. The code below will reset catcodes to the "standard" LaTeX catcode table (whatever that means) inside math mode, I don't know what side effects this might have (hopefully none).

\setmathfont{XITS Math}


$𝒯^*$ \quad $𝒯[ρ]$

A better solution would involve saving the current catcode table, switching to \CatcodeTableLaTeX using \everymath and then switching back to the saved catcode table after math (but there seem not to be an "every after math" hook, so I've no idea how to do that), to localise the effect of switching catcode tables. Update: thanks to egreg's comment below, it seems switching catcode table inside \everymath is already localised to math mode.

  • Works like a charm! The little testing I did hasn't revealed any side effects yet. Have you ever got around to understanding XeTeX's problem? – Mateus Araújo Oct 13 '11 at 7:13
  • 3
    The catcode table change seems to be undone when math mode is left: if I put the catcode table change in \everymath and then ask for the catcode of 𝒯 after the formula, LuaTeX returns again 11. – egreg Oct 13 '11 at 8:29
  • Well this answer one of my questions on the luatex mailing list: As I suspected it is possible to reset the catcodes simply in the document. The second question remains: which letters are affected? On the luatex list is looked as if you meant the normal "P" (which I couldn't really believe) but here it looks more like special chars. Can you tell some of the affected unicode points? (At best simply the unicode numbers). – Ulrike Fischer Oct 13 '11 at 8:34
  • @egreg: thanks, I tried that and indeed the catcode outside math mode is not affected. I updated my answer. – Khaled Hosny Oct 13 '11 at 9:25
  • @UlrikeFischer: I don't know what Unicode code points are affected so I though resetting undoing the catcode part of luatex-unicode-letters.tex inside math mode would be the safest/easiest. By P I really meant U+1D443 (which what unicode-math will convert it to by default). – Khaled Hosny Oct 13 '11 at 9:34

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.