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'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....

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

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

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.