3

I want to include a figure in my text. The text should be wrapped around this figure, thus using environment wrapfigure. In the figure's caption I need a footnote, that includes the reference to the source (as an URL).

I roamed the sites for a ridiculous amount of time, searching for a solution.

I do not want to use the solution including \footnotemark in the float environment, \footnotetext outside of it and manually increasing the counter because it yields no proper linking with hyperref...

Here's a MWE:

\documentclass[11pt,a4paper,bibtotoc,idxtotoc,headsepline,footsepline,%
 footexclude,BCOR12mm,DIV13]{scrbook}
\usepackage[pdftex,colorlinks=true,linkcolor=red,citecolor=red,%
 anchorcolor=red,urlcolor=red,bookmarks=true,%
 bookmarksopen=true,bookmarksopenlevel=0,plainpages=false%
 bookmarksnumbered=true,hyperindex=false,pdfstartview=,%
 ,hyperindex=false,
  ]{hyperref}

\usepackage{graphicx}

\usepackage{wrapfig}
\usepackage{footnote}
\usepackage{caption}

%  \makesavenoteenv{wrapfigure}
%  \makesavenoteenv{figure}

\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet

\begin{wrapfigure}{l}{0.25\textwidth}
\includegraphics[width=0.20\textwidth]{johnny}
%  \captionof{figure}[johnny lof]{\copyright johnny inc. \footnote{\url{google.com}} } 
\end{wrapfigure}

ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 

\end{document}
4
  • 1
    since the footnote must be within the figure, is it really necessary to have it linked? how about just breaking the caption line and setting the credit in a smaller font on another line? Jan 19, 2012 at 17:50
  • 1
    Write \footnotemark in the caption and \footnotetext{\url{google.com}} just after \end{wrapfigure}.
    – egreg
    Jan 19, 2012 at 17:50
  • @egreg: When testing this with TeXlive, I got a link to the google.com file on my hard disc and the wrong footnotenumber (0). Did I make a mistake?
    – Stephen
    Jan 19, 2012 at 19:24
  • Just wanted to mention that there is the [ctan.org/pkg/lipsum] package for inserting this kind of text.
    – Stephen
    Jan 19, 2012 at 19:29

1 Answer 1

4

Well, maybe this is overkill, but nevertheless (explanation below the code):

\documentclass[11pt,a4paper,bibtotoc,idxtotoc,headsepline,footsepline,%
footexclude,BCOR12mm,DIV13]{scrbook}
\usepackage[pdftex,colorlinks=true,linkcolor=red,citecolor=red,%
 anchorcolor=red,urlcolor=red,bookmarks=true,%
 bookmarksopen=true,bookmarksopenlevel=0,plainpages=false%
 bookmarksnumbered=true,hyperindex=false,pdfstartview=,%
 ,hyperindex=false,
  ]{hyperref}

\usepackage{graphicx}

\usepackage{wrapfig}
\usepackage{footnote}
\usepackage{caption}

%  \makesavenoteenv{wrapfigure}
%  \makesavenoteenv{figure}

\makeatletter
\newcommand{\wrapfigfoot}{%
\addtocounter{footnote}{+1}%
\addtocounter{Hfootnote}{+1}%
\global\let\Hy@saved@currentHref\@currentHref%
\hyper@makecurrent{Hfootnote}%
\global\let\Hy@footnote@currentHref\@currentHref%
\global\let\@currentHref\Hy@saved@currentHref%
}
\makeatother


\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet

\begin{wrapfigure}{l}{0.25\textwidth}
\includegraphics[width=0.20\textwidth]{johnny}
\captionof{figure}[johnny lof]{\copyright johnny inc.\footnotemark and xyz\footnotemark}
\end{wrapfigure}
\addtocounter{footnote}{-2}%  -1 times total number of footnote(mark)s in the wrapfigure
\addtocounter{Hfootnote}{-2}% -1 times total number of footnote(mark)s in the wrapfigure
\wrapfigfoot\footnotetext{\href{http://www.google.com/}{google.com}}
\wrapfigfoot\footnotetext{just another footnote in wrapfigure environment}

ipsum dolorsit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no\footnote{another footnote} end.

\newpage

Lorem ipsum\ldots

\AtEndDocument{
\ifnum\value{Hfootnote}=\value{footnote}%OK
  \PackageInfo{footnote}{%
    Number of Hyperfootnotes \arabic{Hfootnote} = number of footnotes \arabic{footnote}!
    \MessageBreak}
\else
  \PackageError{footnote}{%
    Hyperfootnote \arabic{Hfootnote} != footnote \arabic{footnote}!%
   }{Did you make a mistake with\MessageBreak%
     \string\footnotemark , \string\footnotetext , or \MessageBreak%
     \string\addtocounter { Hfootnote or footnote } ?%
   }
\fi%
}

\end{document}

OK, there are several problems:

  1. \url{google.com} does not link to Google, but to the (DOS-command?!) file google.com on your hard-disk. Use \href{http://www.google.com/}{google.com} instead, where the first argument is the url and the second one the text to be shown in the document.
  2. Footnotes are trapped in environments. Therefore \footnotemark inside of the environment and \footnotetext{The text of the footnote} after the end of the environment is necessary.
  3. The footnote-numbers are wrong, when more then one footnote-mark/-text is used. This is fixed by using \addtocounter{footnote}{number} manually.
  4. The Hyperref-footnote-numbers are not affected by \addtocounter{footnote}{number}, therefore they need to be changed manually, too: \addtocounter{Hfootnote}{number}, and additionally some more code copied from the hyperref package, which I packed into the \wrapfigfoot command.

As test, whether hyper- and normal footnote-number are equal, I added some code to be executed at the end of the document.
(I just hope it can be understood, or it solves your problem at least.)

2
  • Thank you @Stephen. This is the working solution of my problem. You made my day! ;)
    – Eric
    Jan 20, 2012 at 9:13
  • @Eric: Glad that I could help.
    – Stephen
    Jan 20, 2012 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .