Inserting tilde (~) for URLs in LaTeX documents

There are certain characters that LaTeX has trouble with.  One of the main offenders is the tilde (~) symbol.  If you include it in plaintext, it disappears in the resulting ps or pdf document.  I found out the hard way today when trying to include a URL in a pdf document.  However, it gets worse – some of the suggested work arounds do not solve the problem.  They create the ~ symbol but the URL still doesn’t work.

It turns out you have to replace the tilde like this:


http://www.unc.edu/~haksaeng/latex-tilde.pdf  %Bad

http://www.unc.edu/\%7Ehaksaeng/latex-tilde.pdf  %Good

That %7E character is legal in LaTeX and represents a tilde in HTML.

To see example LaTeX code for tildes in URLs, check out:

http://unc.edu/~haksaeng/latex-tilde.tex

The document the code produces is here:

http://unc.edu/~haksaeng/latex-tilde.pdf

Good luck!

Advertisements

About glossarch

The word "glossarch" doesn't exist. At least, not yet. But let's pretend it does for a second. The first part is "gloss," a word that comes to us from Ancient Greek via Latin and English. It means "language." The second part also comes from Ancient Greek and can mean "having power over." So "glossarch" means simply "language controller." So what am I doing making up words? Well, I made up an entire language once. It's called Angosey. So I'm the Glossarch of Angosey. I'm currently a doctorate student in volcano seismology (a branch of geophysics). I enjoy writing fiction and poetry, launching balloons, programming, and hanging out with my lovely wife! Follow me on Twitter! Writing and language creation: @glossarch Balloons and science: @bovineaerospace
This entry was posted in SyntaxError (Programming) and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s