2

I a searching for a predefined command for displaying TRUE and FALSE constants in a pseudocode. I tried \TRUE \True etc. non of them work. I know I could myself use something like \texbf{...} but it would be neater to have the right command... Please if you know it, state it here.

I use this template (with the non-existent \False to be replaced by ?):

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[]{algpseudocode}


\begin{algorithm}
\caption{myproc}\label{proc1}
\begin{algorithmic}[1]
\Procedure{myproc}{}
\State $x\gets \FALSE $
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document} 
1

There is no standard \TRUE or \FALSE as part of algorithmicx, since it may require different formatting that depend on the pseudocode being written. Define your own \TRUE and \FALSE using \algnewcommand (similar to \newcommand):

enter image description here

\documentclass{article}

\usepackage{algorithm,algpseudocode}
\algnewcommand{\TRUE}{\textbf{true}}
\algnewcommand{\FALSE}{\textbf{false}}

\begin{document}

\begin{algorithm}
  \caption{My procedure}
  \begin{algorithmic}[1]
    \Procedure{myproc}{}
      \State $x \gets \FALSE $
    \EndProcedure
  \end{algorithmic}
\end{algorithm}

\end{document} 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.