I have to write some algorithm, thus I've decided to use algorithmicx package:
\usepackage{algorithm}
\usepackage{algorithmicx}
\begin{algorithm}
\begin{algorithmic}[1]
\For{aa}
\State $Sim(i,j) \gets \frac{v_{i} \cdot v_{j}}{\left|v_{i}\right|\left|v_{j}\right|}$
\EndFor
\end{algorithmic}
\label{alg:rAP}
\caption{algorithm}
\end{algorithm}
Everything is fine but LaTeX saysUndefinde control sequence \For
I'm very confused because I've just follow the instruction of algorithmicx
Also there is no problem to use \State
(when I've commented out \For
)
I've also tried \FOR
, \for
but nothings work.
Seems algorithmicx
package are not deprecated and it makes me more confused.
Best Answer
From the
algorithmicx
documentation:This means that loading the
algorithmicx
package only, you have to define yourself the commands.If you want to use one of the predefined sets of commands, you have to load the corresponding package, in your case
algpseudocode
.MWE:
Output: