Algorithm2e lets you define functions using \SetKwFunction{Fn}{Function} which you can then reference anywhere in the document (not just in an algorithm environment) using e.g. \Fn (which will output Function all nicely typeset in the right font). However, this doesn't work inside captions. For example, the following doc:
\documentclass{article}
\usepackage{algorithm2e}
\SetKwFunction{Fn}{Function}
\begin{document}
\begin{algorithm}
\caption{\Fn, my function}
\KwRet{0}\;
\end{algorithm}
\end{document}
dies with
Argument of \@caption has an extra }.
<inserted text>
\par
l.6 \caption{\Fn, my function}
Anyone know what's going on, and how to fix it?
\caption{\protect\Fn my function}should work. – Benjamin Feb 09 '16 at 02:32