latex function/procedure调用的大小写问题

latex默认的function和procedure格式是这样的

其中第1行的名称EUCLID是全大写而且非对齐的,如果直接调用,就会出现第10行11行的形式,与定义格式不一致。这里需要用到调用函数关键字Call,具体代码及实现效果如下

\begin{algorithm}
\caption{Euclid’s algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}
\State $r\gets a\bmod b$
\While{$r\not=0$}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$
\EndProcedure
\State Euclid(1,2)
\State EUCLID(1,2)
\State \Call{Euclid} {1,2}
\end{algorithmic}
\end{algorithm}

可以看到12行的效果就是我们想要实现的调用函数

猜你喜欢

转载自blog.csdn.net/banzhuan133/article/details/87914120