# Elsevier elsart/elsart3p incompatibility with algorithmic

Stuggling with the following problem for a small while and am stumped. I'm using the the elsart3p.cls document class, but it seems not to work well with the algorithmic package. Here's a minimal working example:

\documentclass{elsart3p} %also doesn't work with elsart
\usepackage{algorithmic}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}[ht]
\begin{algorithmic}[1]
\REQUIRE help?
\end{algorithmic}
\caption{Algorithm}
\label{alg:test}
\end{algorithm}

\end{document}


When compiling using latex or pdflatex, I get a single error (per \begin{algorithmic} for each algorithm):

LaTeX Error: Command \AND already defined


...but the output looks okay. Usually I wouldn't mind too much, but I'll be passing on sources.

Anyone got any ideas for a workaround? I have a good few algorithms, so not keen on moving to another package (plus, I was never a big fan of algorithmic2e... too many braces give me vertigo).

I know this question isn't exactly blockbuster Hollywood material, but any help much appreciated!

-

The elsart3p class internally loads the elsart class, and the latter defines \AND as \&; the algorithmic package also defines \AND but with a different meaning, so these two definitions collide (that's why you get the error message included in your question). One possible solution is to use the savesym package to rename one of the two colliding names: using \savesymbol{AND} before loading the algorithmic package, renames the \AND command from the elsart as \origAND, avoiding the name clash:

\documentclass{elsart3p}
\usepackage{savesym}
\savesymbol{AND}
\usepackage{algorithmic}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}[ht]
\begin{algorithmic}[1]
\STATE solved!
\end{algorithmic}
\caption{Algorithm}
\label{alg:test}
\end{algorithm}

\end{document}


On a side note, perhaps the algorithmicx package could be of interest for you.

-
Works like a charm! Many thanks! –  badroit Jun 2 '11 at 13:10
Thanks a lot! it works perfect. –  user15833 Jun 21 '12 at 18:26
Adding the two sentences of "\usepackage{savesym} \savesymbol{AND}" indeed solves the problem. Actually, it also solves the errors of using algorithm package in the autart.cls. –  datcn Jan 20 at 8:19