[Tex/LaTex] Why are URLs typeset with monospace fonts by default

typewritertypographyurls

When typesetting URLs in LaTeX using the url package, they are set in a mono space font by default. While I just accepted that as a fact for a long time, I am now starting to wonder why?

In Browsers, for example, the URL in the address bar is also not monospace. It does not make the link more readable, in my opinion rather on the contrary. The only explanation I can come up with is that it sets the link apart from the remeaining text. But honestly, even that sometimes looks a bit obstrusive.

So is the reasons really just to set links apart from the text?

Best Answer

The default was chosen by the package author, according to the common way of setting URLs. Using a monospaced font helps distinguishing them, and this is the main reason.

However the font can be changed with \urlstyle that accepts one argument among

tt
rm
sf
same

The default is equivalent to \urlstyle{tt}; with \urlstyle{rm} and \urlstyle{sf} the font will be the roman or sans serif upright font. With \urlstyle{same} the current font will be used.

\documentclass{article}
\usepackage{url}
\begin{document}
\url{http://tex.stackexchange.com}

\urlstyle{rm}
\url{http://tex.stackexchange.com}

\urlstyle{sf}
\url{http://tex.stackexchange.com}

\urlstyle{same}
\url{http://tex.stackexchange.com}

\bfseries\urlstyle{same}
\url{http://tex.stackexchange.com}

\itshape\urlstyle{same}
\url{http://tex.stackexchange.com}

\mdseries\itshape\urlstyle{same}
\url{http://tex.stackexchange.com}

\end{document}

enter image description here