[Tex/LaTex] polyglossia and algorithmicx – Missing \endcsname inserted

algorithmshebrewnumberingpolyglossia

Trying to compile a simple document using polyglossia with Hebrew as the default language:

\documentclass[a4paper]{article}
\TeXXeTstate=1
\usepackage{amsmath, amssymb}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=hebrew, numerals=hebrew]{hebrew}
\setotherlanguage{english}
\setmainfont{David CLM}
\usepackage[noend]{algpseudocode}

\begin{document}
\section{}
  שלום
  \begin{english}
    Procedure(A)
    \begin{algorithmic}[1]
      \State $A = 0$
    \end{algorithmic}
  \end{english}
\end{document}

Results in this using XeTeX:

! Missing \endcsname inserted.
<to be read again> 
                   \relax 
l.15     \begin{algorithmic}[1]

If I set the default language to English and other language to Hebrew it works fine though.

Best Answer

A workaround can be the following code to be put in the preamble:

\usepackage{etoolbox}
\makeatletter
\let\ORI@arabic\@arabic
\expandafter\pretocmd\csname\string\algorithmic\endcsname
  {\let\@arabic\ORI@arabic}{}{}
\renewcommand{\theALG@storecount}{\ORI@arabic\c@ALG@storecount}
\makeatother

The strange code is meant to inject the code in the "real" macro that does the work intended for \algoritmic.

Related Question