aboutsummaryrefslogtreecommitdiff
path: root/rf.1
blob: fbf429fecee2ebd553a84910d73288f19bb960a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
.Dd $Mdocdate$
.Dt rf 1
.Os
.
.Sh NAME
.Nm rf
.Nd alternative reference system for (t)roff
.
.Sh SYNOPSIS
.Nm
.Ar file
.
.Sh DESCIPTION
.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 in the troff document itself, usually at the end.
.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
is around 150 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 more simple and offers much more basic functionality than
.Xr refer 1 .
This means that you can learn all of it in five minutes.
.El
.Pp
The performance of
.Nm
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:
.Bl -column "EntriesXXXX" "TimeX" -offset indent
.It Em "Entries\ \ \ \ " Ta Em Time
.It    3          Ta    0.03s
.It    50         Ta    0.09s
.It    107        Ta    0.15s
.It    182        Ta    0.24s
.El
.Pp
I would deem it rare to have more than a couple of hundred unique references in a troff document.
.
.Sh USAGE
.Nm
is controlled by several macros, all consisting of one uppercase and one lowercase letter, beginning with either an
.Sq F
(format macros)
or an
.Sq R
(inline reference and reference list macros).
These are listed below in alphabetical order.
.Ss Format macros
.Bl -tag
.It Sy \&Ff
Defines the format for
.Dq full
inline references, which usually contain both author and year.
.Pp
Default: (%a %y)
.It Sy \&Fl
Defines the format for the reference list, which is usually located at the end of the document.
.Pp
Default: %a (%y). {\\fI%t\\fR}. {\\*Q%q\\*U}. %n, %d. %c: %p. {Available: %w.}
.It Sy \&Fx
Defines the format for
.Dq alternate
inline references, which usually contain only the year.
.Pp
Default: (%y)
.El
.Pp
For a description of the format syntax, see
.Sx FORMAT SYNTAX .
.
.Ss Inline reference macros
.Bl -tag
.It Sy \&Rf
Inserts a
.Dq full
inline reference, which usually contains both author and year.
.It Sy \&Rx
Inserts an
.Dq alternate
inline reference, which usually contains only the year.
.El
.Pp
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.
.Pp
To include some punctuation character immediately after the inline reference, add a space before it:
.Bd -literal -offset indent
\&.Rf Johnson 92 .
.Ed
.Pp
To wrap the inline reference in parentheses, use the following syntax:
.Bd -literal -offset indent
\&.Rf Johnson 92 ) (
.Ed
.Pp
Additionally, 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 Johnson
\&.Rx '' 92 ,
there has been a gradual change in attitudes towards ...
.Ed
.
.Ss Reference list macros
.Bl -tag
.It Sy \&Ra
Adds to the list of
.Em authors
of the current reference.
Additionally,
.Sy \&Ra
marks the beginning of a new reference.
.Pp
Format: Surname(s), Forename(s)
.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.
.Ìt 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 entry in place of its definition.
.Nm
does not change the order of reference entries.
This means that you can arrange your references freely.
.Sh FORMAT SYNTAX
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:
.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
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:
.Bd -literal -offset indent
\&.Fx\\ \\**\\
\&.FS\\
%A, {\\fI%t\\fR}, {\\*Q%q\\*U}, %y.\\
\&.FE 
.Ed
.Pp
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
.Nm .
.Pp
Note that all fields are inserted literally, with one exception:
when
.Em %a
is used in an inline reference format, the forenames of the authors are automatically removed.
To include the forenames, use
.Em %A
instead.
.Pp
Finally, 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.
.
.Sh EXAMPLE
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 London
\&.Rp Another Press

\&.XP
\&.Ra Smith, P.
\&.Ry 2007
\&.Rt Modern Society
\&.Rc New York
\&.Rp Some Press
.Ed
.Pp
When given the above file,
.Nm
will output the following 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. London: Another Press.

\&.XP
Smith, P. (2007). \\fIModern Society\\fR. New York: Some Press.
.Ed
.
.Sh AUTHORS
.Nm
was written by John Ankarström
.Aq Mt john (at) ankarstrom.se .