In algorithm2e how can I use the function name (as printed/ style) in the caption and any other part of the document. I notice using the "\FUNNAME" ,in general, sometimes works and sometimes do not. In the example below using \GETMAX works in the document (sometimes) and does not work with the caption at all. Is there specific way to be able to resolve this issue ?
Example:
\documentclass{article}
\usepackage{epsfig}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\SetKwProg{Fn}{Function}{}{end}
\SetKwFunction{GETMAX}{getMax}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\Fn{\GETMAX{atom, neighbour}} {
\KwIn{x }
\KwOut{max}
$max \gets x[1]$\;
\For{$i \gets 2$ \textbf{to} $n$} {
\If{$x[i] > max$} {
$max \gets x[i]$\;
}
}
\Return{$max$}\;
}
\caption{\texttt{getMax} isa function }
\label{algo:getmax}
\end{algorithm}
Algorithm~\ref{algo:getmax} \GETMAX function I can not use same command inside the caption
\end{document}