ELSE IF в алгоритмическом пакете

ELSE IF в алгоритмическом пакете

Есть ли в пакете команда algorithmic, похожая на \ElsIfв algorithmicx? (Я не хочу, чтобы каждая вложенная командаесли быть с отступом).

решение1

Да, есть: \ELSIF. Это один изпервыйпримеры взяты изalgorithmsпучок документация(раздел3.2если-то-иначеЗаявление, стр. 3):

введите описание изображения здесь

\documentclass{article}

\usepackage{algorithmic}

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

Если вы используетеalgorithmicxвам придется использовать \ElsIf. Вот зеркало приведенного выше псевдокода с использованием algpseudocode:

\documentclass{article}

\usepackage{algpseudocode,algorithm}

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

Связанный контент