This is fine:
\documentclass{article}
\usepackage[boxed]{algorithm2e}
\begin{document}
\begin{algorithm}
$x \gets x$\;
\caption{Identity}
\end{algorithm}
\end{document}
But this, which uses the predefined environment "function" (p. 4 of the manual)
\documentclass{article}
\usepackage[boxed]{algorithm2e}
\begin{document}
\begin{function}
$x \gets x$\;
\caption{Identity}
\end{function}
\end{document}
produces this error
Runaway argument?
Identity@\endcsname ##1{\FuncSty {\algocf@captname Identity@(}\ArgSty \ETC.
./sandbox.tex:10: Paragraph ended before \algocf@captname was complete.
<to be read again>
\par
l.10
? r
OK, entering \nonstopmode...
./sandbox.tex:10: Missing \endcsname inserted.
<to be read again>
\par
l.10
)
! Emergency stop.
I use TexShop which (I believe) compiles with
simpdftex latex --maxpfb --extratexopts "-file-line-error -synctex=1"
Any help would be appreciate, I am out of ideas.
Best Answer
This is explained in page 17 of the documentation (talking about the
procedure
environment, but the same remark applies tofunction
):A complete example: