Last active
February 13, 2020 04:14
-
-
Save flymin/eff1ff8e2dffe8611f9d36112b318c49 to your computer and use it in GitHub Desktop.
[algo footnode] An example shows how to add footnote just below an algorithm. #Latex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage[ruled]{algorithm2e} | |
| \usepackage{amssymb,amsmath,caption} | |
| \usepackage[hang,flushmargin]{footmisc} | |
| \usepackage{lipsum} | |
| \makeatletter | |
| \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}}% | |
| }% | |
| } | |
| \makeatother | |
| \begin{document} | |
| \lipsum[1-3] | |
| \begin{algorithm}[tb] | |
| \caption{How to write algorithms}\label{algorithm1} | |
| \algorithmfootnote{$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} | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment