7

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?

4
  • 1
    Welcome! Please post a minimal working example (MWE) i.e. a complete, small document which reproduces the issue. Do you really want floats for this? Why not just use \includegraphics etc. without the figure environments? – cfr Apr 17 '15 at 2:56
  • 1
    So the problem is if you have two \afterpages on the same page and there is only room for one. – John Kormylo Apr 17 '15 at 5:27
  • @cfr, I want floats because latex can take care of positioning the figures in the "optimal" way for me. – LoopInt Apr 22 '15 at 15:24
  • @John Kormylo, yes that seems whats causing the problem. – LoopInt Apr 22 '15 at 15:24
3

\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

2
  • This is the only answer until now that I can put various figures and the footnotes go on the right page. Thanks! – LoopInt Apr 22 '15 at 15:10
  • @LoopInt: That's because in this version the image is always placed at the top of the page, leaving ample room to fill the bottom with however many footnotes can fit - more than in the other solutions. – Werner Apr 22 '15 at 16:43
4

The best practice is never use page footnotes inside floats. You can make show footnotes in a more "orthodox" way using \foonotemark inside the float and\footnotetext[2]{Source of the other image} outside, or a normal \footnote{} inside the float with the ftnxtra package.

However, keep in mind that what is inside a float environment can fleet as the wind, and all what is/left outside stands still as a rock. If the float move to other page, the foot note remain where is the surrounding text (may be several pages before).

Moreover, when the float remain in the same page, but in a bottom position, the footnote might appear by default above the float (a "head note"). There also packages to solve it (see the example) but the main problem remain: the floats have a the bad habit of floating.

So you have two workarounds for this:

(1) Manually move the figure code so that it appear in the same page. But you can never be sure of that until the final version.

(2) Forcing the float code to move automatically just to the top of the next page with afterpage package. (Safer, but note that previous unprocessed floats may force the figure to go beyond). Example:

enter image description here

\documentclass{article}
\usepackage[paperheight=5in,paperwidth=6in,top=.3in,margin=.5in]{geometry}
                        % custom page size for the example 
\usepackage{graphicx}   % you know ...
\usepackage{lipsum}     % dummy text
\usepackage{afterpage}  % put something after the actual page
\usepackage{ftnxtra}    % footnote in floats, sections, ... 
\usepackage{fnpos}      % Avoid floats under the footnotes
                        % or use \usepackage{stfloats} and \fnbelowfloat

\begin{document}

\begin{figure}[htp]
\caption{The caption of A}\centering
\includegraphics[width=.5\linewidth,height=1in]{example-image-a}\par
Source: Images from Jhon\footnote{Source of one image}
and Joseph\footnote{Source of the other image}
\end{figure}

% use \afterpage if you know that only can be placed in the next page  
\afterpage{
\begin{figure}
\caption{The caption of B}\centering
\includegraphics[width=.5\linewidth,height=1in]{example-image-b}\par
Source: Images from Peter\footnote{About Peter}
and David\footnote{Some about David}
\end{figure}
}

\lipsum[1-2] % dummy text

\end{document}
2
  • Yes, I understand the issue with floats, but I wanted latex to put the figure in the "optimal" position for me. Workaround 1 is impractical for me, and the afterpage works on certain conditions, but needs some tweeks sometimes. Still thanks! – LoopInt Apr 22 '15 at 15:14
  • @LooInt You can also relax LateX rules about floats (\topfraction, etc.) to avoid problems when there are too many floats, so that afterpage trick could work in most cases. See here. – Fran Apr 22 '15 at 17:22
2

