Hyperref warning - Token not allowed in a PDF string
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{\\ [email protected]}{}}
should work.
The command is not defined in the document preamble, so \author{}
must be specified after \begin{document}
in this case.
(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...)
While Ulrich's answer is correct and works, there is a more general and transparent way to work around the issue.
The \pdfstringdefDisableCommands
command from the hyperref
package can be used to redefine commands that are usually not supported in PDF bookmark strings.
In the OP example, the offending commands are \\
and \texttt
, which can be redefined to do something else in this way:
\pdfstringdefDisableCommands{%
\def\\{}%
\def\texttt#1{<#1>}%
}
Then, the author can be specified in the document without any special care:
\author{Name \\ \texttt{[email protected]}}
and will be formatted as is, but then put as Name <[email protected]>
in the PDF info strings.
One can also add
\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.