TL 2017 更新后,unicode-math 编译失败

TL 2017 更新后,unicode-math 编译失败

今天 TL 2017 更新后,以下 MWE 对我来说开始失败:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Pagella Math}
\setmathfont[range={`A-`Z,`a-`z,`0-`9}]{Charis SIL}
\begin{document}
Test.
\end{document}

错误是

! Missing number, treated as zero.
<to be read again> 
\__bool_A_0: 
l.4 ...thfont[range={`A-`Z,`a-`z,`0-`9}]{Charis SIL}

答案1

这个问题是由于\bool_if:NTF变得“贪婪”而导致的,所以它总是评估所有部分。这是 Joseph Wright 提出的解决方案,请参阅https://github.com/wspr/unicode-math/pull/393

\documentclass{article}
\usepackage{unicode-math}

\ExplSyntaxOn
\keys_define:nn {unicode-math}
 {
  range .code:n =
   {
    \bool_set_false:N \l__um_init_bool
    \int_incr:N \g__um_fam_int
    \tl_set:Nx \__um_symfont_tl {__um_fam\int_use:N\g__um_fam_int}
    \cs_set_eq:NN \__um_sym:nnn \__um_process_symbol_parse:nnn
    \cs_set_eq:NN \__um_set_mathalphabet_char:Nnn \__um_mathmap_parse:Nnn
    \cs_set_eq:NN \__um_remap_symbol:nnn \__um_remap_symbol_parse:nnn
    \cs_set_eq:NN \__um_maybe_init_alphabet:n \use_none:n
    \cs_set_eq:NN \__um_map_char_single:nn \__um_map_char_parse:nn
    \cs_set_eq:NN \__um_assign_delcode:nn \__um_assign_delcode_parse:nn
    \cs_set_eq:NN \__um_make_mathactive:nNN \__um_make_mathactive_parse:nNN
    \seq_clear:N \l__um_char_range_seq
    \seq_clear:N \l__um_mclass_range_seq
    \seq_clear:N \l__um_cmd_range_seq
    \seq_clear:N \l__um_mathalph_seq

    \clist_map_inline:nn {#1}
     {
      \__um_if_mathalph_decl:nTF {##1}
       {
        \seq_put_right:Nx \l__um_mathalph_seq
         {
          { \exp_not:V \l__um_tmpa_tl }
          { \exp_not:V \l__um_tmpb_tl }
          { \exp_not:V \l__um_tmpc_tl }
         }
       }
       {
        \seq_if_in:NnTF \g__um_mathclasses_seq {##1}
          { \seq_put_right:Nn \l__um_mclass_range_seq {##1} }
          {
            \bool_lazy_and:nnTF { \tl_if_single_p:n {##1} } { \token_if_cs_p:N ##1 } % <---- this one is the only changed line
              { \seq_put_right:Nn \l__um_cmd_range_seq {##1} }
              { \seq_put_right:Nn \l__um_char_range_seq {##1} }
          }
       }
     }
   }
 }
\ExplSyntaxOff

\setmathfont{TeX Gyre Pagella Math}
\setmathfont[range={`A-`Z,`a-`z,`0-`9}]{Charis SIL}

\begin{document}

Test.

\end{document}

相关内容