You can use the copyrightbox package for that. It cooperates with hyperref, cleveref and tablefootnotes, provided your figures are set in a tableenvironment and you use\captionof{figure]{…}from thecaption` package:

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{afterpage}
\usepackage{mwe}
\usepackage{copyrightbox}

\usepackage[pdfborder = 0 0 0,colorlinks]{hyperref}
\usepackage{cleveref}
\crefformat{footnote}{footnote\,\textsuperscript{#2#1#3}}
\Crefformat{footnote}{Footnote\,\textsuperscript{#2#1#3}}
\labelcrefformat{footnote}{\textsuperscript{#2#1#3}}
\crefmultiformat{footnote}{footnotes\,\textsuperscript{#2#1#3}}{\textsuperscript{,#2#1#3}}{\textsuperscript{,#2#1#3}}{\textsuperscript{,#2#1#3}}
\Crefmultiformat{footnote}{Footnotes\,\textsuperscript{#2#1#3}}{\textsuperscript{,#2#1#3}}{\textsuperscript{,#2#1#3}}{\textsuperscript{,#2#1#3}}
\labelcrefmultiformat{footnote}{#2\textsuperscript{#1}#3}{#2\textsuperscript{,#1}#3}{#2\textsuperscript{,#1}#3}{#2\textsuperscript{,#1}#3}
\usepackage{tablefootnote}

\begin{document}

\lipsum[2]
We see in\labelcref{one} and in \cref{two}…

\begin{table}[!ht]
  \captionof{figure}{Caption of the figure}
  \label{fig:test}
  \medskip
  \centering
  \copyrightbox[b]{\includegraphics[width=0.9\linewidth]{example-image-a}}
  {Source: Images from Jhon\tablefootnote{\label{one}Source of one image} and Joseph\tablefootnote{\label{two}Source of the other image}}
\end{table}
\afterpage{
  \begin{table}[t]
    \captionof{figure}{Caption of the figure}
    \label{fig:test}
    \medskip
    \centering
    \copyrightbox[b]{\includegraphics[width=0.9\linewidth]{example-image-b}}
    {Source: Images from Jhon\tablefootnote{\label{third}Another source of one image} and Joseph\tablefootnote{\label{fourth}Further source of the other image}}
  \end{table}
}
And now, grouped references\labelcref{third,fourth}!
\lipsum[3-4]
\end{document} 

enter image description here

enter image description here

2
  • If I put many pictures after another with the figure code, the footnotes gets messed up. That works in some cases, but it needs some tweeks sometimes. But thanks for helping! – LoopInt Apr 22 '15 at 15:18
  • @LoopInt: I changed the code, using the tablefootnote package which hopefully won't mess up the footnotes. It is compatible with hyperlinks. The only problem is tablefootnotes is designed only for a table` environment, and I had to put the figures in a table environment combined with \captionof. – Bernard Apr 22 '15 at 18:06
0

Here is a slightly modified view on the float placement using a forced location - using the [H] float specifier from float:

enter image description here

\documentclass{article}
\usepackage{graphicx,float,etextools,lipsum,refcount}

\makeatletter
\newcommand{\markfootnote}{\edef\@currentlabel{\thefootnote}}
\g@addto@macro{\footnotemark}{\markfootnote}
\makeatother

\begin{document}

\lipsum[1]

\begin{figure}[H]
  \caption{Caption of the figure}
  \vspace{\belowcaptionskip}
  \centering
  \includegraphics[width=0.9\linewidth]{example-image}
  \par\medskip
  Source: Images from Jhon\footnotemark\label{fnmarkA} and Joseph\footnotemark\label{fnmarkB}.
  \AfterGroup{%
    \footnotetext[\getrefnumber{fnmarkA}]{Source of one image}%
    \footnotetext[\getrefnumber{fnmarkB}]{Source of the other image}%
  }
\end{figure}

\lipsum[2-10]

\end{document}

Floats, well... float, and therefore it's not always certain whether they may fall on the page where they're called. As such, forcing the placement to stay [H]ere circumvents that.

However, floats typically gobble footnotes. Escaping this is possible by calling the footnote text placement After the Group (the \begin{figure}...\end{figure} construction) is finished.

Note that the above set won't work if you set your footnote numbering to anything other than \arabic as refcount passes a numeric value to \footnotetext as a reference.

1
  • If I put many figures in sequence, it messes up the footnotes. It needs some tweeks to get right. But thanks for the help! – LoopInt Apr 22 '15 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.