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

make \operator@font protected #550

Closed u-fischer closed 10 months ago

u-fischer commented 4 years ago

Description

the unicode-math definition of \operator@font is not expandable but currently fragile. This leads to problems e.g. with hyperref.

Add info or delete as appropriate:

[x] Relevant for XeTeX [x] Relevant for LuaTeX [x] Issue tracker has been searched for similar issues? [x] e.g. https://tex.stackexchange.com/q/548178/2388

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math}
\usepackage{hyperref}
%\makeatletter
%\ExplSyntaxOn
%\cs_set_protected:Npn \operator@font
%  {
%    \__um_switch_to:n {literal}
%    \__um_fontswitch:n { \g__um_operator_mathfont_tl }
%  }
%\ExplSyntaxOff
%\makeatother

\begin{document} 
\tableofcontents

\section{$\cos $}%
test
\end{document}

This errors with

! Improper alphabetic constant.
<to be read again> 
\math@bgroup 
l.29 \section{$\cos $}

Making the command protected solves the problem.