2

I was confronted with a problem that maybe there exists some clash between package amsmath and hyperref. An MEW is like this:

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\section{$\cdots$}
\end{document} 

There is no problem using PDFlatex. But Xelatex can not pass. The error says Improper alphabetic constant. If one of amsmath or hyperref is deleted, or we write \section* instead of \section, the compiling with Xelatex is no problem. And also, the problem is the same if we change \cdots to \dotsc,\dotsb,\dotsm,\dotso. But \dotsi can pass. I really don't know why. Any advice will be appreciate.

  • Welcome to TeX.SX! What if you use \section[alternative text]{origonal text} where alternative text will be used in the table of contents,...? – leandriis Jan 1 at 13:32
  • Thanks! If I use \section[$\dots$]{$\cdots$}, the compiling is right. But the error still appears if i use \section[$\cdots$]{$\cdots$}. – Misaya Jan 1 at 13:46
  • 2
    Use \texorpdfstring to separate the bookmark from text. – Ulrike Fischer Jan 1 at 14:09
  • Got it! Thanks a lot! – Misaya Jan 2 at 0:50
2

Use \texorpdfstring:

\documentclass{article}
\usepackage{amsmath}
\usepackage[unicode]{hyperref}


\begin{document}

\section{\texorpdfstring{$\cdots$}{\textcdots}}

\end{document} 

The unicode option is recommended with xelatex.

enter image description here

| improve this answer | |
  • Got it! Thank you very much! – Misaya Jan 2 at 0:56
  • Emm, I meet with another problem tex \documentclass{article} \usepackage{amsmath} \usepackage[unicode]{hyperref} \begin{document} \tableofcontents \subsection{\texorpdfstring{$w=\sqrt[\leftroot{-2}\uproot{6}n]{(z-a_1)^ {\beta_1}\cdots(z-a_m)^{\beta_m}}$}{anything is wrong}} \end{document} There is something wrong when producing a table of contents. – Misaya Jan 2 at 1:01
  • @Misaya Add \MakeRobust\leftroot and \MakeRobust\uproot before \begin{document} – egreg Jan 2 at 9:26
  • Pecfectly done, thanks again! – Misaya Jan 2 at 12:06

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.