[Tex/LaTex] Footnote is not clickable and the PDF cannot be selected

footnoteshyperrefpdf

Say in chapter 2, page 10 I create a foonote (by doing: \footnote{bla bla....}). When I reference it in Page 10 I get a clickable reference to that footnote. But, in page 12 when I reference this footnote using \footnotemark[\value{footnote}] , I get the number of the footnote correct, but this time its not clickable. How can I fix this?

I am using Windows 7, MikTEX 2.9 and TexMaker. The PDF that I create is OK. But I can't seem to copy any text from the PDF. When I click, a long vertical bar appears. I am using Adobe PDF for viewing.

Best Answer

It seems that \footnotemark[... is defined by hyperref to just typeset the number while a link is only created when \footnotemark is used without optional argument. Interestingly, in the latter case I was geting a link which lead nowhere.

It seems one must make an explicit mechanism for saving and restoring the link.

Try

\documentclass{article}

\usepackage{hyperref}

\makeatletter

\newcommand\savefootnotemark[1]
{%
  \expandafter\edef\csname fnmark@#1\endcsname%
  {%
    \noexpand\do@fnmark
    {\number\c@footnote}{\unexpanded\expandafter{\Hy@footnote@currentHref}}%
  }%
}

\newcommand\footnoterefmark[1]
{%
  \csname fnmark@#1\endcsname%
}

\newcommand\do@fnmark[2]
{%
  \begingroup
    \c@footnote #1\relax
    \def\@thefnmark{\thefootnote}%
    \leavevmode
    \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
    \hyper@linkstart{link}{#2}%
    \@makefnmark
    \hyper@linkend
    \ifhmode\spacefactor\@x@sf\fi
    \relax
  \endgroup
}  

\makeatother

\begin{document}

xxx

\clearpage

foo\footnote{bar}\savefootnotemark{fnone}.

\clearpage

baz\footnoterefmark{fnone}.\footnote{quux}\savefootnotemark{fntwo}

\clearpage

test1\footnoterefmark{fntwo},test2\footnoterefmark{fnone}.

\end{document}

One should think this is such a common request it must have been done in some package already.