I'm trying to display CJK characters as part of math formulae in XeLaTeX, and it's not working well. I've tried a number of options, and all have failed:
- Defining a
\jp
font command viafontspec
and then using\text{\jp{character}}
. This gives me an undefined control sequence error. - Using
fontspec
's\setmathfont
. This also gives me an undefined control sequence error. - Using the
unicode-math
package with\setmathfont[range="4E00-"2FA1F]{font}
- depending on the range, CJK characters either still display as the 'unavailable character' box or simply disappear
A minimal failing example:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{CMU Serif}
\newfontfamily\jp{TakaoPGothic}
\usepackage{unicode-math}
\setmathfont[range="96E2]{TakaoPGothic} % the code for this particular character
\setmathfont{CMU Serif}
\begin{document}
$離$
\jp{離}
\end{document}
This produces a missing-character box on the first line, and rightly outputs 離 on the second.
Is there any good way to do this?