# babel \L command reverses letters, inserts Ł symbol

It's time for Eyal's babel+Hebrew (or right-to-left) incompatibility of the week; and this time, it's hyperref again.

If you have:

\documentclass{article}
\usepackage[hebrew,english]{babel}
\usepackage{hyperref}
\begin{document}
\selectlanguage{hebrew}
מלל בעברית, \L{Some English within the Hebrew} ועוד עברית לאחר מכן.
\end{document}


You get the following:

if you use just babel without hyperref, you get the expected effect of \L:

This is pretty easy to work around - but I just noticed it, I thought it was some weird part of my other babel+hyperref compatibility issue. Why would hyperref do this?

For those interested, here's some information about the Ł character.

-

Here's the obvious workaround:

\documentclass{article}
\usepackage[hebrew,english]{babel}
\usepackage{hyperref}
\def\L{\protect\pL}
\begin{document}
\selectlanguage{hebrew}
מלל בעברית, \L{Some English within the Hebrew} ועוד עברית לאחר מכן.
\end{document}


This is the definition of \L lifted from rlbabel.def. Alternatively, if you can remember not to use \L itself, don't re-define it, just use something like \def\babelL{\protect\pL}.

-
It's been a bad idea to redefine \L in hebrew.ldf to begin with. :( –  egreg Dec 3 '11 at 15:07
It's a bad idea to define it in hyperref as well... anyway, it's in rlbabel.def, not hebrew.ldf. You would have the same issue with Arabic or Farsi (which is why I didn't set the Hebrew tag on the question.) –  einpoklum Dec 3 '11 at 16:27
hyperref needs to do it because of bookmarks. It's in general not recommendable to redefine commands that change behavior according to the output encoding. Unless you're Heiko Oberdiek who knows better than everybody. :) –  egreg Dec 3 '11 at 16:33
it's overly presumptuous to define one-letter, or even two-letter commands, in packages. At least IMHO. And I wouldn't say hyperref needs to do it. –  einpoklum Dec 3 '11 at 16:36
Yes, it needs to, because \L for the Polish uppercase "suppressed ell" comes before everything, being a kernel command; hyperref only adjusts its meaning for its own purposes. The kernel developers chose it, not Heiko Oberdiek or any other package author. It's a wrong choice by the rlbabel.def file author to use \L for a different purpose. –  egreg Dec 3 '11 at 16:42

Apparently they foresaw that \L would be contentious, so rlbabel provides a macro to reinstate its definition.

\documentclass{article}
\usepackage[hebrew,english]{babel}
\usepackage{hyperref}
\HeblatexRedefineL  % this stands for \def\L{\protect\pL}
\begin{document}
\selectlanguage{hebrew}
מלל בעברית, \L{Some English within the Hebrew} ועוד עברית לאחר מכן.
\end{document}


P.S. An annoying problem I've hit while debugging this was that as soon as I restored the left-to-right meaning, I started getting Command \hebalef unavailable in encoding T1. errors. It took me a long time to notice I had an unterminated \L{... (previously it was outputting Ł but remaining in Hebrew mode, where the characters worked).

-
Are you referring to my answer? In that case better make a comment rather than a new answer (which needs to be stand-alone...) Also, does \HeblatexRedefineL do exactly the same as what I did? –  einpoklum Sep 23 '12 at 13:50