Package hyperref Warning: Token not allowed in a PDF string (<encoding>):
A heading contains math or a command that cannot go into a PDF bookmark. The page is fine; give the bookmark plain text with \texorpdfstring.
Help centre › LaTeX errors › Document structure · Warning: the document still compiles
What the log says
Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref) removing `math shift' on input line 4.What it means
hyperref copies each section title into the PDF's bookmarks (the outline panel in a PDF viewer), which can hold only plain text. Math, formatting commands and some macros cannot be turned into text, so hyperref drops them from the bookmark and says which token it removed. The typeset heading is unaffected; only the bookmark loses part of its text.
Causes and fixes
Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.
1. Math in a section title
Give the bookmark a plain-text version: \section{The \texorpdfstring{$\sqrt{n}$}{sqrt(n)} bound}. The first argument is typeset, the second goes into the bookmark; Unicode characters such as α are allowed in it.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{The $\sqrt{n}$ bound}
Text.
\end{document}\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{The \texorpdfstring{$\sqrt{n}$}{sqrt(n)} bound}
Text.
\end{document}2. A command hyperref cannot turn into text, such as \\ or \footnote in a title
Keep line breaks and footnotes out of the bookmark: \section{A long title\texorpdfstring{\\}{ }continued}, or move a footnote mark into the optional short title \section[Short]{Long\footnote{…}}.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{A rather long title\\ broken by hand}
Text.
\end{document}\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{A rather long title\texorpdfstring{\\}{ } broken by hand}
Text.
\end{document}3. Your own macro in a title
A macro that expands to formatting (\textcolor, \rule, a box) cannot become text. Wrap it in \texorpdfstring where it appears, or once, in the definition, with the text the bookmark should show. If it is a command used in many titles, \pdfstringdefDisableCommands{\def\mymacro{plain text}} sets the bookmark version for all of them.
In Manulyx
The editor shows the warning with an explanation: only the bookmark text is affected, and \texorpdfstring gives it a plain version.
Write in Manulyx for free · Journal templates
More in document structure
- LaTeX Error: Missing \begin{document}Something that prints text sits above \begin{document}, or that line is missing. Only settings belong in the preamble; find the stray text and move it.
- LaTeX Error: Can be used only in preambleA preamble-only command such as \usepackage or \documentclass appears after \begin{document}. Move it above \begin{document}.
- LaTeX Error: Something's wrong--perhaps a missing \itemA list has text before its first \item, or no items at all; an empty thebibliography is a common case. Start every list with \item.
- LaTeX Error: Lonely \item--perhaps a missing list environmentAn \item appears outside any list: the \begin{itemize} or \begin{enumerate} is missing, or the list was closed too early.
- LaTeX Error: \include cannot be nestedA file loaded with \include contains another \include. Only the main file may \include; inside an included file use \input instead.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors