I am trying to use unicode-math, newunicodechar and LuaLaTeX/XeLaTeX to write my LaTeX code making use of unicode characters in the source text.
This works fine, except for the prime character; if I try to use \newunicodechar
for it, it introduces errors if the prime is outside math mode.
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\usepackage{newunicodechar}
\newunicodechar{′}{any replacement character}
\begin{document}
This prime causes “Missing \$ inserted”: ′
\end{document}
Unfortunately, I can't restrict my use of the prime character to just math mode; I am writing literate Agda and wish to use the prime character in my code, and the LaTeX source produced by Agda is not in math mode.
Is there any workaround for this problem? As it stands, my only solutions seem to be avoiding prime in my code or running a script to replace instances of prime in the Agda generated LaTeX source.
unicode-math
redefines′
at begin document. Do\AtBeginDocument{\newunicodechar{′}{any replacement character}}
if you want to override it.unicode-math
for you to define one. If you want a "math" meaning for it, either (a)unicode-math
should provide something appropriate and if it doesn't maybe it should, OR (b) since it already has pretty clear semantics in a maths context, I'd suggest it shouldn't be changed.x
andx′
. So it is a "math" meaning, but I am not using it in math mode, because the Agda LaTeX backend does not place it (or any of my code) in math mode.