summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-setURL.html
blob: c9e444ad6a8ad2bf405f4ad805647cde6bb86534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<head>
<title>UK TeX FAQ -- question label setURL</title>
</head><body>
<h3>Typesetting URLs</h3>
<p/>URLs tend to be very long, and contain characters that would
naturally prevent them being hyphenated even if they weren&rsquo;t typically
set in <code>\</code><code>ttfamily</code>, verbatim.  Therefore, without special treatment,
they often produce wildly overfull <code>\</code><code>hbox</code>es, and their typeset
representation is awful.
<p/>There are three packages that help solve this problem:
<ul>
<li> The <i>path</i> package, which defines a <code>\</code><code>path</code> command.
  The command defines each potential break character as a
  <code>\</code><code>discretionary</code>, 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

  <a href="FAQ-eplain.html">Eplain macros</a> &mdash; define a similar <code>\</code><code>path</code> command.
<p/>  <i>Path</i>, 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.
<li> The <i>url</i> package, which defines an <code>\</code><code>url</code> command
  (among others, including its own <code>\</code><code>path</code> command).  The command
  gives each potential break character a maths-mode &lsquo;personality&rsquo;, and
  then sets the URL itself (in the user&rsquo;s choice of font) in
  maths mode.  It can produce (LaTeX-style) &lsquo;robust&rsquo; commands
  
  (see <a href="FAQ-protect.html">use of <code>\</code><code>protect</code></a>) 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.
<p/>  It is possible to use the <i>url</i> package in Plain TeX,
  with the assistance of the <i>miniltx</i> 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:

<pre>
\input miniltx
\expandafter\def\expandafter\+\expandafter{\+}
\input url.sty
</pre>
<li> The <i>hyperref</i> package, which uses the typesetting code
  of <i>url</i>, in a context where the typeset text forms the
  anchor of a link.
</ul>
<p/>The author of this answer prefers the (rather newer) <i>url</i>
package (directly or indirectly); both <i>path</i> and
<i>url</i> work well with Plain TeX (though of course, the fancy
LaTeX facilities of <i>url</i> don&rsquo;t have much place there).
(<i>hyperref</i> isn&rsquo;t available in a version for use with Plain TeX.)
<p/>Note that neither <code>\</code><code>path</code> (from package <i>path</i>) nor <code>\</code><code>url</code> (from
package <i>url</i>) is robust (in the LaTeX sense).  If you need
a URL to go in a moving argument, you need the command
<code>\</code><code>urldef</code> from the <i>url</i> package.  So one might write:
<blockquote>
<pre>
\urldef\faqhome\url{http://www.tex.ac.uk/faq}
</pre>
</blockquote><p>
after which, <code>\</code><code>faqhome</code> is robust.
<p/>Documentation of both package <i>path</i> and package <i>url</i>
is in the package files.
<dl>
<dt><tt><i>hyperref.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/hyperref.zip">macros/latex/contrib/hyperref</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/hyperref.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/hyperref/">browse</a>)
<dt><tt><i>miniltx.tex</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/plain/graphics.zip">macros/plain/graphics</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/plain/graphics.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/plain/graphics/">browse</a>)
<dt><tt><i>path.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/misc/path.sty">macros/latex/contrib/misc/path.sty</a>
<dt><tt><i>url.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/misc/url.sty">macros/latex/contrib/misc/url.sty</a>
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=setURL">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=setURL</a>
</body>