25 June 2010

texorpdfstring in hyperref

Filed under: Tips — András Salamon @ 18:25

If you use the hyperref package and have seen
Package hyperref Warning: Token not allowed in a PDF string
when running pdflatex/pdftex, consider using \texorpdfstring to specify the PDF string explicitly.

For instance, math mode is not allowed in PDF, so the snippet \section{My $k$-character heading} can be replaced by \section{My \texorpdfstring{$k$}{k}-character heading}.

Thorsten (localghost) pointed this out, thanks! A brief description of the command is actually in the hyperref manual. It’s not obvious what to look for, as the relevant section (at time of writing, Replacement macros) currently does not mention the warning message…

(Edit 20100716: fixed typo.)



  1. its working fine now
    but why math mode is not allowed in section titles??

    Comment by Mohamed Hakeem — 25 June 2012 @ 11:06 | Reply

  2. Mohamed, the hyperref error refers to the string generated for the PDF navigation bookmarks, not in the document itself. Since the PDF bookmarks are text-only, math mode isn’t allowed. Math mode will, however, show up just fine in the actual section title. Hope this clears it up.

    Comment by SF — 14 August 2012 @ 16:19 | Reply

    • Thank you very much for the explanation

      Comment by Mohamed Hakeem — 16 August 2012 @ 10:51 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: