latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
239 stars 28 forks source link

math font in DeclareMathOperator broken (again?) #492

Closed alllexx88 closed 5 years ago

alllexx88 commented 5 years ago

Description

The issue symptoms are very similar to #449: code like \DeclareMathOperator{\Op}{\mathbf{OB}} fails with:

! Undefined control sequence.
\use@mathgroup #1#2->\math@bgroup 
                                  \cs_if_eq:cNF {M@\f@encoding }#1{#1}\__um_...

l.8     $\Op

unicode-math is version 0.8m installed via TeX Live 2018. Tested on Ubuntu and Windows OS's.

Check/indicate

Minimal example demonstrating the issue

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

\DeclareMathOperator{\Op}{\mathbf{OB}}

\begin{document}
    $\Op$
\end{document}

Further details

Another thing I noticed is that if you load amsmath after unicode-math, there's no such error. However, amsmath spits Unable to redefine math accent \mathring warning, and all math operators (user-defined, or not, like \sin, \cos, etc.) become italic instead of upright; that's why it's not a proper workaround, and anyway I guess unicode-math is expected to be loaded after amsmath, right?

And yet another thing. This is also somehow relevant to mathtools package: it you load packages in the following order: \usepackage{mathtools,unicode-math,amsmath}, you get the same error from above. Something gets broken when unicode-math is being loaded after amsmath/mathtools.

eg9 commented 5 years ago

The package does

\cs_set:Nn \__um_fontswitch:n
  {
    \cs_set_eq:NN \math@bgroup     \scan_stop:
    \cs_set_eq:NN \__um_group_begin: \scan_stop:
    \cs_set:Npn \__um_group_end:n % takes no argument in this case
      {
        \cs_set_eq:NN \__um_group_begin:  \__um_group_begin_frozen:
        \cs_set_eq:NN \__um_group_end:n   \__um_group_end_frozen:n
        \cs_set_eq:NN \math@bgroup \__ummath@bgroup
        \cs_set_eq:NN \math@egroup \__ummath@egroup
      }
    \cs_set_eq:NN \math@egroup \__um_group_end:n
    #1 \scan_stop:
  }

but fails to define \__ummath@bgroup and \__ummath@egroup, which is the cause for the “Undefined control sequence” error.

wspr commented 5 years ago

I thought I’d fixed this — I might have forgotten to do a release. Sorry, will try to address ASAP

alllexx88 commented 5 years ago

@eg9 Thank you for clarifying this :+1: @wspr OK, waiting patiently, thanks :smile: btw, version 0.8l, which is provided by Ubuntu 18.04 texlive 2017 package, works fine: the issue is with the latest 0.8m release.