.Dd $Mdocdate$ .Dt rf 1 .Os . .Sh NAME .Nm rf .Nd alternative reference system for (t)roff . .Sh SYNOPSIS .Nm .Ar file . .Sh DESCIPTION .Pp .Nm is a reference system for troff and other roff derivatives. It differs from .Xr refer 1 , the traditional troff reference system, in a couple important ways: .Bl -enum .It References are not stored in a separate file. They are defined via macros at the end of the troff document itself. .Pp 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. .It .Nm consists of circa 200 lines of Perl. If you find a bug or an (in your opinion) undesirable behavior in .Nm , you can easily patch it. .It Finally, .Nm is much simpler, much less opaque and offers much more basic functionality than .Xr refer 1 . You can learn all of it in five minutes. .El .Pp The performance of .Nm 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: .Bl -column "EntriesXXXX" "TimeX" -offset indent .It Em "Entries\ \ \ \ " Ta Em Time .It 3 Ta 0.01s .It 50 Ta 0.07s .It 100 Ta 0.14s .It 200 Ta 0.26s .It 500 Ta 0.65s .It 2,000 Ta 2.59s .It 10,000 Ta 12.94s .El .Pp Luckily, I would deem it extremely rare to have more than a couple of hundred unique references in a troff document. . .Sh USAGE .Pp .Nm provides two features, which it calls .Em references and .Em citations : .Bl -tag .It Em reference a bibliographic entry written at the end of the document .It Em citation an inline reference to a bibliographic entry .El .Pp .Nm is controlled by several macros, all consisting of one uppercase and one lowercase letter, beginning with either an .Sq R \(en macros controlling references and citations \(en or an .Sq F \(en macros controlling the appearance of references and citations. . .Ss Format macros These macros control control the appearance of references and citations. .Bl -tag .It Sy \&Fr Defines the format for references in the bibliography. .Pp Default: %a {(%y)}. {\\fI%t\\fR}. {\\*Q%q\\*U}. %n, %d. %c: %p. {Available: %w} .It Sy \&Ff Defines the format for .Dq full citations, which by default contain both author and year. .Pp Default: (%A %y) .It Sy \&Fx Defines the format for .Dq alternate citations, which by default contain only the year. .Pp Default: (%y) .El .Pp For a description of the format syntax, see .Sx FORMAT SYNTAX . . .Ss Reference definition macros In the reference list or bibliography, a single reference is defined by a .Sy 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, .Sy including text lines, empty lines and lines containing other macros than the ones listed below. .Bl -tag .It Sy \&Ra Defines the .Em author of the publication. You can use .Sy \&Ra more than once in order to define multiple authors. .Pp Format: Surname, Forename/Initial .It Sy \&Rc Defines the .Em city of publication. .It Sy \&Rd Defines the (detailed) .Em date of publication, not as a substitute for .Sy \&Ry , but as a further specification. For example, the day and month a newspaper article was published. .It Sy \&Rn Defines the .Em newspaper in which an article was published. .It Sy \&Rp Defines the .Em publisher of a book. .It Sy \&Rq Defines the (quoted) .Em title of an article. .It Sy \&Rt Defines the .Em title of a book. .It Sy \&Rw Defines the (web) .Em address of an online resource. .It Sy \&Ry Defines the .Em year of publication. .El .Pp In the final output, .Nm prints a formatted version of each reference in place of its definition. .Nm does not change the order of reference. This means that you can arrange your references freely. . .Ss Citation macros To insert a citation, you can use one of two macros: .Bl -tag .It Sy \&Rf Inserts a .Dq full citation, which usually contains both author and year. .It Sy \&Rx Inserts an .Dq alternate citation, which usually contains only the year. .El . .Pp .Sy 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: .Bd -literal -offset indent \&.Rf Trubetzkoy 1969 .Ed .Pp If only a weak match is found, a helpful warning is printed on standard error. .Pp .Sy Adjacent punctuation. \ To include some punctuation character immediately after the inline reference, use the following syntax: .Bd -literal -offset indent \&.Rf Grot 1873 . .Ed .Pp To wrap the inline reference in parentheses, use the following syntax: .Bd -literal -offset indent \&.Rf Courtenay 1972 ) ( .Ed . .Pp .Sy Shortcuts. \ Any instance of .Li '' is replaced with the last word on the preceding line. This allows the following shortcut: .Bd -literal -offset indent According to Brandt \&.Rx '' 1892 , Russian differs from other European languages in its [...] .Ed . .Sh FORMAT SYNTAX .Pp .Ss 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: .Bd -literal -offset indent \&.Ff (%A, %y) \\" (Author, Year) .Ed .Pp 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: .Bd -literal -offset indent \&.Ff (%A{, %y}). \\" Here, ', ' is removed if there is no year. .Ed .Pp To interpolate only the .Sy surnames of the authors, you can use the special .Em %A syntax, with an uppercase instead of lowercase .Sq a . . .Ss Multiple lines If no argument is given to a format macro, then .Nm will read the format specification from the following lines until a line containing .Sq .. is encountered, signifying the end of the multi-line format specification. .Pp Within a multi-line format spefication, use the escapes \\$2 and \\$3 to interpolate (respectively) any suffix and prefix given to the citation macro. .Pp For example, the following multi-line format specification implements footnote references: .Bd -literal -offset indent \&.Fx \\$3\\**\\$2 \&.FS %a, {\\fI%t\\fR}, {\\*Q%q\\*U}, %y. \&.FE \&.. .Ed . .Ss Automatic cleanup .Pp You usually don't need to worry about excessive spaces and stray punctuation marks. .Nm 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. . .Sh EXAMPLE .Pp Below is an example of an ms-based troff document using .Nm rf references. .Bd -literal -offset indent \&.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 .Ed .Pp When given the above file, .Nm will output the following source code: .Bd -literal -offset indent \&.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. .Ed . .Sh AUTHORS .Pp .Nm was written by John Ankarström .Aq Mt john (at) ankarstrom.se .