NAME
rf
—
alternative reference system for
(t)roff
SYNOPSIS
rf |
file |
DESCIPTION
rf
is a reference system for troff and
other roff derivatives. It differs from refer(1), the traditional troff reference system, in a couple
important ways:
- References are not stored in a separate file. They are defined via macros
at the end of the troff document itself.
This means that you can move, copy and share your troff document without needing to worry about an additional reference file. Furthermore, you never run the risk of accidentally losing the references attached to a document.
rf
consists of circa 200 lines of Perl. If you find a bug or an (in your opinion) undesirable behavior inrf
, you can easily patch it.- Finally,
rf
is much simpler, much less opaque and offers much more basic functionality than refer(1). You can learn all of it in five minutes.
The performance of rf
primarily depends on
the number of references (but not citations). On my HP Compaq dc5700 from
2007, the relationship between number of references and total execution time
is roughly the following:
Entries | Time |
3 | 0.01s |
50 | 0.07s |
100 | 0.14s |
200 | 0.26s |
500 | 0.65s |
2,000 | 2.59s |
10,000 | 12.94s |
Luckily, I would deem it extremely rare to have more than a couple of hundred unique references in a troff document.
USAGE
rf
provides two features, which it calls
references
and
citations:
- reference
- a bibliographic entry written at the end of the document
- citation
- an inline reference to a bibliographic entry
rf
is controlled by several macros, all
consisting of one uppercase and one lowercase letter, beginning with either
an ‘R’ – macros controlling references and citations
– or an ‘F’ – macros controlling the appearance
of references and citations.
Format macros
These macros control control the appearance of references and citations.
- Fr
- Defines the format for references in the bibliography.
Default: %a {(%y)}. {\fI%t\fR}. {\*Q%q\*U}. %n, %d. %c: %p. {Available: %w}
- Ff
- Defines the format for “full” citations, which by default
contain both author and year.
Default: (%A %y)
- Fx
- Defines the format for “alternate” citations, which by
default contain only the year.
Default: (%y)
For a description of the format syntax, see FORMAT SYNTAX.
Reference definition macros
In the reference list or bibliography, a single reference is defined by a contiguous block of lines containing any of the macros described below. The definition of one reference is separated from that of another by any other lines, including text lines, empty lines and lines containing other macros than the ones listed below.
- Ra
- Defines the
author
of the publication. You can use Ra more than once in
order to define multiple authors.
Format: Surname, Forename/Initial
- Rc
- Defines the city of publication.
- Rd
- Defines the (detailed) date of publication, not as a substitute for Ry, but as a further specification. For example, the day and month a newspaper article was published.
- Rn
- Defines the newspaper in which an article was published.
- Rp
- Defines the publisher of a book.
- Rq
- Defines the (quoted) title of an article.
- Rt
- Defines the title of a book.
- Rw
- Defines the (web) address of an online resource.
- Ry
- Defines the year of publication.
In the final output, rf
prints a formatted
version of each reference in place of its definition.
rf
does not change the order of reference. This
means that you can arrange your references freely.
Citation macros
To insert a citation, you can use one of two macros:
- Rf
- Inserts a “full” citation, which usually contains both author and year.
- Rx
- Inserts an “alternate” citation, which usually contains only the year.
Reference identification. After the macro name, you should provide one or more keywords to identify the reference to which the citation is to refer. Each word is matched case-insensitively against the author, year and title of all references. For example:
.Rf Trubetzkoy 1969
If only a weak match is found, a helpful warning is printed on standard error.
Adjacent punctuation. To include some punctuation character immediately after the inline reference, use the following syntax:
.Rf Grot 1873 .
To wrap the inline reference in parentheses, use the following syntax:
.Rf Courtenay 1972 ) (
Shortcuts.
Any instance of ''
is replaced with the last
word on the preceding line. This allows the following shortcut:
According to Brandt .Rx '' 1892 , Russian differs from other European languages in its [...]
FORMAT SYNTAX
Interpolation
In a format specification, use a percent (%) sigil followed by a single letter to interpolate any given field of the reference. The letter following the percent sign corresponds to the second letter of the reference list macros described above. For example:
.Ff (%A, %y) \" (Author, Year)
By wrapping an interpolation in braces, you can specify a prefix and/or suffix that should be included only if the interpolation is successful. For example:
.Ff (%A{, %y}). \" Here, ', ' is removed if there is no year.
To interpolate only the surnames of the authors, you can use the special %A syntax, with an uppercase instead of lowercase ‘a’.
Multiple lines
If no argument is given to a format macro, then
rf
will read the format specification from the
following lines until a line containing ‘..’ is encountered,
signifying the end of the multi-line format specification.
Within a multi-line format spefication, use the escapes \$2 and \$3 to interpolate (respectively) any suffix and prefix given to the citation macro.
For example, the following multi-line format specification implements footnote references:
.Fx \$3\**\$2 .FS %a, {\fI%t\fR}, {\*Q%q\*U}, %y. .FE ..
Automatic cleanup
You usually don't need to worry about excessive spaces and stray
punctuation marks. rf
removes common punctuation
immediately preceding and following an unsuccessful interpolation. Excessive
spaces are also removed, unless they follow a period, marking the end of a
sentence.
EXAMPLE
Below is an example of an ms-based troff document using
rf
references.
.de noop .. .blm noop .SH Previous work .LP Davidson .Rx '' 1991 has performed a study [...] .PP [...] which leads to a higher total cholesterol level .Rf Smith 2007 . .SH Literature .XP .Ra Davidson, H. .Ry 1991 .Rt Seminal Work .Rc Athens .Rp Logos .XP .Ra Smith, P. .Ry 2007 .Rt Modern Society .Rc Athens .Rp Logos
When given the above file, rf
will output
the following source code:
.de noop .. .blm noop .SH Previous work .LP Davidson (1991) has performed a study [...] .PP [...] which leads to a higher total cholesterol level (Smith 2007). .SH Literature .XP Davidson, H. (1991). \fISeminal Work\fR. Athens: Logos. .XP Smith, P. (2007). \fIModern Society\fR. Athens: Logos.
AUTHORS
rf
was written by John Ankarström
<john
(at)
ankarstrom.se>.