unicode math in xelatex

In XeTeX, an unicode version of TeX, it's logical to use unicode math. However, till now (march 2010) unicode math publishing doesn't work directly out of the box. Here are two solutions, one is fast (and not so wrong) and one is probably the future standard.

The LaTeX code to compile is:

\documentclass{minimal}
...SOMETHING...
\begin{document}
$$\sin(\alpha+\beta) = \sin α \cos β + \cos\alpha \sin\beta$$
$$\int\!\!\!\int_D dx\,dy$$
\end{document}

Note that "alpha" and "beta" are written both as command sequences and as unicode characters.

The part marked "...SOMETHING..." is a placeholder for setup.

Fast, no so wrong way

If the goal is only to:

* allow the greek letters as unicode symbols, and
* it is not important which math font is used,

then the simplest solution is:

* make the greek letters active,
* define the greek letters as the corresponding commands:

Replace the placeholder "...SOMETHING..." with:

\catcode`\^^^^03b1=13
\let^^^^03b1=\alpha
\catcode`\^^^^03b2=13
\let^^^^03b2=\beta

Repeat it for the all possible letters.

unicode-math package

This package is not yet released on CTAN. Latest developmental and archived historical versions of this package are available from GitHub: http://github.com/wspr/unicode-math.

Given that the author, Will Robertson, is also the author of such packages as fontspec, xltxtra, euenc etc, I think that unicode-math will be a standard way to have unicode math in XeLaTeX.

After installing this package, I succesfully compiled the test document using the following "...SOMETHING...":

\usepackage{unicode-math}
\setmathfont{[Asana-Math]}

The font Asana-Math can be found on TeX Live 2009 DVD (and probably on 2007 and 2008 too). The square brackets around the name forces xelatex to search for a .otf/.ttf-file instead of getting the font from OS. In my case, xelatex somehow found the font automatically, I didn't need to give the full path.

Categories: TeX

Updated: