# Missing $inserted. <inserted text> on a math algorithm 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.

• 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. Aug 14 '14 at 10:21 • What can I use then to put a left arrow symbol? Thanks in advance @1010011010 Aug 14 '14 at 10:22 • Updatd with a MWE @cornelius . Thanks in advance. Aug 14 '14 at 10:23 • @BorjaTornos \leftarrow -> $\leftarrow$ – user56567 Aug 14 '14 at 10:24 ## 2 Answers How 1010011010 user said, you must use $\leftarrow$ instead of \leftarrow. • 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. Aug 14 '14 at 10:38
• @BorjaTornos $\left \{$ s $\right \}$ ->$\{s\}$?
– user56567
Aug 14 '14 at 10:41

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}