# Strange error when unicode-math and hyperref are combined in xelatex

The following is an MWE for a problem that I'm facing:

\documentclass{article}

\usepackage{hyperref}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\begin{document}
\section{$2\times 2$}
$2 \times 2$
\end{document}


When compiling this with xelatex, I get the following error:

! Improper alphabetic constant.
\times
l.7 \section{$2\times 2$}


But the error goes away if I remove the inclusion of the hyperref package.

Now obviously I'd like to be able to use math in a section header, and with pdflatex the compilation is fine (except for hyperref grumbling about math in bookmarks, which can be fixed by other means).

So is there something I'm doing wrong with xelatex ?

-
Have you tried setting a different font encoding? This looks a lot like a problem I once had. –  canaaerus Aug 29 '12 at 17:28
I haven't, but then I don't know too much about font encodings in general. –  Suresh Aug 29 '12 at 20:24

With hyperref 2012/08/13 v6.83a you can use option unicode (or pdfencoding=auto) together with option psdextra:

\usepackage[unicode,psdextra]{hyperref}[2012/08/13]


Then lots of mathematical symbols including \times are recognized.

-
Hmm. my texlive installation is 2011 and I can't merely install the 2012 version of hyperref using tlmgr. –  Suresh Aug 29 '12 at 21:53

You can use \texorpdfstring to tell hyperref to use another text for the bookmarks:

\documentclass{article}

\usepackage{hyperref}
\usepackage{unicode-math}
\setmathfont{Asana Math}
\begin{document}
\section{\texorpdfstring{$2\times 2$}{2\texttimes2}}
$2 \times 2$
\end{document}

-
Sure. and that's what I was referring to when I said there are "other ways" of dealing with this in pdflatex. But I guess I was puzzled as to why this was happening. –  Suresh Aug 29 '12 at 19:30