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}
Related videos on Youtube
Author by
daniel.jackson
Updated on November 26, 2020Comments
-
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 almost 12 yearsThis 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 almost 12 yearsAlso there is no need for
\TeXXeTstate=1
. And it is much safer to loadalgpseudocode
package before loadingpolyglossia
package. -
daniel.jackson almost 12 years@VafaKhalighi: as a matter of fact I wanted
numerals=arabic
but that doesn't compile at all. Deleting thenumerals
also doesn't compile. -
daniel.jackson almost 12 yearsIf I delete the
\section{}
it does compile without thenumerals
, but the original error is stil there. -
IRAN almost 12 yearsSee my answer, do you still get any error with the minimal example that I posted in my answer.
-
-
daniel.jackson almost 12 yearsShould 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 almost 12 yearsAfter loading algorithmic. Just put the loading of etoolbox with the other packages and rest of the code before
\begin{document}
. -
daniel.jackson almost 12 yearsNot much has changed. Here's the modified file with the output at the bottom: paste.pocoo.org/show/511861
-
daniel.jackson almost 12 yearsI'm getting this error:
! Undefined control sequence. \@sect ...stepcounter {#1}\protected@edef \@svsec {\@seccntformat {#1}\relax... l.10 \section{}
-
IRAN almost 12 years
bidi
package automatically loadsbiditools
package (the programming infrastructure ofbidi
package) that provides some tools similar to whatetoolbox
provides. Hence there is no need to loadetoolbox
, instead change\pretocmd
to\bidi@pretocmd
. -
egreg almost 12 years@daniel.jackson I get no error.
-
IRAN almost 12 yearsI do not get that error. Maybe your TeX distribution is not updated.