Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Algorithm Numbering Conflict with algorithmic and algorithm2e

66 views
Skip to first unread message

AikidoGuy

unread,
Jan 28, 2009, 9:55:41 AM1/28/09
to
Does anyone know how to change the following example so that the
second algorithm will be numbered with a 2? i.e. "Algorithm 2" instead
of "Algorithm 1".

Thank you,
Alan

\documentclass{article}
%
% For algorithms (1)
%
% http://gicl.cs.drexel.edu/people/tjkopena/wiki/index.php?n=SWAT.Algorithm2eTooManyBrackets
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
\usepackage[algo2e,ruled,vlined]{algorithm2e} % need for algorithm
environment (name is algorithm2e because of algo2e option)
%
% For algorithms (2)
\usepackage{algorithm}
\usepackage{algorithmic}
\renewcommand{\algorithmiccomment}[1]{\hfill $\rhd$ \textsf{\textit
{#1}}}
%
\begin{document}
%
% First Algorithm
\begin{algorithm}
\caption{My First Algorithm}
\label{algorithm:one} \textbf{Input:} blah
\begin{algorithmic}[1]
\STATE $k \Leftarrow 1$
\end{algorithmic}
\end{algorithm}
%
% Second Algorithm
\begin{algorithm2e}[h!]
\caption{My Second Algorithm\label{algorithm:two}}
%\dontprintsemicolon
\linesnumbered
\SetLine
Let $A \Leftarrow foo(\emptyset, \emptyset)$ \;
\end{algorithm2e}
\end{document}

0 new messages