Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
4  
Please post a proper minimal working example illustrating your problem. The code snippet you posted is almost useless (it contains commands whose definition is not standard and doesn't exhibit, after suitable completion, the problem mentioned). –  Gonzalo Medina Jul 29 '11 at 14:45
    
Since the cause is somewhere else in the OP's code, and no further information is given, I will close this question as being too localized. If Eyal would provide further informaton, the question could be reopened. –  Stefan Kottwitz Aug 9 '11 at 14:24
    
Based on the new edit, I've reopened this. –  Joseph Wright Sep 22 '11 at 19:35
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Works for me, and I'll probably use ; but what happens when algorithmic gets updated in the future? :-( –  einpoklum 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 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
add comment

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).

share|improve this answer
    
Ok, well, this seems to work, but like you said, maybe the redifinition is somehow necessary. –  einpoklum 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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