2

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.
  • No, I want to use \vv, not to make \vv behave like \vec – Noor Oct 18 '18 at 21:01
  • 2
    Using \Procedure{$Eval$}{$rm$,$\protect\vv{p}$} seems to work. – Peter Grill Oct 18 '18 at 21:01
  • 1
    @Noor Ooh, sorry. I thought that \vv was undefined. Peter's solution seems to work fine :) – Phelype Oleinik Oct 18 '18 at 21:02
  • @PeterGrill yes, it does, what does \protect do, and what was actually the problem ?, would you add an answer so i can mar it as answered ? – Noor Oct 18 '18 at 21:02
  • 1
    @Noor: egreg has explained it in his answer. – Peter Grill Oct 18 '18 at 21:04
3

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.

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.