286

Possible Duplicate:
Hyperref warning - Token not allowed in a PDF string

The following code:

\subsection{The classes $\mathcal{L}(\gamma)$}

generates the errors:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `math shift' on input line 1938.


Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\gamma' on input line 1938.


Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `math shift' on input line 1938.

What do I have to do to keep \gamma in the subsection, so that it is also listed in the table of contents?

0

1 Answer 1

417

The PDF bookmarks are a different thing than the table of contents. The bookmarks are not typeset by TeX: they simply are strings of characters, so no math or general formatting instructions are allowed.

The easiest method to avoid the warnings is to use \texorpdfstring:

\subsection{The classes \texorpdfstring{$\mathcal{L}(\gamma)$}{Lg}}

where in the second argument you put the best approximation possible; after all the bookmarks are only a guide for consulting the document.

24
  • 9
    Ahh, I see, those are PDF bookmarks, thanks!
    – Chris
    Apr 26, 2012 at 23:14
  • 3
    Thanks for answering this, even though the question was a duplicate: I couldn't tell if maths mode in section titles would work the same as in the other answers to this problem. May 7, 2014 at 0:39
  • 4
    @barbarabeeton The best approximation possible is left to the reader to decide.
    – egreg
    Sep 23, 2016 at 20:09
  • 6
    Note that unicode, with the unicode option set for hyperref, allows a closer representation like ℒ(γ) for the pdf table of content. \subsection{The classes \texorpdfstring{$\mathcal{L}(\gamma)$}{ℒ(γ)}} works as expected, at least on my setup. This works even if unicode characters are not accepted in math mode. Mar 20, 2019 at 17:59
  • 3
    @Qbyte Maybe \texorpdfstring{$t_2$}{t\_2}?
    – egreg
    Sep 19, 2020 at 16:15

Not the answer you're looking for? Browse other questions tagged .