1

I've made the following pseudocode:

\documentclass[]{article}
\usepackage[]{algorithm2e}

\begin{document}

\title{Title}
\author{Author}
\date{Today}
\maketitle

\begin{algorithm}[H]
pseudoalgoritmo GRASP(maxIt, seed)\;
 \For{k = 1, ..., itmax }{
solucion \leftarrow faseConstructiva(seed):\;

solucion \leftarrow busquedaLocal(solucion);\;

ActualizarSolucion (solucion, mejorSolucion)\;
}
return mejorSolucion\;
\caption{Pseudoalgoritmo GRASP}
\end{algorithm}

\end{document}

And I'm getting the Missing $ inserted. <inserted text> error at the line where the forstatement closes. How can I fix it? Thanks in advance.

5
  • Please post a MWE goo.gl/dtPzv
    – user56567
    Aug 14 '14 at 10:18
  • The symbol \leftarrow is really intended for math mode. That's why you're getting a ` missing $ inserted`.
    – 1010011010
    Aug 14 '14 at 10:21
  • What can I use then to put a left arrow symbol? Thanks in advance @1010011010
    – Avión
    Aug 14 '14 at 10:22
  • Updatd with a MWE @cornelius . Thanks in advance.
    – Avión
    Aug 14 '14 at 10:23
  • @BorjaTornos \leftarrow -> $\leftarrow$
    – user56567
    Aug 14 '14 at 10:24
2

How 1010011010 user said, you must use $\leftarrow$ instead of \leftarrow.

2
  • I've also another little problem. Do do you also know how can i add those $ to this line? \left \{ s \right \} ;\; This makes a {s};. I tried $\left \{$ s $\right \}$ ;\; But it's not working. Thanks in advance.
    – Avión
    Aug 14 '14 at 10:38
  • @BorjaTornos $\left \{$ s $\right \}$ ->$\{s\}$?
    – user56567
    Aug 14 '14 at 10:41
1

Instead of mathmode $\leftarrow$ (as suggested in comments) can also use \textleftarrow from textcomp package

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[]{algorithm2e}
\usepackage{textcomp}
\usepackage{lmodern}

\begin{document}

\title{Title}
\author{Author}
\date{Today}
\maketitle

\begin{algorithm}[H]
pseudoalgoritmo GRASP(maxIt, seed)\;
 \For{k = 1, ..., itmax }{
solucion \textleftarrow\ faseConstructiva(seed):\;

solucion $\leftarrow$ busquedaLocal(solucion);\;

ActualizarSolucion (solucion, mejorSolucion)\;
}
return mejorSolucion\;
\caption{Pseudoalgoritmo GRASP}
\end{algorithm}

\end{document}

enter image description here

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.