Hi,
I am just wondering how can I add a footnote inside the algorithm (using the algorithm package) next to the comments, I tried to add it but it gave me a number next to the sentence, but at the bottom of the page nothing has been shown to indicate the description of the footnote.
Thanks,
General ⇒ footnote when dealing with algorithms
NEW: TikZ book now 40% off at Amazon.com for a short time.

footnote when dealing with algorithms
The algorithm environment generates a float (as figure or table). The \footnote command doesn't work inside floats. If you use the h (default) or t descriptor for positioning the algorithm, you can combine \footnotemark and \footnotetext to get the footnote, as shown in the following example:
EDITED: In the preceding example, the combination of \footnotemark and \footnotetext gives the desired result... by chance. In general, independently of the descriptor used to position the float, it is rather unlikely that the float and the footnote text appear in the same page. It is quite difficult to add footnotes to floats. See, for example, this page and this thread.
Code: Select all
\documentclass{article}
\usepackage{algpseudocode,algorithm}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{algorithm}[t]
\caption{Euclid’s algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$\footnotemark
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\footnotetext{A footnote about the statement $r\gets a\bmod b$.}
\lipsum[2]
\end{document}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.