# Pseudocode: “If not” control structure

I use the following packages:

\usepackage{algorithm}
\usepackage{algpseudocode}


to display pseudocode of some algorithms in my latex document. For conditionals I use the follow

\If{success = 0}
\State \Return{$\emptyset$}
\EndIf


Now, this renders the if and endif keywords in bold using the same typeface as the one used for all the other control structures. My question is the following: How can I render if not instead of if? So my code would read something like:

\IfNot{success}
\State \Return{$\emptyset$}
\EndIf


You can take all the details associated with \If (within algpseudocode.sty) and add your own \IfNot:

\documentclass{article}

\usepackage{algpseudocode}

\algnewcommand\algorithmicnot{\textbf{not}}
\algdef{SE}[IF]{IfNot}{EndIf}[1]{\algorithmicif\ \algorithmicnot\ #1\ \algorithmicthen}{\algorithmicend\ \algorithmicif}%

\begin{document}

\begin{algorithmic}
\If{success = 0}
\State \Return $\emptyset$
\EndIf
\IfNot{success}
\State \Return $\emptyset$
\EndIf
\end{algorithmic}

\end{document}

• This did exactly what I was looking for, thanks! – gen Feb 24 at 2:44