I want to write this algorithm but the error Undefined Control Sequence \For, \state, or \EndFor pops up.
\documentclass[titlepage,oneside,12pt]{article}
\usepackage[]{algorithm2e,algpseudocode}
\begin{document}
\begin{algorithmic}[H]
\KwData{Given the M detected objects}
\KwResult{new clusters}
\For (each object $i$)
\state Create new cluster $C_i$;
\state Initialize the cluster feature;
\state $cluster Feature(i) = (x_i, y_i, v_{xi}, v_{yi}, 1, 0, i)$;
\EndFor
\caption{Initialization}
\end{algorithmic}
\end{document}
I saw related questions but the case wasn't as mine.
Undefined control sequence \State \COMMENT
LaTeX algorithmic package: Undefined Control Sequence in for-Loop
Best Answer
You are mixing up commands from the packages
algorithm2e
andalgorithm
. Well, I believe you do.See my following MWE. This does compile and uses the syntax provided by the documentation here.
Is this what you wanted to type?