Code: Select all
Code, edit and compile here:
\documentclass[pdftex]{scrartcl}\usepackage[driver=pdftex,margin=25mm]{geometry}\usepackage[hyperfootnotes=false]{hyperref} % hotlinking footnotes disabled\usepackage{xstring} % used for \StrSubstitute in the def of \footnoteurl\usepackage{lipsum}\newcommand{\footnoteurl}[2]{\href{#1}{#2}\footnote{\nolinkurl{#1}}}%\newcommand{\footnoteurl}[2]{\href{#1}{#2}\footnote{\nolinkurl{\string{#1}}}}%\newcommand{\footnoteurl}[2]{\href{#1}{#2}\footnote{\nolinkurl{\detokenize{#1}}}}%\newcommand{\footnoteurl}[2]{\href{#1}{#2}\footnote{\detokenize{\nolinkurl{#1}}}}%\newcommand{\footnoteurl}[2]{\StrSubstitute{#1}{\#}{\#}[\cleanurl]\href{#1}{#2}\footnote{\nolinkurl{\cleanurl}}}%\newcommand{\footnoteurl}[2]{\expandafter\StrSubstitute{#1}{\#}{\#}[\cleanurl]\href{#1}{#2}\footnote{\nolinkurl{\cleanurl}}}%\newcommand{\footnoteurl}[2]{\noexpand\StrSubstitute{#1}{\#}{\#}[\cleanurl]\href{#1}{#2}\footnote{\nolinkurl{\cleanurl}}}%\newcommand{\urlescape}[1]{{%% \noexpandarg % suppress expansions made by xstring% \StrSubstitute{#1}{\#}{\#}[\x]% first step% \expandafter\StrSubstitute\expandafter{\x}{_}{\textunderscore }[\x]%% \x}}%\newcommand{\footnoteurl}[2]{\href{#1}{#2}\footnote{\nolinkurl{#1}}} % must escape hashes; e.g. "\#"\begin{document}\lipsum[1]\vspace{1em}Yada yada \footnoteurl%{https://www.sourcewatch.org/index.php?title=ALEC_Civil_Justice_Task_Force\#Politicians}{%ALEC financing} Yada yada\vspace{1em}\lipsum[1]\end{document}
\href
and \url
commands themselves do not require this, so it should be possible to write a macro that also does not require escaping the “#”. Notice all the commented out code. These are all failing attempts to remedy the problem.