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.

I try to get Roman numbering but couldn't find how to change it in the package documentation. After some research, I figured out how to do it using the algorithm2e package. (Use algonl as optional command and then \renewcommand{\theAlgoLine}{\Roman{AlgoLine}}).

If I know the counter name for the algorithmicx package I could add the \renewcommand{thecountername}{\Roman{countername}} command.

I already wrote 8 algorithmns so if possible I would like to avoid rewriting them using the algorithm2e package.

My Example:

\usepackage[section]{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm}
\caption{Algo-name}
\label{arnoldi}
\begin{algorithmic}[1]
\State algo
\end{algorithmic}
\end{algorithm}

\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Roman line numbering? Do you really think that this is a good idea? Arabic line numbering is hard coded. You will have to redefine either \ALG@step or \alglinenumber:

\documentclass{article}
\usepackage[section]{algorithm}
\usepackage{algpseudocode}
\makeatletter
%\renewcommand\alglinenumber[1]{\footnotesize\Roman{ALG@line}:}%alternative
\def\ALG@step%
   {%
   \addtocounter{ALG@line}{1}%
   \addtocounter{ALG@rem}{1}%
   \ifthenelse{\equal{\arabic{ALG@rem}}{\ALG@numberfreq}}%
      {\setcounter{ALG@rem}{0}\alglinenumber{\Roman{ALG@line}}}%<---
      {}%
   }%
\makeatletter
\begin{document}

\begin{algorithm}
\caption{Algo-name}
\label{arnoldi}
\begin{algorithmic}[1]
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\State algo
\end{algorithmic}
\end{algorithm}

\end{document}
share|improve this answer
    
The reason I want Roman line numbering is that I have equations as well and I want to give the equation arabic numbering since I have a lot equations so the Roman numbering gets big and looks stupid if I use \stackrel{}=. My algorithmns are relativly short (~15 lines of code tops) so I rather have them in Roman. I implemented your solution but I have one problem with it. When I refer to the algorithm lines its shown as an arabic number and not as a Roman number. –  1988WM Oct 22 '12 at 13:24
    
Well imho Roman looks numbering looks stupid too. To get the reference right add \renewcommand\theALG@line{\Roman{ALG@line}}. –  Ulrike Fischer Oct 22 '12 at 13:36

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.