3

If I use algorithmic with babel, having both Hebrew and English, the line numbers go missing. Using MikTeX 2.9.

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

\begin{document}
\begin{algorithm}
\caption{A caption}
\begin{algorithmic}[1]
\STATE{A line which should be numbered.}
\end{algorithmic}
\end{algorithm}
\end{document}

screenshot

  • Based on the new edit, I've reopened this. – Joseph Wright Sep 22 '11 at 19:35
2

Joseph Wright has already mentioned the cause of the problem and a possible solution. I found another approach in the page Hebrew in LaTeX. Under the title algorithmics you can find a modified version of algorithmic.sty. You can download this file and save it (where TeX can find it) under a different name (heb-algorithmic.sty, for example) and then load the modified version on the preamble of your document:

\usepackage{heb-algorithmic}

I did a test with the following file:

\documentclass{article}
\usepackage[hebrew,english]{babel}
\usepackage{heb-algorithmic}

\begin{document}

\begin{algorithmic}[1]
\STATE{A line which should be numbered.}
\end{algorithmic}

\end{document}

and everything worked as expected; the line numbers were back.

  • Works for me, and I'll probably use ; but what happens when algorithmic gets updated in the future? :-( – einpoklum - reinstate Monica Sep 23 '11 at 6:44
  • 1
    Have contacted Rogério Brito, the manintainer, who will consider making changes to the package to address this. He may be able to post something on the matter here (assuming the reputation system doesn't stand in his way...) – einpoklum - reinstate Monica Sep 23 '11 at 13:24
  • @Eyal Rozenberg: yes, that was the right thing to do. We'll be looking forward to hearing any news from the maintainer. – Gonzalo Medina Sep 23 '11 at 14:07
  • what happens when algorithmic is updated in the future? ... the same: if someone notices a problem, the cycle of patch -- re-release -- ... starts again. babel is a tricky beast anyway, and i can imagine babel hebrew being trickier than average (i've never looked); as far as i can tell, polyglossia is better in this regard -- requires a switch to unicode and xetex, but that may well be a more comfortable environment, long term, anyway. – wasteofspace Oct 21 '11 at 8:24
1

You can cut the minimal example down to

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

\begin{document}

\begin{algorithmic}[1]
\STATE{A line which should be numbered.}
\end{algorithmic}

\end{document}

i.e. the algorithm package is nothing to do with this. The fundamental problem seems to be that the hebrew option for babel redefines \@arabic such that it is not expandable. That makes some internal testing fail, and so no number is printed. Restoring the original definition sorts this out

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

\begin{document}

\makeatletter
\def\@arabic#1{\number#1}
\makeatother

\begin{algorithmic}[1]
\STATE{A line which should be numbered.}
\end{algorithmic}

\end{document}

Whether this will be okay in the real case, I don't know (I'm sure that there is a reason for the change).

  • Ok, well, this seems to work, but like you said, maybe the redifinition is somehow necessary. – einpoklum - reinstate Monica Sep 23 '11 at 6:40
  • The redefinition is necessary otherwise in RTL, \@arabic{19} would be printed as 91 instead 19. – IRAN Oct 24 '11 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.