32

I use \usepackage{url} and \url{…} to typeset URLs, but the typewriter font stands out a little too much. How can I have the URLs typeset in a different font?

Vebjorn Ljosa
  • 22,437
  • 17
  • 43
  • 32
  • 4
    May I suggest you leave your questions up for a short while before answering them yourself; there was a little discussion on this: http://meta.tex.stackexchange.com/questions/4/asking-a-question-and-answering-it-yourself-straight-away – Andrew Stacey Jul 30 '10 at 19:33

1 Answers1

38

According to the README,

you can switch the style of printing using \urlstyle{tt}, where tt can be any defined style. The pre-defined styles are tt, rm, sf, and same, all of which produce the same linebreaks but use different fonts—the first three select a specific font and the ‘same’ style uses the current text font.

You can also define your own font:

\makeatletter
\def\url@foostyle{%
  \@ifundefined{selectfont}{\def\UrlFont{\sf}}{\def\UrlFont{\small\ttfamily}}}
\makeatother

%% Now actually use the newly defined style.
\urlstyle{foo}

(The last example is from http://www.kronto.org/thesis/tips/url-formatting.html.)

Vebjorn Ljosa
  • 22,437
  • 17
  • 43
  • 32