URL with tilde character?

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:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\url{http://lyle.smu.edu/~tspell/jaws}
\end{document}

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.


The ~ character will work fine if used inside \url{} or \hyperref{} within your text because they automatically disable all the TeX parsing; as described by Martin Scharrer. The same is true for other characters like _ and for the \path{} command provided by the url package.

But if you have a URL within your bibliography’s .bib file it won’t work. The solution to this problem is to URL encode the character. The tilde would be encoded as %7E. The bibliography entry would look like this:

@article{Spell.2009,
  author = {Spell, Brett},
  date   = {2009-12-24},
  title  = {Java API for WordNet Searching (JAWS)},
  url    = {http://lyle.smu.edu/%7Etspell/jaws/},
}

This will compile correctly and the URL is clickable in e.g. generated PDF. You can even just copy that URL into your browser, it will load as expected.


uses \%7E to replace ~, do not forget \ before %7E.

url    = {http://lyle.smu.edu/\%7Etspell/jaws/},