[Tex/LaTex] ELSE IF in algorithmic package

algorithmicalgorithmicx

Is there a command in algorithmic package which is similar to \ElsIf in algorithmicx? ( I do not want each nested if to be indented).

Best Answer

Yes there is: \ELSIF. This is one of the first examples taken from the algorithms bundle documentation (section 3.2 The if-then-else Statement, p 3):

enter image description here

\documentclass{article}
\usepackage{algorithmic}% http://ctan.org/pkg/algorithms
\begin{document}
\begin{algorithmic}
  \IF{some condition is true}
    \STATE do some processing
  \ELSIF{some other condition is true}
    \STATE do some different processing
  \ELSIF{some even more bizarre condition is met}
    \STATE do something else
  \ELSE
    \STATE do the default actions
  \ENDIF
\end{algorithmic}
\end{document}
Related Question