Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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}
\everymath\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).

share|improve this answer
    
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).

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}

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

\begin{document}
$𝒯^*$ \quad $𝒯[ρ]$
\end{document}

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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