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


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 '14 at 3:19
  • This problem now (beamer v. 3.36) also affects the \date command, which it previously didn't do. The same fix applies (see accepted answer below). – Sverre Apr 10 '15 at 12:13

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.

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...)

  • 1
    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

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:


Then, the author can be specified in the document without any special care:

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

and will be formatted as is, but then put as Name <my.email@domain.com> in the PDF info strings.

  • 1
    This did the trick for me in a similar situation! Thanks. The trick is to figure out which command is creating the disallowed token and then using pdfstringdefDisableCommands to overwrite it for the hyperref. – patrickvacek Sep 29 '16 at 3:53
  • Exactly! Usually, anything that has to do with typography or formatting has to be escaped. – gigabytes Sep 29 '16 at 6:20
  • 2
    How can someone avoids math with this sintax? i.e. $...$ – gvgramazio May 9 '18 at 20:07
  • 1
    That's different than simply redefining commands. In that case it's better to explicitly use \texorpdfstring to provide two alternative texts, one to typeset, and one to include in the PDF string. – gigabytes May 10 '18 at 8:02

One can also add


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.

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.