# Hyperref warning - Token not allowed in a PDF string

When compiling a beamer presentation and using the following `\author` command

``````\author{Name \\ \texttt{my.email@domain.com}}
``````

I get the following hyperref warning in my logfile

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

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\new@ifnextchar' on input line 15.
``````

I understand that this has to do with hyperref setting the PDF metadata, where the linebreak does’t make much sense and should be removed.

Trying to set

``````\hypersetup{pdfauthor={Name}}
``````

does’t change the situation, seems like hyperref is still looking at the author command.

How do I get the desired display of author name with email and still keep hyperref happy?

-
Other packages may be causing this issue if you switch to use `texorpdfstring` as Ulrich answered. The culprit for me was the `breqn` package. –  Oleg Vaskevich Mar 18 at 3:19

There's the aptly, if verbosely, named macro `\texorpdfstring`, which takes two arguments and uses the first for (La)TeX and the second for pdf, so something like

``````\author{A.U. Thor\texorpdfstring{\\ foo@bar.baz}{}}
``````

should work.

(Yes, I've avoided the issue that I don't know off the top of my head if \url is allowed to go inside another argument...)

-
Thanks, Ulrich, this works. –  Nickolay Kolev Feb 8 '11 at 8:18
Sorry, my previous post is wrong. I deleted it. `\url` is OK, and I think it should be used. Or `\protect\url`, if any error occurs. –  Leo Liu Feb 8 '11 at 8:32
Yes, there shouldn't be trouble, at least not until you have %xx-escaped characters, stuff like that. –  Ulrich Schwarz Feb 8 '11 at 10:46

``````\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{naturalnames}{hyperref}
``````

before `\documentclass{beamer}` to remove many messages generated due to national (non-English) section titles, like

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

P.S. Usually one may get up to few thousands of those even for a simple presentation, and parsing of them takes few extra seconds for many IDEs even on a modern box.

-