Defining styles
Before describing how to customize the printing style, it is best to
mention something about the unusual implementation of \csurl. Although
the material is textual in nature, and the font specification required
is a text-font command, the text is actually typeset in math mode.
This allows the context-sensitive linebreaking, but also accounts for
the default behavior of ignoring spaces. (Maybe that underlying design
will eventually change.) Now on to defining styles.
To change the font or the list of characters that allow linebreaks, you
could redefine the commands \csUrlFont, \csUrlBreaks,
\csUrlSpecials, etc., directly in the document, but it is better to
define a new ‘url-style’ (following the example of \csurl@ttstyle
and \csurl@rmstyle) which defines all of \csUrlBigbreaks,
\csUrlNoBreaks, \csUrlBreaks, \csUrlSpecials, and \csUrlFont.
Changing font
The \csUrlFont command selects the font. The definition of
\csUrlFont done by the pre-defined styles varies to cope with a
variety of LaTeX font selection schemes, but it could be as simple
as . Depending on the font selected, some
characters may need to be defined in the \csUrlSpecials list because
many fonts don’t contain all the standard input characters.
Changing linebreaks
The list of characters after which line-breaks are permitted is
given by the two commands (list macros)
\csUrlBreaks and \csUrlBigBreaks. They consist of repeating
\csdo\csc for each relevant character c.
The differences are that ‘BigBreaks’ typically have a lower penalty (more
easily chosen) and do not break within a repeating sequence (e.g.,
“DEC::NODE”).
(For gurus: ‘BigBreaks’ are treated as mathrels while ‘Breaks’ are mathbins;
see The TeXbook , p. 170.) The result is that a series of
consecutive ‘BigBreak’
characters will break at the end and only at the end; a series of
‘Break’ characters will break after the first and after every following
pair ; there will be no break between a ‘Break’ character and a
following ‘BigBreak’ char; breaks are permitted when a ‘BigBreak’
character is followed by ‘Break’ or any other char. In the case
of http:// it doesn’t matter whether : is a
‘Break’ or ‘BigBreak’ — the breaks are the same in either case; but
for (now ancient) DECnet addresses using :: it was
important to prevent breaks between the colons, and that is why
colons are ‘BigBreaks’. (The only other ‘BigBreak’ character is,
optionally, the hyphen; slashes are regular ‘Break’s.)
It is possible for characters to prevent breaks after the next
following character (this is used for parentheses). Specify these in
\csUrlNoBreaks.
You can allow some spacing around the breakable characters by assigning
\Urlmuskip = 0mu plus 1mu
(with mu units because of math mode).
You can change the penalties used for BigBreaks and Breaks by assigning
\mathchardef\UrlBreakPenalty=100
\mathchardef\UrlBigBreakPenalty=100
The default penalties are \csbinoppenalty and \csrelpenalty.
These have such odd non-LaTeX syntax because I don’t expect people
to need to change them often. (The \mathchardef does not relate to
math mode; it is only a way to store a number without consuming registers.)
Arbitrary character actions
You can do arbitrarily complex things with characters by specifying
their definition(s) in \csUrlSpecials. This makes them ‘active’ in
math mode (mathcode "8000). The format for setting
each special character c is:
\do\c{\metadefinition}, but other definitions not
following this style can also be included.
Here is an example to make “!” inside \csurl force a line break
instead of being treated verbatim (it uses LaTeX’s \csg@addto@macro):
\makeatletter \g@addto@macro\UrlSpecials{\do\!{\newline}}
Here is another overly-complicated example to put extra flexible
muglue around each “/” character, except when followed
by another “/”, as in “http://”, where extra
spacing looks poor.
\newmuskip\Urlslashmuskip
\Urlslashmuskip=2mu plus2mu minus2mu
\g@addto@macro\UrlSpecials{\do\/{\Urlspaceyslash}}
If this sounds confusing … well, it is! But I hope you
won’t need to redefine breakpoints — the default assignments seem to
work well for a wide variety of applications. If you do need to make
changes, you can test for breakpoints using regular math mode and the
characters “+=(a”.