# = in algorithm when using hebrew and algorithm2e

For some reason an = sign appears at the beginning of every line in an algorithm block when using hebrew and algorithm2e. Removing hebrew removes the line.

For example:

\documentclass{article}
\usepackage{algorithm2e}
\usepackage[hebrew,english]{babel}

\begin{document}
\begin{algorithm}
\KwData{$x$}
$y \gets x$\\
\KwOut{$y$}
\end{algorithm}
\end{document}


Renders:

While:

\documentclass{article}
\usepackage{algorithm2e}
\usepackage[english]{babel}

\begin{document}
\begin{algorithm}
\KwData{$x$}
$y \gets x$\\
\KwOut{$y$}
\end{algorithm}
\end{document}


Gives

Any ideas?

Just in case you're thinking there's something wrong with my install, try it yourself on sharelatex

Edit(2): Found possible related post algorithmic + babel with Hebrew conflict: Numbering missing

This is caused by a very wrong redefinition of \everypar done in rlbabel.def:

% rlbabel.def, line 140
\def\everypar#1{\o@everypar{\rl@everypar#1}}


This doesn't take into account that \everypar is, originally, a token list register, which allows the syntax \everypar={...} and algorithm2e uses it.

Fix:

\documentclass{article}
\usepackage[hebrew,english]{babel}
\usepackage{algorithm2e}
\usepackage{etoolbox}

\makeatletter
\let\heb@everypar\everypar
\def\everypar#1#{\heb@everypar}
\makeatother

\begin{document}

\begin{algorithm}
\KwData{$x$}
$y \gets x$\\
\KwOut{$y$}
\end{algorithm}
\end{document}


As I read in the pack man Algorithm2e provides an option for different languages and the main problem is that hebrew is not supported so when you call hebrew in babel the pack tries to find the keywords of algorithm2e in hebrew so, using the lang option of algorithm set to english this stops

\documentclass{article}
\usepackage[linesnumbered,ruled,english]{algorithm2e}

\usepackage[hebrew]{babel}

\begin{document}
\begin{algorithm}
\KwData{$x$}
$y \gets x$\\
\KwOut{$y$}
\end{algorithm}

\end{document}


however the algorithm is right flush for some reason

• Sorry, this doesn't help. The solution should have the ability to work with both hebrew and english. I'm quite sure the problem is with babel/hebrew redefining \arabic . I'm to patch algorithm2e myself similar to the way algorithmic was patched but no luck yet. – habeanf May 4 '14 at 15:43