[Tex/LaTex] Using the “algorithm” package – can’t use \OR

algorithms

I keep getting an error…

! Undefined control sequence. \State $v.bool \gets v.bool \OR

Even though \AND works. Is there something I'm missing. A little late for me to switch to a different package but seems like something that should be supported.

Sample…

\begin{algorithmic}
    \Procedure{proc}{$v$}
        \State $v.bool \gets v.bool \OR c.bool$;
    \EndProcedure
\end{algorithmic}

Best Answer

You seem to be mixing the notation of algorithmicx and algorithms - both provide an algorithmic environment. Define something if it doesn't exist:

enter image description here

\documentclass{article}

\usepackage{algpseudocode}

\algnewcommand{\algorithmicand}{\textbf{ and }}
\algnewcommand{\algorithmicor}{\textbf{ or }}
\algnewcommand{\OR}{\algorithmicor}
\algnewcommand{\AND}{\algorithmicand}
\algnewcommand{\var}{\texttt}

\begin{document}

\begin{algorithmic}
  \Procedure{proc}{$v$}
    \State $\var{v.bool} \gets \var{v.bool} \OR \var{c.bool}$;
  \EndProcedure
\end{algorithmic}

\end{document}