对于下面的文档,我在环境\vv
中使用时出现如下所示的错误algorithmic
。如果我更改为\vec
,则不会出现错误。我该怎么做才能继续使用\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}
错误如下:
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.
答案1
真正的错误信息是
! Undefined control sequence.
\reserved@a ->\@nil
l.8 \Procedure{$Eval$}{$rm$,$\vv{p}$}
问题是\Procedure
有“移动参数”,所以\vv
必须保护诸如这样的脆弱命令。要么使用
\Procedure{$Eval$}{$rm$,$\protect\vv{p}$}
或者一开始就让命令变得强大:
\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}
我认为你应该使用
\Procedure{$\mathit{Eval}$}{$\mathit{rm},\vv{p}$}
以获得均匀的间距。