rf(1) | General Commands Manual | rf(1) |
rf
—
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:
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
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.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’ (format macros) or an ‘R’ (inline reference
and reference list macros). These are listed below in alphabetical order.
Default: (%a %y)
Default: %a (%y). {\fI%t\fR}. {\*Q%q\*U}. %n, %d. %c: %p. {Available: %w.}
Default: (%y)
For a description of the format syntax, see FORMAT SYNTAX.
What reference to refer to is specified by the rest of the line. 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 ...
Format: Surname(s), Forename(s)
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.
.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.
You can include a newline in your format by ending the line with a backslash and continuing on the next line. If you add a backslash immediately following the macro name, the interpolated format will be joined to the preceding line. 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
As you can see above, you can use troff requests and other macros
in your format. This will expand to a valid request/macro in the output of
rf
.
Note that all fields are inserted literally, with one exception: when %a is used in an inline reference format, the forenames of the authors are automatically removed. To include the forenames, use %A instead.
Finally, 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.
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 London .Rp Another Press .XP .Ra Smith, P. .Ry 2007 .Rt Modern Society .Rc New York .Rp Some Press
When given the above file, rf
will output
the following 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. London: Another Press. .XP Smith, P. (2007). \fIModern Society\fR. New York: Some Press.
rf
was written by John Ankarström
<john
(at)
ankarstrom.se>.
November 11, 2020 | Linux 5.4.72-0-lts |