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.

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}
share|improve this question
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

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer
    
Somehow i got some manuals mixed up. \COMMENT was from program package. –  s093294 Mar 5 '12 at 19:09
    
Thank you. It solve the issue –  s093294 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

\Comment

and the results will appear like this

x → Here is a comment
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.