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 operator in figure caption results in failure. #493

Open neboat opened 5 years ago

neboat commented 5 years ago

Description

Using unicode-math version 0.8m, installed with TeX Live 2018, causes math operators in figure captions to fail with the following error:

! Undefined control sequence.
\__um_fontswitch:n ...ath@bgroup \__ummath@bgroup 
                                                  \cs_set_eq:NN \math@egroup...

l.10   \caption{Test caption $i \bmod 64$.}

I am observing this issue on Mac OS X 10.13.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}

\usepackage{unicode-math}

\begin{document}

\begin{figure}
  \caption{Test caption $i \bmod 64$.}
\end{figure}

\end{document}

Further details

Based on the error message, this issue seems to be related to #492.

eg9 commented 5 years ago

\bmod has always been a fragile command. If you comment out unicode-math, add \listoffigures and compile with pdflatex, the .lof file will contain

\contentsline {figure}{\numberline {1}{\ignorespaces Test caption $i \nonscript \mskip -\medmuskip \mkern 5mu\mathbin {\mathgroup \symoperators mod}\penalty 900\mkern 5mu\nonscript \mskip -\medmuskip 64$.}}{1}

Use \protect\bmod when the command is used in a moving argument.

On the other hand, it would probably be a good addition if unicode-math makes the command robust.

neboat commented 5 years ago

Thanks @eg9 for the quick response and for reminding me about \protect. Thus far I've only seen this issue affect fragile math operators, such as \bmod or \sin (without amsmath).