0

I am trying to write a nested if pseudo code on latex put the following error is appearing:

LaTeX Error: Command \NOT already defined.

\begin{algorithm}[!htbp]
\begin{algorithmic}
\STATE \textbf{Step 5}: Compare each sentence Scores and CFs to determine the class it belong to:
\begin{ALC@g}
\IF {(FR\_Score[sentence] $>$ NFR\_Score[sentence])} 
\STATE Class[Sentence] = FR  
\ELSIF{(FR\_Score[sentence] $<$ NFR\_Score[sentence]) }
\STATE Class [Sentence] = NFR 
\ELSIF {(FR\_Score[sentence] == NFR\_Score[sentence])} 
\begin{ALC@g}
\IF{(FR\_CF[sentence] $>$ NFR\_CF[sentence])} 

\STATE Class[Sentence] = FR  

\ELSIF {(FR\_CF[sentence] $<$ NFR\_CF[sentence])} 

\STATE Class[Sentence] = NFR  

\ELSIF {(FR\_CF[sentence]  == NFR\_CF[sentence])} 

\STATE Class [Sentence] = Nan
\end{ALC@g}
\end{ALC@g}
\end{algorithmic}
\end{algorithm}

update after removing \begin{ALC@g} ..\end{ALC@g} from the code and adding \ENDIF the problem is solved but a 0= symbol is steel appear at the end of the algorithm enter image description here

3
  • Why are you using \begin{ALG@g} and \end{ALG@g}? I told you not to. Commented Jul 13, 2022 at 22:09
  • because without using it here latex doesn't give me the required alignment. in the other parts of the code I removed it there's no problem. but here because if and if else statement doesn't work well I don't remove it Commented Jul 13, 2022 at 22:17
  • See answer (and in the previous question of yours I removed those bits and added \ENDIF). Commented Jul 13, 2022 at 22:19

1 Answer 1

1

I'm wondering where you found \begin{ALC@g} and \end{ALC@g} documented. You want to close the \IF statements with \ENDIF.

\documentclass{article}
\usepackage{algorithm,algorithmic}

\begin{document}

\begin{algorithm}[!htbp]
\begin{algorithmic}
\STATE \textbf{Step 5}: Compare each sentence Scores and CFs to determine the class it belong to:
\IF {(FR\_Score[sentence] $>$ NFR\_Score[sentence])} 
  \STATE Class[Sentence] = FR  
\ELSIF{(FR\_Score[sentence] $<$ NFR\_Score[sentence]) }
  \STATE Class [Sentence] = NFR 
\ELSIF {(FR\_Score[sentence] == NFR\_Score[sentence])} 
  \IF{(FR\_CF[sentence] $>$ NFR\_CF[sentence])} 
    \STATE Class[Sentence] = FR  
  \ELSIF {(FR\_CF[sentence] $<$ NFR\_CF[sentence])} 
    \STATE Class[Sentence] = NFR  
  \ELSIF {(FR\_CF[sentence]  == NFR\_CF[sentence])} 
    \STATE Class [Sentence] = Nan
  \ENDIF
\ENDIF
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

3
  • Thanks @egreg ! sorry for bothering you. could you see the update, please Commented Jul 13, 2022 at 22:30
  • @Eng.sh Do you see =0 in my image? No. So, please, add a complete (but minimal) document, from \documentclass to \end{document} that shows the issue. Commented Jul 13, 2022 at 22:33
  • Finally solved the problem. I am just remove \usepackage{algpseudocode} from the code. Thank you very much @egreg Commented Jul 13, 2022 at 22:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.