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.
Best Answer
The problem here is your interpretation of the macros involved with the
algorithmic
construction. The\State
macro doesn't take an argument. So, useand not
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 thealgorithmicx
documentation). So, useand not
Here is a minimal example that provides what I described above: