# Problem with \% in PDF bookmark under XeLaTeX

A MWE is:

% !TeX program = XeLaTeX

\documentclass{article}
\usepackage{hyperref}
\begin{document}

\section{\^e\%}
\section{20\%}

\end{document}


It can work fine under pdfLaTeX and LuaLaTeX. But there is a error under XeLaTeX:

(./mwe.out)
Runaway argument?
{ê\BOOKMARK [1][-]{section.2}{20\045}{}
! File ended while scanning use of \@@BOOKMARK.
<inserted text>
\par
l.5     \begin{document}

?
(./mwe.out)
Runaway argument?
{ê\BOOKMARK [1][-]{section.2}{20\045}{}
! File ended while scanning use of \@@BOOKMARK.
<inserted text>
\par
l.5     \begin{document}

?
\@outlinefile=\write3
\openout3 = mwe.out'.


I can see the bookmark auxiliary file (mwe.out) is

\BOOKMARK [1][-]{section.1}{ê%}{}% 1
\BOOKMARK [1][-]{section.2}{20\045}{}% 2


I think that it is due to the first % in the first \BOOKMARK. How can I avoid it under XeLaTeX?

• Seems like a bug. If you load also bookmark after hyperref it doesn't happen. Loading bookmark is indeed recommended. May 8 '14 at 18:00

Load the bookmark package instead; it provides an updated bookmarking reference:

\documentclass{article}
\usepackage{bookmark}
\begin{document}

\section{\^e\%}
\section{20\%}

\end{document}


bookmark loads hyperref (see Which package should I load first: hyperref or bookmark?)

• While it's true that bookmark loads hyperref because it depends on it, I find it conceptually clearer to explicitly load both. May 8 '14 at 18:13
• @egreg: Agreed and recommended by me. For example, a package such as package bookmark might evolve to get rid of the dependency of hyperref. An explicit \usepackage or \RequirePackage` can only be dropped, because it is loaded by another package, if the dependency in the other package is part of the official interface for this other package. May 23 '14 at 5:32