How to write URLs in Latex?

UrlLatexText Formatting

Url Problem Overview


How do you write a URL in Latex?

The subscripts and everything else make the font look very strange when it compiles.

Url Solutions


Solution 1 - Url

You can use \url

\usepackage{hyperref}
\url{http://stackoverflow.com/}

Solution 2 - Url

You just need to escape characters that have special meaning: # $ % & ~ _ ^ \ { }

So

http://stack_overflow.com/~foo%20bar#link

would be

http://stack\_overflow.com/\~foo\%20bar\#link

Solution 3 - Url

Here is all the information you need in order to format clickable hyperlinks in LaTeX:

http://en.wikibooks.org/wiki/LaTeX/Hyperlinks

Essentially, you use the hyperref package and use the \url or \href tag depending on what you're trying to achieve.

Solution 4 - Url

A minimalist implementation of the \url macro that uses only Tex primitives:

\def\url#1{\expandafter\string\csname #1\endcsname}

This url absolutely won't break over lines, though; the hypperef package is better for that.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondanzigView Question on Stackoverflow
Solution 1 - Urlzs2020View Answer on Stackoverflow
Solution 2 - UrlGabeView Answer on Stackoverflow
Solution 3 - UrlmandaleekaView Answer on Stackoverflow
Solution 4 - UrlCharles StewartView Answer on Stackoverflow