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 ?





\Fn{\GETMAX{atom, neighbour}} {
\KwIn{x }
$max \gets x[1]$\;
\For{$i \gets 2$ \textbf{to} $n$} {
  \If{$x[i] > max$} {
    $max \gets x[i]$\;
\caption{\texttt{getMax}  isa  function }

Algorithm~\ref{algo:getmax} \GETMAX function I can not use same command inside the caption 


1 Answer 1


algorithm2e defines \GETMAX in a fragile way. This means that in commands which move their argument also to other places (the caption is move to the list of algorithm) it can break.

You should either protect the command:

 \caption{\protect\GETMAX  isa  function }

or make it robust:

  • many thanks that's work with me
    – AlKharusi
    Apr 20, 2019 at 11:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .