# \prime gives "Undefined control sequence" in xelatex with unicode-math

I cannot seem to be able to create a prime (') in any custom font. This, for example

\documentclass{article}
\usepackage{unicode-math, polyglossia}
\setmainfont{Times New Roman}
\setmathfont[range=\mathit/{latin,Latin}]{timesi.ttf}
\begin{document}
Hello, I want A-prime:
$$A^\prime.$$
\end{document}


gives "Undefined control sequence [ A^\prime]" error. I've tried A', A\prime, A^\prime, none works. Without the \setmathfont command, xelatex works fine, outputting the expected A' in the standard CM font. I found this: What is the right way to input prime with Unicode-math (LuaTeX backend) from 3 years ago, but they are concerned about the correct placement of prime, whereas for my example xelatex won't even recognise such command exists. I'd sure be grateful for any pointers.

• That font is not a math font. Oct 25, 2014 at 15:20
• I subset it for Latin letters only. Shouldn't it leave the symbols alone? Oct 25, 2014 at 15:28
• You see this even with 'proper' math mode fonts: I suspect it's a unicode-math bug Oct 25, 2014 at 15:33
• @AlexanderPavlov Say \setmathfont{TeX Gyre Termes Math}, or \setmathfont{texgyretermes-math.otf} if you haven't installed it on your system Oct 25, 2014 at 15:41

It seems that there are appearing bugs in unicode-math.

Here's a workaround: load the prime from a math font after loading the fonts. By the way, it's necessary to call \setmathfont with the original font after any others to set the correct “fontdimens”.

\documentclass{scrartcl}
\usepackage{unicode-math,polyglossia}
\setmainfont{Gentium}
\setmathfont[range=\mathit/{latin,Latin}]{Gentium Italic}
\setmathfont[range={"2032}]{TeX Gyre Pagella Math}
\setmathfont[range={\int}]{Latin Modern Math}
\begin{document}
Hello, I want A-prime: $A^\prime \textrm{ or } x'$
\end{document}


I used TeX Gyre Pagella Math because it looks better in my example, with Latin Modern Math you only need

\setmathfont[range=\mathit/{latin,Latin}]{Gentium Italic}
\setmathfont[range={"2032}]{Latin Modern Math}

• That does it for me, thank you! Should I try to report it, or is this behaviour by design for symbols missing in current font? Oct 29, 2014 at 5:11