# Problem with For (or ForAll) loop in algorithm/algpseudocode: missing $inserted by Coulis Last Updated September 11, 2019 10:23 AM I currently have a problem I can't resolve. Here is my code : \begin{algorithm} \caption{Feedback system} \begin{algorithmic}[1] \State$expert$: object describing the expert (name, laterality and path to data) \State$student$: object describing the student (name, laterality and path to data) \Procedure{Feedback}{$expert$,$student$} \State$D_{exp} \gets$all data from$expert$\State$D_{std} \gets$all data from$student$\State$P \gets$all the data to process for each problem \If{$normalisation$== true} \State$P \gets$normalised($P$) \EndIf \State$X_{d_{exp}} \gets$expert's data repartition \ForAll{$p_i$in$P$} \State$d_{exp} \gets$get_data($p_i$,$X_{d_{exp}}$) \EndFor \State clustering_result$\gets$run_clustering \State student_centroid$\gets$get_centroid($D_{std}$) \EndProcedure \end{algorithmic} \label{algorithm_Feedback} \end{algorithm} My import are \usepackage{lipsum} \usepackage[linedheaders,parts,pdfspacing, dottedtoc]{classicthesis} \usepackage{amsmath} \usepackage{amsthm} \usepackage{acronym} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[frenchb]{babel} \usepackage{url} \usepackage[style=alphabetic]{biblatex} \usepackage{graphicx} \usepackage{tabularx} \usepackage{pdflscape} \usepackage{makecell} \usepackage{algorithm, algpseudocode} \usepackage{enumitem} \usepackage{colortbl} My problem is located at the ForAll loop. Basically, it tells me that I have a missing$ at the next line. If I delete all the code after the \ForAll, even the \State in the ForAll loop (and keep the \EndFor obviously), it compiles without any problem. I tried deleting only the \State inside the ForAll loop, or the \States after the \EndFor, but with no success.

Long story short, this works

\ForAll{$p_i$ in $P$}
\EndFor

And this doesn't

\ForAll{$p_i$ in $P$}
\State $d_{exp} \gets$ get_data($p_i$, $X_{d_{exp}}$)
\EndFor
\ForAll{$p_i$ in $P$}
\State $d_{exp} \gets$ get_data($p_i$, $X_{d_{exp}}$)
\EndFor

\State clustering_result $\gets$ run_clustering
\State student_centroid $\gets$ get_centroid($D_{std}$)

Can someone point out to me what seems to be the problem? I really don't get it, and I think my syntax is ok? I haven't found someone with the same problem as me. Sorry if it has been already answered or if the mistake is really obvious and stupid.

Cheers

Tags :