Clickable URLs as footnotes in LaTeX
I often like to link to software packages or websites in scientific papers, and prefer URLs in PDFs to be clickable. You can do this quite easily in LaTeX:
(This requires the hyperref package.)
However, this has the ugly ‘http://’ or ‘https://’ prefix everywhere in the URLs which is decidedly less neat. You could drop it but come on, that’s just bad practice.
I also thought it would be nice if the relevant part of the text would already be clickable (e.g. ‘We published a browser-based listening test framework1.’)
Sure enough, you can do this too:
Of course, this becomes very long, so I made the following macro and have been using it everywhere since a year or so.
Then use as follows (still requiring the hyperref package):
1. Simple (no arguments)
This creates a footnote consisting of a clickable URL.
2. Link text (1 argument)
This creates a clickable piece of text in the text (‘My website’) plus a footnote consisting of a clickable URL.
3. Link text and invisible prefix (2 arguments)
This creates a clickable piece of text in the text (‘My website’) plus a footnote consisting of a clickable URL without the prefix (in this case ‘http://’). Upon clicking it, however, you are directed to the full link, i.e. ‘http://www.mywebsite.com’.
This ‘minimal working example’ consisting of a LaTeX and a PDF file further illustrates the concept.
You can use the xspace package to add/absorb spaces when necessary, e.g. to avoid a space between the footnote number and a punctuation mark.