# Create a keyword using the newalg package and algkey

I'm using the newalg package to typeset some algorithms, and I'd like to be able to typeset a keyword using the algkey macro. the problem is that I can't get it to work. Here's what I'm trying to do:

\begin{algorithm}{PromoteServer}{x}
servers \= \CALL{GetMeshServers}(x) \\
\begin{FOR}{\EACH M_n \IN servers}
\begin{IF}{n \eq \algkey{sizeof}(servers)}
\ELSE
\end{IF}
\CALL{AssignCachePartner}(M_{n+1})
\end{FOR}
\end{algorithm}


Where am I going wrong? The documentation for the package doesn't give any examples....

-
Seems odd to me to accept the answer but not to also up-vote it. –  vanden Sep 16 '10 at 16:34

The most recent version of the package is from 2005, it doesn’t ship with TeX Live, the documentation is very incomplete and promises “future work” … I don’t think this package is supported any longer. Try using another package, e.g. algpseudocode, or Cormen’s own clrscode.

That said, what do you mean by “I can't get it to work”? The code, as you’ve written it, is correct. I’ve had a look at the source code of the package and \algkey is defined as follows:

\def\algkey#1{\mbox{\bf #1\ }}


So there’s absolutely nothing special about that command (apart from the fact that it always appends a space which may be unwanted) and it should work out of the box. Alternatively, you can just use \textbf{sizeof} to get the same effect, minus the annoying space at the end.

-