The below code is giving me the error: "Undefined control sequence.l.36 \Elsif {$ -3 <=$ polarity of $car_dictionary[fd] < -2 $}:" in multiple else if case in latex. Please help me asap.
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\title{Euclid's Algorithm: An example of how to write algorithms in \LaTeX{}}
\author{write\LaTeX{}}
\date{\today}
\begin{document}
\maketitle
\section{Example Algorithm}
Algorithms can be included using the commands as shown in algorithm \ref{alg:euclid}.
\begin{algorithm}
\caption{Euclid’s algorithm}\label{alg:euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\For {each field fd in car\_dictionary} :
\If{ polarity of $car\_dictionary[fd] < -3 $ }:
\State {add "EXTREME BAD" to car\_dictionary[fd];}
\Elsif{$ -3 <=$ polarity of $car\_dictionary[fd] < -2 $}:
\State add "VERY BAD" to car\_dictionary[fd];
\ElsIf{$ -2 <=$ polarity of $car\_dictionary[fd] < -1 $}:
\State add "BAD" to car\_dictionary[fd];
\ElsIf{$ -1 <=$ polarity of $car\_dictionary[fd] < 0 $}:
\State add "NOT GOOD" to car\_dictionary[fd];
\ElsIf{polarity of $car\_dictionary[fd] == 0 $}:
\State add "NEUTRAL" to car\_dictionary[fd];
\ElsIf{$ 0 < $ polarity of $car\_dictionary[fd] <= 2 $}:
\State add "GOOD" to car\_dictionary[fd];
\ElsIf{$ 2 < $ polarity of $car\_dictionary[fd] <= 5 $}:
\State add "SATISFACTORY" to car\_dictionary[fd];
\ElsIf{$ 5 < $ polarity of $car\_dictionary[fd] <= 7 $}:
\State add "VERY GOOD" to car\_dictionary[fd];
\Else
\State add "EXCELLENT" to car\_dictionary[fd];
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
Best Answer
You need
\ElsIf
, not\Elsif
: