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.

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.

\documentclass{minmal}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=\mathup/{num,latin,Latin}]{Linux Libertine O}
\setmathfont[range=\mathup/{greek,Greek}]{Symbola}
\begin{document}
\[ \sqrt[5]{2} \]
\end{document}

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.

share|improve this question
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
    
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
    
@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
add comment

2 Answers

up vote 6 down vote accepted

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 {
    \c_math_toggle_token
    \m@th
    #1
    \sqrtsign { #2 }
    \c_math_toggle_token
  }
  \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_clear: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.

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

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:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=\mathbb]{Arial}
\setmathfont[range=\int]{Latin Modern Math}
\begin{document}
\[ \sqrt[5]{2} \mathbb{ABC} \]
\end{document}

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

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

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.