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 ?

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

2 Answers 2

12

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.

3
  • Hmm. my texlive installation is 2011 and I can't merely install the 2012 version of hyperref using tlmgr.
    – Suresh
    Aug 29, 2012 at 21:53
  • I can't find this feature in the documentation of hyperref with TeXlive 2016. Is it out of sync?
    – cjorssen
    Sep 8, 2016 at 9:01
  • @cjorssen Option psdextra is documented in the README. Sep 8, 2016 at 17:04
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}
1
  • 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, 2012 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.