[Tex/LaTex] Using \vv within in algorithmic

algorithmic

For the document below, I'm getting errors, shown below, when using \vv in the algorithmic environment. If I change to \vec, there is no error. What can I do to continue using \vv?

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}  
\usepackage{esvect}
\begin{document}
    $\vv{p}$
        \begin{algorithmic}
            \Procedure{$Eval$}{$rm$,$\vv{p}$}

            \EndProcedure
        \end{algorithmic}
\end{document}

The errors are:

Undefined control sequence. \Procedure{$Eval$}{$rm$,$\vv{p}$}
Argument of \@firstoftwo has an extra }. \Procedure{$Eval$}{$rm$,$\vv{p}$}
Paragraph ended before \@firstoftwo was complete. \Procedure{$Eval$}{$rm$,$\vv{p}$}
Argument of \mathpalette has an extra }. \Procedure{$Eval$}{$rm$,$\vv{p}$}
Paragraph ended before \mathpalette was complete. \Procedure{$Eval$}{$rm$,$\vv{p}$}
Incomplete \iffalse; all text was ignored after line 9.

Best Answer

The real error message is

! Undefined control sequence.
\reserved@a ->\@nil 

l.8             \Procedure{$Eval$}{$rm$,$\vv{p}$}

The problem is that \Procedure has “moving arguments”, so fragile commands such as \vv have to be protected. Either use

\Procedure{$Eval$}{$rm$,$\protect\vv{p}$}

or make the command robust at the outset:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{esvect}

\MakeRobust{\vv}

\begin{document}

$\vv{p}$

\begin{algorithmic}
  \Procedure{$Eval$}{$rm$,$\vv{p}$}

  \EndProcedure
\end{algorithmic}

\end{document}

enter image description here

In my opinion you should use

\Procedure{$\mathit{Eval}$}{$\mathit{rm},\vv{p}$}

to get uniform spacing.