I need to write some pseudocode and am using the IEEE template. However, the guidelines say that algorithmic should be contained in a figure environment and that I am not supposed to use the algorithm package see here.

So far no problem just put everything in figure instead.

\item[\textbf{Input:}] some input 
\item[\textbf{Output:}] Some output
\STATE $P \gets 1$
\STATE $X \gets 2$
\caption{Algorithm that does stuff}

The problem is that this gives me a caption reading Fig. 1. Algorithm that does stuff and I would like it to read Alg. 1. Algorithm that does stuff and not be numbered with the figures but separately.

Thanks for the help.

Edit: I have found a somewhat ugly workaround: I define a new environment based on the figure environment and rename the \figurename to Alg.. Then I needed to introduce two more counters, one as a placeholder(PlaceHolder) and one for keeping track of the actual numbering of the algorithms(BestAlgorithm). Otherwise the it would number algorithms and figure together.


\renewcommand{\figurename}{Alg.} }
{\end{figure} \setcounter{figure}   
{\value{PlaceHolder}} \addtocounter {BestAlgorithm} {1}}

After defining this in the beginning of the document, I can use BestAlgorithm instead of the figure environment.

Is there a nicer way to assign a counter to a new environment?

Your Answer

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

Browse other questions tagged or ask your own question.