rf(1) General Commands Manual rf(1)

rf
alternative reference system for (t)roff

rf file

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:
  1. 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.

  2. rf is around 150 lines of Perl. If you find a bug or an (in your opinion) undesirable behavior in rf, you can easily patch it.
  3. Finally, rf is much more simple and offers much more basic functionality than refer(1). This means that you can learn all of it in five minutes.

The performance of rf primarily depends on the number of entries in the reference list at the end of the document. On my HP Compaq dc5700 from 2007, the relationship between number of entries in the reference list and total execution time is roughly the following:

Entries     Time
3 0.03s
50 0.09s
107 0.15s
182 0.24s

I would deem it rare to have more than a couple of hundred unique references in a troff document.

rf is controlled by several macros, all consisting of one uppercase and one lowercase letter, beginning with either an ‘F’ or an ‘R’. Macros beginning with ‘R’ control the two primary “units” of rf:
  1. entries in the reference list, and
  2. inline references to these entries.

Macros beginning with ‘F’, in turn, control the appearance of these two units.

You can control the appearance of your references as they are displayed in-line as well as in the final reference list by using the format macros.
Fe
Defines the format for reference list entries.

Default: %a (%y). {\fI%t\fR}. {\*Q%q\*U}. %n, %d. %c: %p. {Available: %w.}

Ff
Defines the format for “full” inline references, which by default contain both author and year.

Default: (%A %y)

Fx
Defines the format for “alternate” inline references, which by default contain only the year.

Default: (%y)

For a description of the format syntax, see FORMAT SYNTAX.

In the reference list, each entry is defined by a contiguous block of lines containing definition macros, describing various fields belonging to the reference, such as author and year. The definition of one reference is separated from that of another by any other lines, including text lines and empty lines.
Ra
Adds to the list of authors of the current reference.

Format: Surname(s), Forename(s)

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 entry in place of its definition. rf does not change the order of reference entries. This means that you can arrange your references freely.

To insert an inline reference to an entry in the reference list, you can use one of two macros:
Rf
Inserts a “full” inline reference, which usually contains both author and year.
Rx
Inserts an “alternate” inline reference, which usually contains only the year.

What reference to refer to is specified by the rest of the line. Each word of it is matched against the author, year and title of all references to find a match. If only a weak match is found, a warning is printed on standard error.

To include some punctuation character immediately after the inline reference, add a space before it:

.Rf Johnson 92 .

To wrap the inline reference in parentheses, use the following syntax:

.Rf Johnson 92 ) (

Additionally, any instance of '' is replaced with the last word on the preceding line. This allows the following shortcut:

According to Johnson
.Rx '' 92 ,
there has been a gradual change in attitudes towards ...

In a format definition, 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’.

  1. A backslash at the end of a format line acts as a line continuation marker. The newline after the backslash is preserved.
  2. For format macros describing inline references, a backslash immediately following the macro name will cause the reference be joined to the preceding line.

Anywhere else in the line, backslashes are preserved literally.

By using backslashes, you can implement footnote-based references. For example, using the ms macro package:

.Fx\ \**\
.FS\
%a, {\fI%t\fR}, {\*Q%q\*U}, %y.\
.FE

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.

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.

rf was written by John Ankarström <john (at) ankarstrom.se>.
November 11, 2020 Linux 5.4.72-0-lts