# \newunicodechar fails for PRIME only

I'm using Beamer with the XeTeX backend and initially I got lots of warnings of the following form:

[WARNING] Missing character: There is no ∙ in font [lmmono10-regular]:!

So I went and added \newunicodechar commands for each of them, e.g.

\newunicodechar{∙}{\makebox[\fontcharwd\fonta]{$\bullet$}}


And they all work, I've got almost 30 lines all similar for various Unicode characters. However, this fails for the unicode PRIME character ′. Once I add the following line:

\newunicodechar{′}{\makebox[\fontcharwd\fonta]{$\prime$}}


I start getting the following error:

Error producing PDF.
! TeX capacity exceeded, sorry [input stack size=5000].
\__um_scanprime_collect:N ...canprime_collect:N #1
}{\peek_meaning_remove:NTF...
l.277 ...erTok{→} \DataTypeTok{Set} \OtherTok{_}


I'm using Beamer via Pandoc if that matters.

• I get no error if unicode-math is not used; I get a different error than stated if I load unicode-math. Anyway, you should do \AtBeginDocument{\newunicodechar{′}{\makebox[\fontcharwd\fonta]{$\prime$}}} – egreg Oct 8 at 12:15

Judging from the error message you're using unicode-math.

The problem is that this package assigns a value to the “active ′” at begin document, thus overriding what your \newunicodechar does.

Solution: postpone \newunicodechar.

\documentclass{article}
\usepackage{unicode-math}
\usepackage{newunicodechar}

\AtBeginDocument{\newunicodechar{′}{\makebox[\fontcharwd\fonta]{$\prime$}}}

\begin{document}

a′

\end{document}

• Thanks! I'm not using unicode-math myself, but I guess Pandoc includes it automatically. – Cactus Oct 8 at 13:46