My document contains section titles that are formatted by the listings package. (The section names are names of configure script switches.)


I am getting the following warning when processing the LaTeX source:

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

Can I avoid it anyhow? I would be willing to duplicate the title string without the listings formatting decoration if there were a directive to set the PDF TOC entry string manually (instead of automatically).


1 Answer 1


Many commands that works via unexpandable stuff (assignments, catcode changes, ...) do not work in bookmarks. A PDF viewer is not TeX and does not understand the TeX language.

Package hyperref provides \texorpdfstring to provide different code for the normal case and the bookmark case:





  • The curly braces inside -{}-enable prevent that the bookmark code makes a ligature and converts the two single hyphens to an en dash.
  • Package bookmark is recommended, the bookmarks are faster up to date and the package provides more features.

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