13

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.
<to be read again> 
                   \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 ?

Suresh
  • 16,511
  • 14
  • 55
  • 64

2 Answers2

13

An update to Ulrike's answer.

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.

Heiko Oberdiek
  • 271,626
6

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}
Ulrike Fischer
  • 327,261
  • 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