# Runaway argument in algorithm

\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}


The above produces "runaway argument". Any ideas why ?

-

## 1 Answer

There is a missing closing brace in the last \If (the first opening brace is not balanced); in the code below I added it:

\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}


Note also that the right syntax is \EndIf and not \Endif (at least if algpseudocode is being used).

-
Thanks a lot. This is what I needed. – shrm Aug 25 '12 at 23:42