
컴파일할 수 없는 다음과 같은 간단한 예제가 있습니다.
\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
그 중 마지막 인수는 함수의 본문입니다. 함수의 시작과 끝이 다음 \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}