[Tex/LaTex] Undefined control sequence \State \COMMENT

algorithms

Undefined control sequence \State \COMMENT.

The manual clearly state that I can use the \comment. I use \usepackage{algpseudocode} \usepackage{algorithm}. Here is my code:

\documentclass[10pt, a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath,graphicx,subfigure}

\title{{Bachelor Thesis\\[0.5em]}
       {\bf \huge Road Inventory\\Detection and Recognition\\[0.5em]}
       {\bf Weekly Report 3}}
\author{Poul Sørensen. s093294}

%\setlength{\parindent}{0mm}
\setlength{\parskip}{1.5mm}


\usepackage{lettrine}
\usepackage[draft,english]{fixme}                   %Pakke til at skrive marginnoter under arbejdet. Skift draft til final når der skal printes. Brug 'fxnote{}','fxwarning', 'fxerror' eller 'fxfatal' alt efter behov.
%\fxsetup{layout=margin}                            %Footnote anbefales som option - men er ikke specielt praktisk?

\newcommand{\openCV}{\texttt{OpenCV}~}
\newcommand{\cpp}{\texttt{C++}~}
\usepackage{url}

% Different font in captions
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up,margin=7mm]{caption}

\usepackage{multirow}
\usepackage{array}

\usepackage{rotating}

\renewcommand{\topfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\floatpagefraction}{0.75}

\usepackage{color}

\definecolor{quotationcolour}{rgb}{0.95,0.95,0.95}
\definecolor{quotationmarkcolour}{rgb}{0,0.4,0.9}
% Double-line for start and end of epigraph.
\newcommand{\epiline}{\hrule \vskip -.2em \hrule}
% Massively humongous opening quotation mark.
\newcommand{\hugequote}{%
  \fontsize{42}{48}\selectfont \color{quotationmarkcolour} \textbf{``}
  \vskip -.5em
}

\newcounter{quotecounter}

% Beautify quotations.
\newcommand{\epigraph}[2]{%
\refstepcounter{quotecounter}
  \begin{flushright}
  \colorbox{quotationcolour}{%
    \parbox{.95\textwidth}{%
    \epiline \vskip 1em {\hugequote} \vskip -.5em
    \parindent 2.2em
    #1\begin{flushright}\textbf{Quote \thesection.\thequotecounter}~~ \textsc{#2}\end{flushright}
    \epiline
    }
  }
  \end{flushright}

}

\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{eqparbox}
%\usepackage{program}
%\renewcommand{\algorithmiccomment}[1]{\hfill\eqparbox{COMMENT}{\backslash\backslash #1}}

\begin{document}

\maketitle

\newpage
\section{Performance Measurement }
There exist a few methods for measure performance~\cite{Book:OpenCV}. First one of interest is \textit{cross-validation} and its close related technique of \textit{bootstrapping}. A great outline on the topic can be found online\footnote{www.faqs.org/fags/ai-fag/neural-nets/part3/section-12.html}.

Cross-validation involves splitting the data $\Phi $ into $k$ distinct subsets ${\Phi_1,\cdots,\Phi_{k-1},\Phi_k}$, training $k$ times on $k-1$ of the subsets and testing with left out set. The $k$ test results can then be averaged to a final score.


%\begin{algorithm}
\begin{algorithmic}

\Procedure{CrossValidate}{$\Phi$}
\ForAll{$\phi \in {\Phi_1,\cdots,\Phi_{k-1},\Phi_k}$} 
    \State $model =$ Train($\Phi \setminus \phi$ )
    \ForAll{$s \in \phi$ }
        \State  \COMMENT{hej}
    \EndFor

\EndFor
\EndProcedure

\end{algorithmic} 
%\end{algorithm}


\section{Related Work}\fxnote{(intended for report.)}

\subsection{Machine Learning}
\input{../../"Report Parts"/MachineLearning/ML.tex}
\subsubsection{Prediction Trees}
\input{../../"Report Parts"/MachineLearning/PredictionTrees.tex}


\subsection{Colour Analysis}

\subsection{Decision Tree}

\subsection{Forest of Decision Trees}

\subsection{Hough Forest}

\newpage

\section*{Project status according to the study plan}

All under control. Report work is doing well.

\bibliographystyle{plain} 
\bibliography{../../../../references}

\appendix
\end{document}

Best Answer

LaTeX is case sensitive it terms of control sequences. So, \Comment is different from \COMMENT, \comment and all other valid combinations. This is what you're after in terms of showing a comment - using \Comment{...}:

enter image description here

\documentclass{article}
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\begin{document}
\begin{algorithmic}
  \Procedure{CrossValidate}{$\Phi$}
    \ForAll{$\phi \in {\Phi_1,\cdots,\Phi_{k-1},\Phi_k}$} 
      \State $model =$ Train($\Phi \setminus \phi$ )
      \ForAll{$s \in \phi$ }
        \State \Comment{hej}
      \EndFor
    \EndFor
  \EndProcedure
\end{algorithmic}
\end{document}

From the algorithmicx documentation (section 2.4 Placing comments in sources, p 4):

Comments may be placed everywhere in the source using the \Comment macro ...