Search code examples
latexhyperref

extra "file://" prefix generated by pdflatex using hyperref package in macro


The LaTeX hyperref package confuses me in several ways. Here's my particular problem.

In my document, the command

\footnote{
\url{http://www.boston.com/news/science/articles/2010/04/25/new_atlas_shows_the_state_of_nature_as_well_as_the_nature_of_states/}
}

works just fine - pdflatex generates just the valid link.

But the commands

\newcommand{\webref}[1]{\footnote{\url{#1}}}

\webref{http://www.boston.com/news/science/articles/2010/04/25/new_atlas_shows_the_state_of_nature_as_well_as_the_nature_of_states/
}

generates the link

file:///C|/eb/qrbook/%20http://www.boston.com/news/science/articles/2010/04/25/new_atlas_shows_the_state_of_nature_as_well_as_the_nature_of_states/

Can someone tell me where the extra "file://..." comes from, and how to get rid of it?


Solution

  • Wild guess: Are you sure you're not introducing any extraneous spaces anywhere? I can reproduce the behaviour if I introduce a linebreak just before #1. (Pro tip: Put a % just after the last character in multi-line commands, so LaTeX doesn't process the newline.)