ELSE IF im algorithmischen Paket

ELSE IF im algorithmischen Paket

Gibt es einen Befehl im Paket, der in algorithmicähnlich ist ? (Ich möchte nicht, dass jedes verschachtelte\ElsIfalgorithmicxWenn eingerückt werden soll).

Antwort1

Ja, das gibt es: \ELSIF. Dies ist einer derErsteBeispiele aus deralgorithmsbündeln Dokumentation(Abschnitt3.2 Diewenn-dann-sonstStellungnahme, S. 3):

Bildbeschreibung hier eingeben

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

Wenn SiealgorithmicxSie müssen verwenden \ElsIf. Hier ist ein Spiegelbild des obigen Pseudocodes mit 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}

verwandte Informationen