I’m having trouble with XeLaTeX (0.9998) and unicode-math (0.7a). If I use \setmathfont more than twice, the \sqrt command breaks when a superscript is specified.

\setmathfont{Latin Modern Math}
\setmathfont[range=\mathup/{num,latin,Latin}]{Linux Libertine O}
\[ \sqrt[5]{2} \]

If I typeset this code, XeLaTeX will produce the following error

Font \l_tmpb_font has only 8 fontdimen parameters.

If I remove the superscript from \sqrt or remove the last \setmathfont command, the document compiles correctly. I’ve tested this code with several OTF files, and they all produced the same result. (I know the resulting superscript is improperly positioned, but I can work on this once I know the document can be typeset.)

I filed a bug for this issue on GitHub because I believe it’s a problem with the package, but I should have checked here before doing so, and I will gladly close the bug if I find I was doing something stupid.

  • 2
    You forgot to activate the mathmode $\sqrt[5]{2}$. – Marco Daniel Aug 13 '12 at 16:10
  • I have no issues with the demo if I tidy it up (for example, use font file names rather than names, use math fonts in all cases, etc.). – Joseph Wright Aug 13 '12 at 16:28
  • @Joseph: But it should be possible to use non-math-fonts for special symbols. For me \setmathfont[range=\mathrm]{Arial} breaks too – but only if I use the optional argument of \sqrt: $\sqrt[5]{2}$. – Ulrike Fischer Aug 13 '12 at 16:49
  • 1
    Agh! I apologize, but my original post should have included \[ \] around the \sqrt command. The error occurs when math mode is invoked; my original example obviously fails for other reasons. – AstroPig7 Aug 13 '12 at 17:23
  • 1
    @UlrikeFischer: Exactly.The radical and the vinculum for the square root should come from Latin Modern Math, and the superscript should come from Linux Libertine O since I only defined it for numbers and Latin characters. This is why I suspect the culprit is the package itself, since the problem only occurs if a second \setmathfont is defined for a range. – AstroPig7 Aug 13 '12 at 17:33

Tracing through the code, the issue is that unicode-math redefines \r@@t, which is used by LaTeX when it typesets a root with an index. The redefinition is different for LuaTeX and XeTeX, so you only see the issue with XeTeX. In that case, it is

\cs_set_nopar:Npn \r@@t #1 #2 {
  \hbox_set:Nn \l_tmpa_box {
    \sqrtsign { #2 }
  \um_mathstyle_scale:Nnn #1 { \kern } {
    \fontdimen 63 \l_um_font
  \box_move_up:nn {
    (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box)
    * \number \fontdimen 65 \l_um_font / 100
  } {
    \box_use:N \rootbox
  \um_mathstyle_scale:Nnn #1 { \kern } {
    \fontdimen 64 \l_um_font
  \box_use_drop:N \l_tmpa_box

The key here is the \fontdimen business: these are 'high number' font dimensions which are not available in traditional TeX. As such, these are not defined for text fonts: they are only available for 'proper' Unicode math fonts. You therefore see the error only if you set up some symbols to be taken from a text font.

  • Thank you! I only know enough LaTeX3 to be dangerous, so digging through the style definition proved useless to me. – AstroPig7 Aug 13 '12 at 17:59
  • @AstroPig7 At present, the code here is a bit of a mishmash, to be honest, so it's more a question of knowing what might be up (the error immediately suggested something to me). – Joseph Wright Aug 13 '12 at 18:00
  • Wait, what: \fontdimen 64? Do you know where could I find more information about those higher fontdimens? – morbusg Aug 13 '12 at 18:20
  • 3
    @morbusg: they are documented at the end of unicode-math manual. – Khaled Hosny Aug 13 '12 at 18:31

Obviously unicode-math maps the last font set with \setmathfont to \l_um_font and then uses it in \r@@t to get the \fontdimen values. So you could try as a workaround to remap \l_um_font to your "main" math font:

\setmathfont{Latin Modern Math}
\setmathfont[range=\int]{Latin Modern Math}
\[ \sqrt[5]{2} \mathbb{ABC} \]

I'm not quite sure what unicode-math should do in this situation, but probably \r@@t should use the font of the actual radical symbol. (And it should sort out the redefinitions of \r@@t. at line 2098 is looks as if it would redefine only when amsmath is not loaded but later on it does it anyway. Very confusing ;-).)

  • Yes, I found the AMS stuff rather odd, and like you I'm not sure quite what is 'right' here. – Joseph Wright Aug 14 '12 at 9:23
  • I added your suggestion to my test document and it worked like a charm. I’m currently adding all of the other symbols and alphabets I need to see if anything else breaks. – AstroPig7 Aug 15 '12 at 14:42

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.