[XeTeX] unicod-math testing / siunitx

Joseph Wright joseph.wright at morningstar2.co.uk
Fri May 28 08:56:26 CEST 2010


On 28/05/2010 07:14, Will Robertson wrote:
> This gist of the problem was that siunitx was using things like
>
> \setbox\si at tempboxa=\hbox{%
> $\mathsf{\global\chardef\si at fam@sf=\fam}$}%
>
> and then
>
> \ifnum\the\fam=\si at fam@sf
>
> to detect when maths alphabets were available.
>
> Since unicode-math doesn't use a different fam for each alphabet those
> tests were breaking.
>
> (The current implementation of unicode-math very inefficiently uses
> mathcode remapping to effect the maths font switching. But at least it
> works and is flexible for now. Future plans are to merge breqn's
> "everything active" approach to improve efficiency and compatibility
> with that package.)
>
> I haven't actually checked yet, however, whether siunitx v2 gives
> correct output while inside a unicode-math \mathsf. I'd be surprised if
> it did.

The approach hasn't really changes:

\cs_set_protected_nopar:Npn \_siunitx_set_math_fam:n #1 {
   \int_new:c { _c_siunitx_math #1 _int }
   \group_begin:
     \hbox_set:Nn \_l_siunitx_tmp_box
       {
         \ensuremath
           {
             \use:c { math #1 }
               {
                 \int_gset:cn { _c_siunitx_math #1 _int } { \fam }
               }
           }
       }
   \group_end:
}
\tl_put_right:Nn \document {
   \_siunitx_set_math_fam:n { sf }
   \_siunitx_set_math_fam:n { tt }
}

How should math family be picked up when unicode-math is loaded? I can 
soon fork the detection method if I know what I'm looking for.
--
Joseph Wright


More information about the XeTeX mailing list