[Tex/LaTex] Put caption on top of figure and source at the bottom with two footnotes

captionsfloatsfootnotespositioning

What I'm trying to do is this:

Figure 1: Caption of the figure.
_____________________________________

Figure
_____________________________________
Source: Images from Jhon¹ and Joseph²

(Bottom of the page)
_______
1 Source of one image    
2 Source of the other image

I tried many methods but none of them worked like this. The code I use which achieves this result (but with some "bugs") is this:

\newcommand{\footnotelabeled}[2]{%
\addtocounter{footnote}{1}%
\footnotetext[\thefootnote]{\label{#1}#2}}
\newcommand{\footnoteref}[1]{$^{\ref{#1}}$}

\afterpage{
\begin{figure}[htbp]
\centering
\includegraphics[width=0.9\linewidth]{fig.png}
\caption{Caption of the figure}
\label{fig:test}
\end{figure}
\begingroup
\captionof*{figure}{Source: Images from Jhon\footnoteref{one} and Joseph\footnoteref{another}}
\footnotelabeled{one}{Source of one image}
\footnotelabeled{another}{Source of the other image}
\endgroup}

However, this results in cases where two Sources are at the same figure and the next figure doesn't have Source (because its at the other one on top).

Any ideas?

Best Answer

\queuepage works like \afterpage but will not run until the previous \queuepage is done.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{afterpage}
\usepackage{mwe}

\newcounter{nextqpage}% incremented when queued
\newcounter{lastqpage}% incremented when used

\newcommand{\queuepage}[1]% #1 = same as \afterpage
{\global\long\expandafter\def\csname queuepage\thenextqpage\endcsname{%
   \stepcounter{lastqpage}%
   \ifnum\value{lastqpage}<\value{nextqpage}\relax%
     \afterpage{\csname queuepage\thelastqpage\endcsname}
   \fi
   #1}%
 \ifnum\value{lastqpage}=\value{nextqpage}\relax%
   \afterpage{\csname queuepage\thelastqpage\endcsname}%
 \fi
 \stepcounter{nextqpage}%
}

\newcommand{\footnotelabeled}[2]{%
\addtocounter{footnote}{1}%
\footnotetext[\thefootnote]{\label{#1}#2}}
\newcommand{\footnoteref}[1]{$^{\ref{#1}}$}

\begin{document}

\queuepage{%
\begin{figure}[t]
\caption{Caption of the figure}
\label{fig:test}
\medskip
\centering
\includegraphics[width=0.9\linewidth]{example-image-a}
\par\medskip
Source: Images from Jhon\footnoteref{one} and Joseph\footnoteref{another}
\end{figure}
\footnotelabeled{one}{Source of one image}
\footnotelabeled{another}{Source of the other image}}

\lipsum[1]

\queuepage{%
\begin{figure}[t]
\caption{Caption of the figure}
\label{fig:test2}
\medskip
\centering
\includegraphics[width=0.9\linewidth]{example-image-b}
\par\medskip
Source: Images from Jhon\footnoteref{third} and Joseph\footnoteref{fourth}
\end{figure}
\footnotelabeled{third}{Source of one image}
\footnotelabeled{fourth}{Source of the other image}}

\lipsum[2-12]

\end{document}

pages 2 and 3

Related Question