6

When changing the math font using \mathversion under unicode-math, math operator commands (such as \lim or \cos) lead to an error message stating "math alphabet identifier \mathrm is undefined in math version..." (although three clicks past the error prompts will get to correct output). The error message is eliminated by resetting the operator font manually, e.g., as \setoperatorfont\symup. The MWE below illustrates this behavior; it is set up to produce the error for the GFS fonts but not for the Fira fonts.

The unicode-math documentation (sections 4.4.1 and 4.4.3) seems to suggest that \mathrm should be automatically reset when switching math versions, but the error message claims it's not. The problem can also be manually eliminated by adding to the preamble a command like \setmathfontface\mathrm[version=GFS]{GFS Neohellenic Math}; however, as I read the documentation, this should not be necessary.

So, my question is whether there may be something off in the code I'm using or in my understanding of unicode-math?

The specific choice of fonts is not important to the problem, so far as I can see.

% !TEX TS-program = lualatex
% !TEX encoding = UTF-8 Unicode

\documentclass[11pt]{article}
\usepackage{mathtools} 
\usepackage{xparse}

\usepackage[math-style=TeX]{unicode-math}

\setmainfont[]{STIX Two Text}
\setmathfont[Scale=MatchUppercase]{STIX Two Math} 

\setmathfont[version = Fira, Scale=MatchUppercase]{Fira Math}

\setmathfont[version = GFS, Scale=MatchUppercase]{GFS Neohellenic Math}
% \setmathfontface\mathrm[version=GFS]{GFS Neohellenic Math}  %... unclear that this should be needed, but does resolve the matter if used...

%%%  Environments for changing text and math fonts
\DeclareDocumentEnvironment{Firasans}{}{%
   \setmainfont{FiraGO}[Scale=MatchUppercase]\mathversion{Fira}\setoperatorfont\symup}{%
}

\DeclareDocumentEnvironment{GFSsans}{}{%
   \setmainfont{GFS Neohellenic}[Scale=MatchUppercase, WordSpace=0.7]\mathversion{GFS}}{%\setoperatorfont\symup}{ % commented out for illustration
}

%%% An equation and some text to use 
\DeclareDocumentCommand{\Equation}{}{%
   \[ \lim_{n\rightarrow\infty} \lim_{m\rightarrow\infty} \cos^{2n}\left( m!\pi x \right) = \begin{cases} 1 & \text{if $x$ is rational} \\ 0 & \text{if $x$ is irrational} \end{cases} 
   \]
}

\DeclareDocumentCommand{\Proof}{}{%
   \paragraph{Proof:} If $x$ is rational, then $x = p/q$ for integers $p$ and $q$. As $m$ becomes large, eventually $m!$ will include $q$ as a factor\ldots%
}

%%%
\begin{document}

\Equation\Proof\bigskip

\begin{Firasans}
   \Equation\Proof
\end{Firasans}

\bigskip

\begin{GFSsans}
   \Equation\Proof
\end{GFSsans}

\end{document}

enter image description here

enter image description here

  • Have you tried \text{...} instead of \mathrm? – Sebastiano May 29 '18 at 20:59
  • Add an issue to the issue tracker of unicode-math (simplify the example, don't use firamath). – Ulrike Fischer May 29 '18 at 22:02
  • @Ulrike Fischer - FiraGO and Fira Math can be replaced by another free text/math pairing, such as Tex Gyre Terms and Tex Gyre Terms Math. – John May 29 '18 at 22:10
  • @John There is no need to use three math fonts, already with mathversion GFS you can demonstrate the problem. – Ulrike Fischer May 29 '18 at 22:13
  • 1
    Just for completeness: github.com/wspr/unicode-math/issues/468 – TeXnician May 30 '18 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.