5.12.1 Leaders

Sometimes it is desirable to fill a tab stop with a given glyph, but also use tab stops normally on the same output line. An example is a table of contents entry that uses dots to bridge the entry name with its page number, which is itself aligned within a tab stop. The roff language provides leaders for this purpose.58

A leader character (ISO and EBCDIC code point 1, also known as SOH or “start of heading”), behaves similarly to a tab character: it moves to the next tab stop. The difference is that for this movement, the default fill glyph is a period ‘.’.

Escape sequence: \a

Interpolate a leader in copy mode; see Copy Mode.

Request: .lc [fill-glyph]

When writing a leader, GNU troff fills the space to the next tab stop with dots ‘.’. A different leader repetition character can be specified with the lc request, causing GNU troff to write as many instances of fill-glyph as are necessary to occupy the interval from the current horizontal location to the next tab stop. With no argument, GNU troff treats leaders the same as tabs. The leader repetition character is associated with the environment (see Environments).59 Only a single fill-glyph is recognized; any excess is ignored.

A table of contents, for example, may define tab stops after a section number, a title, and a gap to be filled with leader dots. The page number follows the leader, after a right-aligned final tab stop wide enough to house the largest page number occurring in the document.

.ds entry1 19.\tThe Prophet\a\t98
.ds entry2 20.\tAll Astir\a\t101
.ta .5i 4.5i +.5iR
.nf
\*[entry1]
\*[entry2]
    ⇒ 19.  The Prophet.............................   98
    ⇒ 20.  All Astir...............................  101