latex algorithm algorithmic Undefined control sequence
在会议论文中正常的伪代码,复制到学位论文中,
\STATE等报错Undefined control sequence,
使用的包是\usepackage{algorithm,algorithmic}。
解决方法:
1. 使用包\usepackage{algorithm,algpseudocode}
Latex 使用algorithm报错 undefined control sequence_undefined control sequence. \ensure-CSDN博客
2. 将伪代码中的\STATE替换为\State,其它指令类似
\begin{algorithm}
\caption{The algorithm}\label{alg:cap}
\begin{algorithmic}
\Require $n \gets 0$
\Ensure $y = x^n$
\State $y \gets 1$
\State $X \gets x$
\State $N \gets n$
\While{$N \neq 0$}
\If{$N$ is even}\State $X \gets X \times X$\State $N \gets \frac{N}{2}$ \Comment{This is a comment}
\ElsIf{$N$ is odd}\State $y \gets y \times X$\State $N \gets N - 1$
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
by 软件工程小施同学