polyglossia and algorithmicx - Missing \endcsname inserted

2,906

Solution 1

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.

Solution 2

Since, in the comment you said that you want arabic numerals, then changing your minimal example to the following works without problems with arabic numerals:

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

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

Related videos on Youtube

daniel.jackson
Author by

daniel.jackson

Updated on November 26, 2020

Comments

  • daniel.jackson
    daniel.jackson almost 3 years

    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.

    • IRAN
      IRAN almost 12 years
      This is due to numerals=hebrew. If you delete it, no error happens. I am not sure about details. You can make a bug report at github.com/reutenauer/polyglossia/issues
    • IRAN
      IRAN almost 12 years
      Also there is no need for \TeXXeTstate=1. And it is much safer to load algpseudocode package before loading polyglossia package.
    • daniel.jackson
      daniel.jackson almost 12 years
      @VafaKhalighi: as a matter of fact I wanted numerals=arabic but that doesn't compile at all. Deleting the numerals also doesn't compile.
    • daniel.jackson
      daniel.jackson almost 12 years
      If I delete the \section{} it does compile without the numerals, but the original error is stil there.
    • IRAN
      IRAN almost 12 years
      See my answer, do you still get any error with the minimal example that I posted in my answer.
  • daniel.jackson
    daniel.jackson almost 12 years
    Should this be put in a specific location in the preamble (before/after polygossia/algorithmic etc)? I tried several positions but all resulted in the same error.
  • egreg
    egreg almost 12 years
    After loading algorithmic. Just put the loading of etoolbox with the other packages and rest of the code before \begin{document}.
  • daniel.jackson
    daniel.jackson almost 12 years
    Not much has changed. Here's the modified file with the output at the bottom: paste.pocoo.org/show/511861
  • daniel.jackson
    daniel.jackson almost 12 years
    I'm getting this error: ! Undefined control sequence. \@sect ...stepcounter {#1}\protected@edef \@svsec {\@seccntformat {#1}\relax... l.10 \section{}
  • IRAN
    IRAN almost 12 years
    bidi package automatically loads biditools package (the programming infrastructure of bidi package) that provides some tools similar to what etoolbox provides. Hence there is no need to load etoolbox, instead change \pretocmd to \bidi@pretocmd.
  • egreg
    egreg almost 12 years
    @daniel.jackson I get no error.
  • IRAN
    IRAN almost 12 years
    I do not get that error. Maybe your TeX distribution is not updated.