アルゴリズムパッケージのELSE IF

アルゴリズムパッケージのELSE IF

パッケージ内に、にalgorithmic似たコマンドはありますか?(それぞれをネストしたくありません。\ElsIfalgorithmicxもし インデントする)。

答え1

はい、あります\ELSIF。これは初めから抜粋した例algorithmsバンドル ドキュメンテーション(セクション3.2if-then-else声明、p 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}

関連情報