0

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

EDIT: here is a compilable example:

\documentclass[
  % Replace twoside with oneside if you are printing your thesis on a single side
  % of the paper, or for viewing on screen.
  %oneside,
  oneside,
  11pt, a4paper,
  footinclude=true,
  headinclude=true,
  cleardoublepage=empty
]{scrbook}

\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}

\title{Giga titre qui tue et qui donne envie de lire alors qu'en fait c'est chiant}
\author{Quentin Couland\\ Directeur de thèse : \textbf{Sébastien George}\\Co-encadrant : \textbf{Ludovic Hamon}}

\begin{document}

\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}

\end{document}
2
  • Please make your example compilable – DG' Sep 11 '19 at 9:47
  • Thanks for the tip, I added what should be a compilable version (it works on my computer at least). – Coulis Sep 11 '19 at 10:25
1

You need to do \_in textmode.

It needs to be:

\State $d_{exp} \gets$ get\_data($p_i$, $X_{d_{exp}}$)

instead of

\State $d_{exp} \gets$ get_data($p_i$, $X_{d_{exp}}$)
\documentclass[
  % Replace twoside with oneside if you are printing your thesis on a single side
  % of the paper, or for viewing on screen.
  %oneside,
  oneside,
  11pt, a4paper,
  footinclude=true,
  headinclude=true,
  cleardoublepage=empty
]{scrbook}

\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}

\title{Giga titre qui tue et qui donne envie de lire alors qu'en fait c'est chiant}
\author{Quentin Couland\\ Directeur de thèse : \textbf{Sébastien George}\\Co-encadrant : \textbf{Ludovic Hamon}}

\begin{document}

\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}

\end{document}

Result

1
  • Wow thanks a lot, my lack of knowledge in the math mode was the biggest problem here. Thanks again! – Coulis Sep 11 '19 at 11:46

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.