I have created pseudocode for an algorithm and would like to add a footnote under the algorithm. However, when I try to apply the answer provided here, no footnote does appear. See the following example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{algorithm, algpseudocode}
\makeatletter
\newcommand{\StatexIndent}[1][3]{%
\setlength\@tempdima{\algorithmicindent}%
\Statex\hskip\dimexpr#1\@tempdima\relax}
\algdef{S}[WHILE]{WhileNoDo}[1]{\algorithmicwhile\ #1}%
\newcommand{\algorithmfootnote}[2][\footnotesize]{%
\let\old@algocf@finish\@algocf@finish% Store algorithm finish macro
\def\@algocf@finish{\old@algocf@finish% Update finish macro to insert "footnote"
\leavevmode\rlap{\begin{minipage}{\linewidth}
#1#2
\end{minipage}}%
}%
}
\begin{document}
\begin{algorithm}[H]
\caption{Algorithm}
\algorithmfootnote{This is a footnote.}
\label{alg:algorithm}
\textbf{Input:} An input\\
\textbf{Output:} An output
\begin{algorithmic}[1]
\Procedure{Test}{}
\State $ x \gets$ 1
\State \Return x
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
which gives the following output:
Could someone tell me what I am doing wrong? Thanks in advance!
PS. I would like to keep using algorithmic (so not algorithmicx, algorithm2e, etc.) because of other layout structures

