[Tex/LaTex] URL with tilde character


I'm trying to make a URL with a tilde character (~) in it:


It looks right in the resulting PDF, but when clicking on it the browser goes to a wrong URL: http://lyle.smu.edu/%18tspell/jaws

If I type in the browser %7e (escape code for '~') instead of %18 the browser then goes to the correct URL.

Any idea how to get a correct link in the PDF?

Best Answer

You should use the hyperref package (which uses url internally but improves on it). It will not only format the link but also place a real hyperlink into the PDF. With url alone the link is only normal text, but is probably recognized as hyperlink by your PDF viewer, but with the wrong code for ~. LaTeX tends to substitute the code of these special characters depending on the font you use instead of taking the ASCII code.

This works fine with Acrobat Reader:


A funny thing is that %18 is the ASCII code for "CAN (cancel)", which doesn't make much sense and \char"18 isn't the tilde in the tt font. I can't follow how this specific code was produced.