TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
\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 ?

share|improve this question
up vote 2 down vote accepted

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}

enter image description here

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

share|improve this answer
    
Thanks a lot. This is what I needed. – shrm Aug 25 '12 at 23:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.