In the following MWE, the bookmark produced by hyperref is incorrect:
\documentclass{article}
\usepackage{hyperref}
\usepackage[capitalize,nameinlink,noabbrev]{cleveref}
\hypersetup{%
bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,%
}
\begin{document}
\section{\label{sec:foo}foo}
\section{Code for \cref{sec:foo}}
\end{document}
The heading of section 2 in the PDF is correct (Code for Section 1
), but the bookmarks as shown in Acrobat read:
1 foo
2 Code for sec:foo
Edit: as Micha pointed out, the code also produces a warning:
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\@ifnextchar' on input line 11.
Using the allmighty \protect
before the \cref
unfortunately did not change anything ;).
Package hyperref Warning: Token not allowed in a PDF string
\cref
is to complicated for the bookmarks. Use something like\section{Code for \texorpdfstring{\cref{sec:foo}}{section \ref{sec:foo}}}