In the following code, I have one problem with the test \ifthenelse{\equal{\pageref{#1}}{\thepage}}{...}{...}. Why doesn't this detect the equality hoped if the reference is in the same page where it is used and defined ?
% Sources :
% * http://tex.stackexchange.com/questions/35095/special-footnotes-for-url/35097#35097
% * http://tex.stackexchange.com/questions/35043/how-to-reference-different-places-to-the-same-footnote
% * http://forum.mathematex.net/latex-f6/forcer-le-retour-a-la-ligne-dans-texttt-t13246.html#p127511
% * http://tex.stackexchange.com/questions/33465/changing-the-catcode-of-in-one-command
\documentclass[10pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage{manyfoot}
\usepackage{xifthen}
\usepackage{hyperref}
\usepackage{varioref}
% Cosmetic
\hypersetup{urlcolor=blue}
\definecolor{urlColor}{named}{DarkRed}
\newcommand{\urlText}[2][0]{%
\textcolor{urlColor}{%
\ifthenelse{\equal{#1}{0}}{%
\textbf{#2}%
}{%
#2%
}%
}%
}
% Special footnote
\newfootnote{Url}
\newcounter{footnoteUrl}
\newcommand{\footnoteUrl}{%
% \renewcommand\thefootnoteUrl{\Alph{footnoteUrl}}
\stepcounter{footnoteUrl}%
\Footnotemark{\urlText{\#\thefootnoteUrl}}\FootnotetextUrl{}%
}
% New url
\newcommand{\newUrl}[2][0]{%
\urlText{http://link/}%
\ifthenelse{\equal{#1}{0}}{%
\footnoteUrl{\, \url{#2}}%
}{%
\footnoteUrl{\,\label{#1} \url{#2}}%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE PROBLEM IS HERE... %
%%%%%%%%%%%%%%%%%%%%%%%%%%
% Old url
\newcommand{\oldUrl}[1]{%
\urlText{http://link/\textsuperscript{\ref{#1}}}%
\ifthenelse{\equal{\pageref{#1}}{\thepage}}{}{%
\urlText[1]{(cf.\,page\,\pageref{#1})}%
}%
}
\usepackage{lipsum}
\begin{document}
Let's try to indicate one URL \newUrl[linkGoogle]{http://www.google.fr/}
and another \newUrl{http://tex.stackexchange.com/}.
Let's try to indicate one old URL \oldUrl{linkGoogle}.
and one more \newUrl{http://tug.org/texlive/pkginstall.html}
and another \newUrl[ctan]{http://www.ctan.org/}
and then the same \oldUrl{ctan}.
I would like to indicate something \footnote{... but here !}.
\lipsum
Just only old URLS \oldUrl{linkGoogle} and \oldUrl{ctan}.
I would like to indicate something \footnote{... but here !}.
\lipsum
Just only old URLS \oldUrl{linkGoogle} and \oldUrl{ctan}.
I would like to indicate something \footnote{... but here !}.
\end{document}