UK TeX FAQ -- question label setURL

### Typesetting URLs

URLs tend to be very long, and contain characters that would naturally prevent them being hyphenated even if they weren't typically set in `\``ttfamily`, verbatim. Therefore, without special treatment, they often produce wildly overfull `\``hbox`es, and their typeset representation is awful.

There are three packages that help solve this problem:

- The path package, which defines a `\``path` command. The command defines each potential break character as a `\``discretionary`, and offers the user the opportunity of specifying a personal list of potential break characters. Its chief disadvantage is fragility in LaTeX moving arguments. The Eplain macros - define a similar `\``path` command.

  Path, though it works in simple situations, makes no attempt to work with LaTeX (it is irremediably fragile). Despite its long and honourable history, it is no longer recommended for LaTeX use.

- The url package, which defines an `\``url` command (among others, including its own `\``path` command). The command gives each potential break character a maths-mode 'personality', and then sets the URL itself (in the user's choice of font) in maths mode. It can produce (LaTeX-style) 'robust' commands (see use of `\``protect`) for use within moving arguments. Note that, because the operation is conducted in maths mode, spaces within the URL argument are ignored unless special steps are taken.

  It is possible to use the url package in Plain TeX, with the assistance of the miniltx package (which was originally developed for using the LaTeX graphics package in Plain TeX). A small patch is also necessary: the required sequence is therefore:

      \input miniltx
      \expandafter\def\expandafter\+\expandafter{\+}
      \input url.sty

- The hyperref package, which uses the typesetting code of url, in a context where the typeset text forms the anchor of a link.

The author of this answer prefers the (rather newer) url package (directly or indirectly); both path and url work well with Plain TeX (though of course, the fancy LaTeX facilities of url don't have much place there). (hyperref isn't available in a version for use with Plain TeX.)

Documentation of both path and url is in the package files.

`hyperref.sty`
  macros/latex/contrib/hyperref (zip, browse)
`miniltx.tex`
  Distributed as part of macros/plain/graphics (zip, browse)
`path.sty`
  macros/latex/contrib/misc/path.sty
`url.sty`
  macros/latex/contrib/misc/url.sty

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=setURL