\begin{algorithm}
\caption{Partial Sum Update Algorithm}\label{alg:usline}
\begin{algorithmic}[1]
\State $\mathcal{N}^*\gets$ bitreverse$(\mathcal{N})$
\If{$i(s)=0$}\Comment{The $s^{th}$ LSB in the binary representation of i is $0$.}
\If{$s=\log _2N - 1$ or$ i_{(\log _{2}N - 1):(s+1)} = \mathcal{N}_{(\log _{2}N - 2):s}^*$
\Endif
\Endif
\end{algorithmic}
\end{algorithm}
以上内容产生了“失控论证”。您知道这是为什么吗?
答案1
最后一个缺少一个右括号\If
(第一个左括号不平衡);在下面的代码中我添加了它:
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Partial Sum Update Algorithm}\label{alg:usline}
\begin{algorithmic}[1]
\State $\mathcal{N}^*\gets$ bitreverse$(\mathcal{N})$
\If{$i(s)=0$}\Comment{The $s^{th}$ LSB in the binary representation of i is $0$.}
\If{$s=\log _2N - 1$ or $ i_{(\log _{2}N - 1):(s+1)} = \mathcal{N}_{(\log _{2}N - 2):s}^*}$
\EndIf
\EndIf
\end{algorithmic}
\end{algorithm}
\end{document}
还要注意,正确的语法是\EndIf
而不是\Endif
(至少在algpseudocode
使用时)。