latex3 / unicode-math

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

Strange interaction between beamer, siunitx and unicode-math #318

Open itoijala opened 8 years ago

itoijala commented 8 years ago

The following:

\documentclass{beamer}
\usepackage{siunitx}
\usepackage{unicode-math}
\begin{document}
\begin{frame}
  $\mathbf{foo}$ % works with \symbf
  \setmathfont{XITS Math}
  $x$
\end{frame}
\end{document}

gives the error:

Runaway argument?
9@nil try@load@fontshape expandafter ifx csname curr@fontshape endcsname ETC.
! File ended while scanning use of \split@name.
<inserted text> 
par 
<*> foo.tex
josephwright commented 8 years ago

As you might expect, siunitx is only parenthetically involved here: you can get the same effect with

\documentclass{beamer}
\usepackage{unicode-math}
\begin{document}
\begingroup
  \setbox0=\hbox{\ensuremath{\mathsf{}}}
  \setbox0=\hbox{\ensuremath{\mathtt{}}}
\endgroup
\begin{frame}
  $\mathbf{foo}$ % works with \symbf

  \setmathfont{XITS Math}$x$
\end{frame}
\end{document}

(the method siunitx uses to pick up the active math font families). I'll see if I can trace this further.

CommunicationAnimale commented 6 years ago

It seems that the same issue prevents using \smashoperator or \cramped (from mathtools) even outside beamer :

\documentclass{article}

\usepackage{mathtools}
\usepackage{unicode-math}

\begingroup % or \usepackage{siunitx}
\setbox0=\hbox{\ensuremath{\mathsf{}}}
\setbox0=\hbox{\ensuremath{\mathtt{}}}
\endgroup

\begin{document}
\begin{align*}
    Z_\beta &= \smashoperator{\sum_{\sigma \in \left\{-1, +1\right\}^N}} e^{-\beta H(\sigma)} \\
    Z_\beta &= \sum_{\sigma \in \left\{-1, +1\right\}^N} e^{-\beta H(\sigma)}
\end{align*}
\end{document}

gives main

Removing the \begingroup ... \endgroup statement makes the black bar go away.

wspr commented 6 years ago

I'm sleep deprived but I've looked at this again and can't see where the issue is coming from. Will continue to investigate. (My answer to the OP would be: don't change the maths font mid-slide!)

Thanks @CommunicationAnimale for the additional comments.

wspr commented 6 years ago

@CommunicationAnimale — I've just tested your example with the most recent release of the package and it now appears fixed. Hopefully you see the same — please let me know (by opening a new issue) if you see it re-occur.