Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question
    
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
add comment

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer
    
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
add comment

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}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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