# Strange bug with hyperref, percent symbol and cyrillic character

I minimized it to the following snippet:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{\%н}
\end{document}


When I compile it:

xelatex test.tex


the first run compiles fine, but on the second run it complains:

Runaway argument?
{
! File ended while scanning use of \@@BOOKMARK.
<inserted text>
\par
l.3 \begin{document}


If I remove either hyperref, or percent sign, or cyrillic char, it compiles fine. I observe this behavior only on TeXLive 2012 distribution - 2009 distribution works just fine.

What is the problem?

## 1 Answer

With that setting, the annotation written in the .out file is

\BOOKMARK [1][-]{section.1}{%н}{}% 1


where the problem is self evident: the "naked" % ends the line.

You have two workarounds available:

\usepackage[unicode]{hyperref}


that makes the following annotation

\BOOKMARK [1][-]{section.1}{\376\377\000\045\004\075}{}% 1


thus avoiding the problem. The second workaround is

\usepackage{hyperref}
\usepackage{bookmark}


This seems better, because the bookmark package better manages bookmarks.

• With the first workaround, I get ** WARNING ** Failed to convert input string to UTF16.... Second workaround works fine, but is a bit strange - since I don't work with bookmarks, just with simple links. – Rogach Jun 2 '13 at 12:24
• @Rogach The warning can be safely ignored. If you don't need bookmarks, you can pass the option bookmarks=false to hyperref (they are enabled by default). – egreg Jun 2 '13 at 12:28
• adding \usepackage{bookmark} helped me, thanks! – CodingYourLife May 20 '17 at 12:26