3

I have the following trivial example that I just can't compile.

\documentclass{beamer}

\mode<presentation> {
\usetheme{Madrid}
\usecolortheme[RGB={0,0,0}]{structure}
}

\usepackage{amsmath,amsfonts,graphicx}
\usepackage{algpseudocode}
\usepackage{tikz, nth}
\usepackage{tkz-graph}

\begin{document}

\begin{frame}
\begin{algorithmic}
\Function{deleteMax}{}{
\State{$P \gets$ \Call{Skip-Search}{$L$, Max}}
}
\EndFunction
\end{algorithmic}
\end{frame}

\end{document}

This produces the error

 ! Missing \endcsname inserted. \ALG@currentblock@2

that I just can't get rid of. Strangely enough, if I add an if statement, I do not get an error.

Note: I can put any amount of \State statements without the \Function body, so the error seems to be related to that somehow.

  • Removing the extra set of brackets seems to fix the issue, but I do not know why. I have other examples with these brackets there, and they do not cause an issue. – user340082710 Jun 12 '16 at 5:32
4

The problem here is your interpretation of the macros involved with the algorithmic construction. The \State macro doesn't take an argument. So, use

\State <state content>

and not

\State{<state content>}

In a similar way, you think \Function takes three arguments, the last of which is the body of the function. This is not true, as the start and end of the function are given by \Function and \EndFunction, respectively (see section 3.1.6. the function block of the algorithmicx documentation). So, use

\Function{<name>}{<parms>}
  <body>
\EndFunction

and not

\Function{<name>}{<parms>}{
  <body>
}
\EndFunction

Here is a minimal example that provides what I described above:

enter image description here

\documentclass{beamer}

\usepackage{algpseudocode}

\begin{document}

\begin{frame}
  \begin{algorithmic}
    \Function{deleteMax}{}
      \State $P \gets$ \Call{Skip-Search}{$L$, Max}
    \EndFunction
  \end{algorithmic}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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