# “improper alphabetic constant” with hyperref and bidi packages

I'm getting an "improper alphabetic constant" error in xelatex which appears to be due to an interaction between the bidi and hyperref packages, when I redefine the \section cmd. Here's an MWE:

\documentclass{report}
\usepackage[unicode]{hyperref}
\usepackage{bidi} %Must be loaded after hyperref pkg
\makeatletter
\renewcommand\section{\@startsection{section}{1}{0pt}{0pt}{0pt}{}}
\makeatother
\begin{document}
\section{\RL{foo}}
\RL{bar}
\end{document}


It's important that the text \RL{bar} be the first non-whitespace after the \section{}, otherwise the error is not triggered.

I've checked the suggested "Similar Questions," and don't see anything quite like this.

Suggestions?

-

I do not think, you need to pass unicode option to hyperref package with XeTeX engine. So with the following example:

\documentclass{report}
\usepackage{hyperref}
\usepackage{bidi} %Must be loaded after hyperref pkg
\makeatletter
\renewcommand\section{\@startsection{section}{1}{0pt}{0pt}{0pt}{}}
\makeatother
\begin{document}
\section{\RL{foo}}
\RL{bar}
\end{document}


I get no error (using Updated TeXLive 2012) but one related warning which is due to the use of \RL macro inside \section:

Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref)                removing \RL' on input line 9.


For details see page 19 of hyperref manual, under Replacement macros subsubsection.

To get rid off this warning, you can change your example into:

\documentclass{report}
\usepackage{hyperref}
\usepackage{bidi} %Must be loaded after hyperref pkg
\makeatletter
\renewcommand\section{\@startsection{section}{1}{0pt}{0pt}{0pt}{}}
\makeatother
\begin{document}
\section{\texorpdfstring{\RL{foo}}{foo}}
\RL{bar}
\end{document}


and if you do not like \texorpdfstring, you can try:

\documentclass{report}
\usepackage{hyperref}
\usepackage{bidi} %Must be loaded after hyperref pkg
\makeatletter
\renewcommand\section{\@startsection{section}{1}{0pt}{0pt}{0pt}{}}
\pdfstringdefDisableCommands{%
\let\RL\@firstofone
}
\makeatother
\begin{document}
\section{\RL{foo}}
\RL{bar}
\end{document}
`
-
Odd, I had tried it without the [unicode] arg to hyperref first (and re-tried that just now), but I get the same error. I'm running the TexLive 2011 version, I must have missed the 2012 update! –  Mike Maxwell Oct 26 '12 at 14:11
Thanks for the fixes--both work with 2011, although I'm now in the process of updating our installation to 2012, so maybe I won't need them :-). –  Mike Maxwell Oct 26 '12 at 20:42
We updated to the 2012 version, but I still get my original error msg ("improper alphabetic constant"), rather than the one you get about '\RL' not being allowed. I guess you have some files that have been updated since TeXLive 2012 came out. Can you explain the effect of omitting the \RL command (which IIUC is what the \pdfstringdefDisableCommands{} that you give is doing)? I would have thought it would mean that Arabic script comes out left-to-right in bookmarks, but I can't see any diff in the output. –  Mike Maxwell Oct 30 '12 at 17:57