% % url.sty % % James Kittock and Nir Friedman, Stanford University % January 4, 1995 % % PURPOSE % % This file creates a simple TeX macro, \url{}, which % serves to format World Wide Web URLs in a reasonably % nice way. % % OPERATION % % This macro automatically puts the argument of the % \url command into typewriter font and lets TeX know % that it can break the lines after slashes ('/') but % not between slashes. Thus, given the command % % this is the URL: \url{http://foo.bar.com/directory/file.txt} % % TeX might produce output formatted as % % this is the URL: http:// % foo.bar.com/directory/file.txt % % but it would NOT produce output formatted as % % this is the URL: http:/ % /foo.bar.com/directory/file.txt % % NOTES % % 1. This macro has been tested with LaTeX and LaTeX2e % in compatibility mode; it has not been tested with % LaTeX2e in native mode. % % 2. Because of the way the macro is written, any % control sequences in the argument to the \url{} % command must be enclosed in brackets. Even then, % strange interactions may result. A known bug % involves underscores ('_') in the argument: % % \url{http://foo.com/this{\_}is{\_}the{\_}file} % % does not work properly; instead it must be written as % % \url{http://foo.com/this{\char`_}is{\char`_}the{\char`_}file} % % 3. The current version of the macro puts no character % at the end of a wrapped URL. If, for example, you % wanted wrapped URLs to be hyphenated, you could % modify the macro by replacing % % \discretionary{}{}{} % % with % % \discretionary{-}{}{} % % CONTACT % % If you have improvements or bug fixes to this macro, % please send them to jek@cs.stanford.edu. We will % also accept bug reports, but we make no promises % about ever fixing the bugs. % \typeout{Document Style `url' <04 Jan 95>.} \def\url#1{{\tt \count0=0 \urlh#1\end }} \def\urlh#1{\ifx#1\end\let\next=\relax\else\let\next=\urlh\urlhh#1\fi\next} \def\urlhh#1{\if#1/\count0=1 #1\else\ifnum\count0=1 \discretionary{}{}{}\count0=0 \fi#1\fi}