Skip to content

Confusing errors with URLs in latex

November 1, 2012

If you get a confusing error using URLs in latex…for example,

Missing $ inserted

It may be because there are tildes or underscores in your URL. I fixed it by putting a slash, \, before these characters,

\href{http://r-forge.r-project.org/R/?group_id=1171/}{http://r-forge.r-project.org/R/?group\_id=1171/}

NOTICE that I only put the slash in the second version of the URL. The reason is that the first version is where the browser is actually directed if someone clicks on a hyperlink (so this must be the exact URL without slashes), while the second is what gets printed in your pdf document (so this needs to use slashes so that latex doesn’t get confused).

Advertisements
No comments yet

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

%d bloggers like this: