0

I don't understand why i have this error at the "\end{algorithm}" line

\usepackage[spanish]{babel}
\selectlanguage{spanish} 
\usepackage[spanish,onelanguage,linesnumbered]{algorithm2e} %for psuedo code
\usepackage[lmargin=3.81cm,tmargin=2.54cm,rmargin=2.54cm,bmargin=2.52cm]{geometry}

\begin{algorithm}[H] %or another one check
    \DontPrintSemicolon
    \SetKwFunction{FSonIguales}{son\_iguales}
    \SetKwProg{Fn}{Funcion}{}{fin}

    \Fn{\FSonIguales{$X[1..n]$, $Y[1..n]$}}{
        \;\comment{\# Si es array vacío, devuelvo verdadero}\;
        \uIf{$X.longitud == 0$ $\&\&$ $Y.longitud == 0$}{
            \KwRet verdadero\; 
        }
        \;\comment{\# Compruebo si primeros elemento son distintos}\;
        \uElseIf{$X[1]$  $!=$  $Y[1]$}{
            \KwRet falso\;
        }
        \;\comment{\# Compruebo el resto del array}\;
        \Else{
            \KwRet son\_iguales($X[2..n]$, $Y[2..n]$)\;
        }   
    }
\end{algorithm}

Line 126 - Undefined control sequence. \end
Line 126 - Undefined control sequence. \end
Line 126 - Undefined control sequence. \end
2

The undefined control sequence is \comment. Here is the full error message:

! Undefined control sequence.
<argument>  \;\comment 
                       {\# Si es array vacío, devuelvo verdadero}\; \uIf {$...
l.25 \end
         {algorithm}
? 

What can you do? Just don't use \comment, which is undefined. The macros for comments are \tcp and \tcc, described in section 10.3 of the manual of algorithm2e.

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.