
次のような簡単な例がありますが、コンパイルできません。
\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}
これによりエラーが発生します
! 挿入された \endcsname がありません。\ALG@currentblock@2
どうしても取り除くことができません。不思議なことに、if ステートメントを追加すると、エラーは発生しません。
注: \Function 本体なしで任意の数のステートメントを配置できる\State
ため、エラーは何らかの形でそれに関連しているようです。
答え1
ここで問題となるのは、構築に関係するマクロの解釈ですalgorithmic
。\State
マクロは引数を取りません。そのため、
\State <state content>
そしてそうではない
\State{<state content>}
同様に、 は\Function
3つの引数を取り、最後の引数が関数の本体であると考えます。これは正しくありません。関数の開始と終了はそれぞれ\Function
とで与えられます\EndFunction
(セクション3.1.6. 機能ブロックのalgorithmicx
ドキュメンテーション)。
\Function{<name>}{<parms>}
<body>
\EndFunction
そしてそうではない
\Function{<name>}{<parms>}{
<body>
}
\EndFunction
以下は、上で説明した内容を実現する最小限の例です。
\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}