I try to add some texts used to illustrate the algorithms right below the bottom line of algorithms.
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[hang,flushmargin]{footmisc}
\usepackage{caption}
\begin{document}
\begin{algorithm}
\caption{How to write algorithms}\label{algorithm1}
\KwIn{this text}
\KwOut{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
$y_0\leftarrow y$\;
}
}
\end{algorithm}
\end{document}
I want to add some text below the bottom line as shown below:
Based on How to create footnote for algorithmicx's comment, one should be using a minipage
. I update my codes as follows:
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[hang,flushmargin]{footmisc}
\usepackage{caption}
\begin{document}
\noindent\begin{minipage}{\textwidth}
\begin{algorithm}
\caption{How to write algorithms}\label{algorithm1}\footnotetext{$y_0$ denotes the initial value.}
\KwIn{this text}
\KwOut{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
$y_0\leftarrow y$\;
}
}
\end{algorithm}
\renewcommand\footnoterule{}
\end{minipage}
\end{document}
but errors occur.
Any suggestion will be greatly appreciated.
Best Answer
The construction of
algorithm2e
's float is intricate, since it allows for specifying a stay-H
ere-style float placement without the use offloat
. Additionally it manages placement of captions at the top or bottom to suit different styles. So accommodate your request for a footnote inside this float you need to split it in somewhere where it will not influence the other components in the construction. Here's a patch that provides\algorithmfootnote[<style>]{<stuff>}
(<style>
defaults to\footnotesize
):