DEV Community

Breno Viana
Breno Viana

Posted on • Updated on

Using multiple footnotes in float environments

The problems

I was writing my MSc thesis when I just tried to add two footnotes in the captions of two subfigures. The result of my first try was something like this:

Alt Text

Well, the problem is that I expected the footnotes to be at the bottom of the page. And I solved it quite fast by using \footnotemark[...] and \footnotetext[...]{...}. However, another problem arose: only the label of the last footnote was linkable and I wanted both to be linkable.

The fix

I googled a lot but no solution was good enough to solve both problems. I found some solutions proposing using the footnotehyper package but they did not help with the first problem. After some hours I found this 2012 post showing the savenotes environment of footnote package. It did not solve my second problem, but I realized that the footnotehyper could be based on the footnote so I could use the savenotes environment as well. And it worked finely! More about the footnotehyper documentation here.

The code

\documentclass{article}

\usepackage{geometry}
\geometry{a5paper,landscape,margin=0.5in}

\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{caption,subcaption}
\usepackage{footnotehyper}

\begin{document}

\pagestyle{empty}

\begin{savenotes}
    \begin{figure}[ht]
        \centering
        \caption{Animals.}
        \label{fig:animals}
        \begin{subfigure}[b]{0.48\textwidth}
            \centering
            \caption{A cat.}
            \label{fig:cat}
            \includegraphics[width=\textwidth]{cat.jpg}
            \caption*{Source: \href{https://unsplash.com}{Unsplash}\footnote{Source: \href{https://unsplash.com/photos/kjERLXaHjXc}{https://unsplash.com/photos/kjERLXaHjXc}.}.}
        \end{subfigure}
        ~
        \begin{subfigure}[b]{0.48\textwidth}
            \centering
            \caption{A dog.}
            \label{fig:dog}
            \includegraphics[width=\textwidth]{dog.jpg}
            \caption*{Source: \href{https://unsplash.com}{Unsplash}\footnote{Source: \href{https://unsplash.com/photos/N04FIfHhv_k}{https://unsplash.com/photos/N04FIfHhv\_k}.}.}
        \end{subfigure}
    \end{figure}
\end{savenotes}

\end{document}
Enter fullscreen mode Exit fullscreen mode

The result

Alt Text

References

Discussion (0)