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}

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


\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?


% Different font in captions





% Double-line for start and end of epigraph.
\newcommand{\epiline}{\hrule \vskip -.2em \hrule}
% Massively humongous opening quotation mark.
  \fontsize{42}{48}\selectfont \color{quotationmarkcolour} \textbf{``}
  \vskip -.5em


% Beautify quotations.
    \epiline \vskip 1em {\hugequote} \vskip -.5em
    \parindent 2.2em
    #1\begin{flushright}\textbf{Quote \thesection.\thequotecounter}~~ \textsc{#2}\end{flushright}


%\renewcommand{\algorithmiccomment}[1]{\hfill\eqparbox{COMMENT}{\backslash\backslash #1}}



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


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



\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}


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

All under control. Report work is doing well.


  • 1
    Yes it is needed; you should give a minimal example.
    – jon
    Mar 5 '12 at 4:42
  • 1
    Code examples should be minimal, not as lengthy as yours.
    – Werner
    Mar 5 '12 at 6:18
  • Please don't do cross-site posts. Moderators can migrate questions from stackoverflow to tex.se
    – Thorsten
    Mar 5 '12 at 13:21

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

\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
    \ForAll{$\phi \in {\Phi_1,\cdots,\Phi_{k-1},\Phi_k}$} 
      \State $model =$ Train($\Phi \setminus \phi$ )
      \ForAll{$s \in \phi$ }
        \State \Comment{hej}

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

  • Somehow i got some manuals mixed up. \COMMENT was from program package. Mar 5 '12 at 19:09

I would like to add one more thing which is also helpful. sometimes you need to specify the place of your comment. so on the top of document

\newcommand{\Comment}[1]{{\hskip3em$\rightarrow$ #1}}

and inside the algorithm you could easily use


and the results will appear like this

x → Here is a comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.