# [Tex/LaTex] Defining a function in pseudocode

algorithms

I am trying to define a function in LaTeX pseudocode, as shown below.

\begin{algorithm}
\begin{algorithmic}[1]
\Function{Increment}{$a$}
.....
\EndFunction
\end{algorithmic}
\end{algorithm}


However, when I compile, I get the error, undefined control sequence \Function{Increment}{$a$}. What mistake am I doing here and how can I solve it?

Like Vikram said: use algpseudocode from the algorithmicx package, it’s superior to the other pseudocode packages.

Then you can do the following:

\begin{algorithm}
\begin{algorithmic}
\Procedure{YourFunction}{$x$}
\State Do Something
\EndProcedure
\end{algorithmic}
\end{algorithm}