refer(1)
π refer(1) β General Commands Manual π
πΈ Name πΈ
refer β process bibliographic references for groff
β¨ Synopsis β¨
Hereβs the whole command shape, bestie:
refer [-bCenPRS] [-a n] [-B field.macro] [-c fields] [-f n] [-i fields]
[-k field] [-l range-expression] [-p database-file] [-s fields]
[-t n] [file ...]
refer --help
refer -v
refer --version
π Description π
Okay so, refer is the GNU implementation, and itβs part of the groff(1) document formatting system. Itβs a troff(1) preprocessor that gets your bibliographic citations ready by looking up keywords you specify in a roff(7) input document β which means you donβt have to type all those annotations yourself, and the citation style in the formatted output can be changed independently and systematically. π It copies the contents of each file to the standard output stream, except that it interprets lines between .[ and .] as citations to be translated into groff input, and lines between .R1 and .R2 as instructions about how citations are to be processed. Normally, refer is not executed directly by you; groff(1) invokes it by specifying the -R option to groff. If no file operands are given on the command line, or if file is -, the standard input stream is read. π«Ά
Each citation specifies a reference. The citation can specify a reference that is contained in a bibliographic database by giving a set of keywords that only that reference contains. Alternatively, it can specify a reference by supplying a database record in the citation. A combination of these alternatives is also possible. β¨
For each citation, refer can produce a mark in the text. This mark consists of some label that can be separated from the text and from other labels in various ways. For each reference it also outputs groff(7) language commands that can be used by a macro package to produce a formatted reference for each citation. The output of refer must therefore be processed using a suitable macro package, such as me, mm, mom, or ms. The commands to format a citationβs reference can be output immediately after the citation, or the references may be accumulated and the commands output at some later point. If the references are accumulated, then multiple citations of the same reference will produce a single formatted reference. No cap. π
The interpretation of lines between .R1 and .R2 as preprocessor commands is a feature of GNU refer. Documents making use of this feature can still be processed by AT&T refer just by adding the lines
.de R1
.ig R2
..
to the beginning of the document. This will cause troff(1) to ignore everything between .R1 and .R2. The effect of some commands can also be achieved by options. These options are supported mainly for compatibility with AT&T refer. It is usually more convenient to use commands. π
refer generates .lf requests so that file names and line numbers in messages produced by commands that read refer output will be correct; it also interprets lines beginning with .lf so that file names and line numbers in the messages and .lf lines that it produces will be accurate even if the input has been preprocessed by a command such as soelim(1). π
π Bibliographic databases π
The bibliographic database is a text file consisting of records separated by one or more blank lines. Within each record, fields start with a % at the beginning of a line. Each field has a one-character name that immediately follows the %. It is best to use only upper and lower case letters for the names of fields. The name of the field should be followed by exactly one space, and then by the contents of the field. Empty fields are ignored. The conventional meaning of each field is as follows:
%Aβ The name of an author. If the name contains a suffix such as βJr.β, it should be separated from the last name by a comma. There can be multiple occurrences of the%Afield. The order is significant. It is a good idea always to supply an%Afield or a%Qfield.%Bβ For an article that is part of a book, the title of the book.%Cβ The place (city) of publication.%Dβ The date of publication. The year should be specified in full. If the month is specified, the name rather than the number of the month should be used, but only the first three letters are required. It is a good idea always to supply a%Dfield; if the date is unknown, a value such as in press or unknown can be used.%Eβ For an article that is part of a book, the name of an editor of the book. Where the work has editors and no authors, the names of the editors should be given as%Afields and β, (ed.)β or β, (eds.)β should be appended to the last author.%Gβ U.S. government ordering number.%Iβ The publisher (issuer).%Jβ For an article in a journal, the name of the journal.%Kβ Keywords to be used for searching.%Lβ Label.%Nβ Journal issue number.%Oβ Other information. This is usually printed at the end of the reference.%Pβ Page number. A range of pages can be specified asm-n.%Qβ The name of the author, if the author is not a person. This will only be used if there are no%Afields. There can only be one%Qfield.%Rβ Technical report number.%Sβ Series name.%Tβ Title. For an article in a book or journal, this should be the title of the article.%Vβ Volume number of the journal or book.%Xβ Annotation.
For all fields except %A and %E, if there is more than one occurrence of a particular field in a record, only the last such field will be used. π
If accent strings are used, they should follow the character to be accented. This means that an ms document must call the .AM macro when it initializes. Accent strings should not be quoted: use one \ rather than two. Accent strings are an obsolescent feature of the me and ms macro packages; modern documents should use groff special character escape sequences instead; see groff_char(7). π¦
π Citations π
Citations have a characteristic format:
.[opening-text
flags keywords
fields
.]closing-text
The opening-text, closing-text, and flags components are optional. Only one of the keywords and fields components need be specified.
The keywords component says to search the bibliographic databases for a reference that contains all the words in keywords. It is an error if more than one reference is found. π
The fields component specifies additional fields to replace or supplement those specified in the reference. When references are being accumulated and the keywords component is non-empty, then additional fields should be specified only on the first occasion that a particular reference is cited, and will apply to all citations of that reference. π
The opening-text and closing-text components specify strings to be used to bracket the label instead of those in the bracket-label command. If either of these components is non-empty, the strings specified in the bracket-label command will not be used; this behavior can be altered using the [ and ] flags. Leading and trailing spaces are significant for these components. β¨
The flags component is a list of non-alphanumeric characters, each of which modifies the treatment of this particular citation. AT&T refer will treat these flags as part of the keywords and so will ignore them since they are non-alphanumeric. The following flags are currently recognized.
#β Use the label specified by theshort-labelcommand, instead of that specified by thelabelcommand. If no short label has been specified, the normal label will be used. Typically the short label is used with author-date labels and consists of only the date and possibly a disambiguating letter; the β#β is supposed to be suggestive of a numeric type of label.[β Precede opening-text with the first string specified in thebracket-labelcommand.]β Follow closing-text with the second string specified in thebracket-labelcommand.
An advantage of using the [ and ] flags rather than including the brackets in opening-text and closing-text is that you can change the style of bracket used in the document just by changing the bracket-label command. Another is that sorting and merging of citations will not necessarily be inhibited if the flags are used. π₯
If a label is to be inserted into the text, it will be attached to the line preceding the .[ line. If there is no such line, then an extra line will be inserted before the .[ line and a warning will be given. π
There is no special notation for making a citation to multiple references. Just use a sequence of citations, one for each reference. Donβt put anything between the citations. The labels for all the citations will be attached to the line preceding the first citation. The labels may also be sorted or merged. See the description of the <> label expression, and of the sort-adjacent-labels and abbreviate-label-ranges commands. A label will not be merged if its citation has a non-empty opening-text or closing-text. However, the labels for a citation using the ] flag and without any closing-text immediately followed by a citation using the [ flag and without any opening-text may be sorted and merged even though the first citationβs opening-text or the second citationβs closing-text is non-empty. (If you wish to prevent this, use the dummy character escape sequence \& as the first citationβs closing-text.) π
π Commands π
Commands are contained between lines starting with .R1 and .R2. Recognition of these lines can be prevented by the -R option. When a .R1 line is recognized, any accumulated references are flushed out. Neither .R1 nor .R2 lines, nor anything between them, is output. π«Ά
Commands are separated by newlines or semicolons. A number sign (#) introduces a comment that extends to the end of the line, but does not conceal the newline. Each command is broken up into words. Words are separated by spaces or tabs. A word that begins with a (neutral) double quote (") extends to the next double quote that is not followed by another double quote. If there is no such double quote, the word extends to the end of the line. Pairs of double quotes in a word beginning with a double quote collapse to one double quote. Neither a number sign nor a semicolon is recognized inside double quotes. A line can be continued by ending it with a backslash (\); this works everywhere except after a number sign. π
okay so hereβs the group-chat recap of the command rules, bestie: each command name that is marked with * has an associated negative command no-name that undoes the effect of name. For example, the no-sort command specifies that references should not be sorted. The negative commands take no arguments β theyβre literally just the vibe-reversal button. π
Also, in the following description each argument must be a single word. Hereβs the decoder ring: field is used for a single upper or lower case letter naming a field; fields is used for a sequence of such letters; m and n are used for non-negative numbers; string is used for an arbitrary string; file is used for the name of a file. Slay, letβs go. β¨
abbreviate*fieldsstring1string2string3string4β abbreviate the first names offields. An initial letter will be separated from another initial letter bystring1, from the last name bystring2, and from anything else (such as βvonβ or βdeβ) bystring3. These default to a period followed by a space. In a hyphenated first name, the initial of the first part of the name will be separated from the hyphen bystring4; this defaults to a period. No attempt is made to handle any ambiguities that might result from abbreviation. Names are abbreviated before sorting and before label construction. πabbreviate-label-ranges*stringβ three or more adjacent labels that refer to consecutive references will be abbreviated to a label consisting of the first label, followed bystring, followed by the last label. This is mainly useful with numeric labels. Ifstringis omitted, it defaults to β-β. π¦accumulate*β accumulate references instead of writing out each reference as it is encountered. Accumulated references will be written out whenever a reference of the form
.[
$LIST$
.]
is encountered, after all input files have been processed, and whenever a .R1 line is recognized. π
annotate*fieldstringβfieldis an annotation; print it at the end of the reference as a paragraph preceded by the line
.string
If string is omitted, it will default to AP; if field is also omitted it will default to X. Only one field can be an annotation. periodt. π
articlesstring ...β eachstringis a definite or indefinite article, and should be ignored at the beginning ofTfields when sorting. Initially, βaβ, βanβ, and βtheβ are recognized as articles. πΈbibliographyfile ...β write out all the references contained in each bibliographic databasefile. This command should come last in an.R1/.R2block. πbracket-labelstring1string2string3β in the text, bracket each label withstring1andstring2. An occurrence ofstring2immediately followed bystring1will be turned intostring3. The default behavior is as follows:
bracket-label \*([. \*(.] ", "
π«Ά
capitalizefieldsβ convertfieldsto caps and small caps. πcompatible*β recognize.R1and.R2even when followed by a character other than space or newline. π₯databasefile ...β search each bibliographic databasefile. For eachfile, if an indexfile.icreated byindxbib(1)exists, then it will be searched instead; each index can cover multiple databases. πdate-as-label*stringβstringis a label expression that specifies a string with which to replace theDfield after constructing the label. See subsection βLabel expressionsβ below for a description of label expressions. This command is useful if you do not want explicit labels in the reference list, but instead want to handle any necessary disambiguation by qualifying the date in some way. The label used in the text would typically be some combination of the author and date. In most cases you should also use theno-label-in-referencecommand. For example,
date-as-label D.+yD.y%a*D.-y
would attach a disambiguating letter to the year part of the D field in the reference. β
default-database*β the default database should be searched. This is the default behavior, so the negative version of this command is more useful.referdetermines whether the default database should be searched on the first occasion that it needs to do a search. Thus ano-default-databasecommand must be given before then, in order to be effective. π§discard*fieldsβ when the reference is read,fieldsshould be discarded; no string definitions forfieldswill be output. Initially,fieldsareXYZ. πet-al*stringmnβ control use of et al. in the evaluation of@expressions in label expressions. If the number of authors needed to make the author sequence unambiguous isuand the total number of authors istthen the lastt-uauthors will be replaced bystringprovided thatt-uis not less thanmandtis not less thann. The default behavior is as follows:
et-al " et al" 2 3
Note the absence of a dot from the end of the abbreviation, which is arguably not correct. (Et al[.] is short for et alli, as etc. is short for et cetera.) π
includefileβ includefileand interpret the contents as commands. πjoin-authorsstring1string2string3β join multiple authors together with strings. When there are exactly two authors, they will be joined withstring1. When there are more than two authors, all but the last two will be joined withstring2, and the last two authors will be joined withstring3. Ifstring3is omitted, it will default tostring1; ifstring2is also omitted it will also default tostring1. For example,
join-authors " and " ", " ", and "
will restore the default method for joining authors. π
label-in-reference*β when outputting the reference, define the string[Fto be the referenceβs label. This is the default behavior, so the negative version of this command is more useful. πlabel-in-text*β for each reference output a label in the text. The label will be separated from the surrounding text as described in thebracket-labelcommand. This is the default behavior, so the negative version of this command is more useful. πlabelstringβstringis a label expression describing how to label each reference. πseparate-label-second-partsstringβ when merging two-part labels, separate the second part of the second label from the first label withstring. See the description of the<>label expression. π¦move-punctuation*β in the text, move any punctuation at the end of line past the label. It is usually a good idea to give this command unless you are using superscripted numbers as labels. β¨reverse*stringβ reverse the fields whose names are instring. Each field name can be followed by a number which says how many such fields should be reversed. If no number is given for a field, all such fields will be reversed. πsearch-ignore*fieldsβ while searching for keys in databases for which no index exists, ignore the contents offields. Initially,fieldsXYZare ignored. π ββοΈsearch-truncate*nβ only require the firstncharacters of keys to be given. In effect when searching for a given key words in the database are truncated to the maximum ofnand the length of the key. Initially,nis6. πshort-label*stringβstringis a label expression that specifies an alternative (usually shorter) style of label. This is used when the#flag is given in the citation. When using author-date style labels, the identity of the author or authors is sometimes clear from the context, and so it may be desirable to omit the author or authors from the label. Theshort-labelcommand will typically be used to specify a label containing just a date and possibly a disambiguating letter. πsort*stringβ sort references according tostring. References will automatically be accumulated.stringshould be a list of field names, each followed by a number, indicating how many fields with the name should be used for sorting. β+β can be used to indicate that all the fields with the name should be used. Also.can be used to indicate the references should be sorted using the (tentative) label. (Subsection βLabel expressionsβ below describes the concept of a tentative label.) π₯sort-adjacent-labels*β sort labels that are adjacent in the text according to their position in the reference list. This command should usually be given if theabbreviate-label-rangescommand has been given, or if the label expression contains a<>expression. This will have no effect unless references are being accumulated. π
β¨ Label expressions β¨
Label expressions can be evaluated both normally and tentatively. The result of normal evaluation is used for output. The result of tentative evaluation, called the tentative label, is used to gather the information that normal evaluation needs to disambiguate the label. Label expressions specified by the date-as-label and short-label commands are not evaluated tentatively. Normal and tentative evaluation are the same for all types of expression other than @, *, and % expressions. The description below applies to normal evaluation, except where otherwise specified. π«
fieldfield nβ then-th part offield. Ifnis omitted, it defaults to1.'string'β the characters instringliterally. π«Ά@β okay so this is the author-join icon: all the authors joined as specified by thejoin-authorscommand. The whole of each authorβs name will be used. But if the references are sorted by author (that is, the sort specification starts withA+), then authorsβ last names will be used instead, provided that this does not introduce ambiguity, and also an initial subsequence of the authors may be used instead of all the authors, again provided that this does not introduce ambiguity. The use of only the last name for thei-th author of some reference is considered to be ambiguous if there is some other reference, such that the firsti-1authors of the references are the same, thei-th authors are not the same, but thei-th authorsβ last names are the same. A proper initial subsequence of the sequence of authors for some reference is considered to be ambiguous if there is a reference with some other sequence of authors which also has that subsequence as a proper initial subsequence. When an initial subsequence of authors is used, the remaining authors are replaced by the string specified by theet-alcommand; this command may also specify additional requirements that must be met before an initial subsequence can be used.@tentatively evaluates to a canonical representation of the authors, such that authors that compare equally for sorting purpose will have the same representation. π%n,%a,%A,%i,%Iβ the serial number of the reference formatted according to the character following the%. The serial number of a reference is 1 plus the number of earlier references with same tentative label as this reference. These expressions tentatively evaluate to an empty string.expr*β if there is another reference with the same tentative label as this reference, thenexpr, otherwise an empty string. It tentatively evaluates to an empty string.expr+n,expr-nβ the first (+) or last (-)nupper or lower case letters or digits ofexpr.roffspecial characters (such as\('a) count as a single letter. Accent strings are retained but do not count towards the total.expr.lβexprconverted to lowercase.expr.uβexprconverted to uppercase.expr.cβexprconverted to caps and small caps.expr.rβexprreversed so that the last name is first.expr.aβexprwith first names abbreviated. Fields specified in theabbreviatecommand are abbreviated before any labels are evaluated. Thus.ais useful only when you want a field to be abbreviated in a label but not in a reference.expr.yβ the year part ofexpr.expr.+yβ the part ofexprbefore the year, or the whole ofexprif it does not contain a year.expr.-yβ the part ofexprafter the year, or an empty string ifexprdoes not contain a year.expr.nβ the last name part ofexpr.expr1~expr2βexpr1except that if the last character ofexpr1is-then it will be replaced byexpr2.expr1 expr2β the concatenation ofexpr1andexpr2.expr1|expr2β ifexpr1is non-empty thenexpr1otherwiseexpr2.expr1&expr2β ifexpr1is non-empty thenexpr2otherwise an empty string.expr1?expr2:expr3β ifexpr1is non-empty thenexpr2otherwiseexpr3.<expr>β the label is in two parts, which are separated byexpr. Two adjacent two-part labels which have the same first part will be merged by appending the second part of the second label onto the first label separated by the string specified in theseparate-label-second-partscommand (initially, a comma followed by a space); the resulting label will also be a two-part label with the same first part as before merging, and so additional labels can be merged into it. It is permissible for the first part to be empty; this may be desirable for expressions used in theshort-labelcommand.(expr)β the same asexpr. Used for grouping.
The above expressions are listed in order of precedence (highest first); & and | have the same precedence.
π§΅ Macro interface π§΅
Each reference starts with a call to the macro ]-. The string [F will be defined to be the label for this reference, unless the no-label-in-reference command has been given. There then follows a series of string definitions, one for each field: string [X corresponds to field X. The register [P is set to 1 if the P field contains a range of pages. The [T, [A and [O registers are set to 1 according as the T, A and O fields end with any of .?! (an end-of-sentence character). The [E register will be set to 1 if the [E string contains more than one name. The reference is followed by a call to the ][ macro. The first argument to this macro gives a number representing the type of the reference. If a reference contains a J field, it will be classified as type 1, otherwise if it contains a B field, it will be type 3, otherwise if it contains a G or R field it will be type 4, otherwise if it contains an I field it will be type 2, otherwise it will be type 0. The second argument is a symbolic name for the type: other, journal-article, book, article-in-book, or tech-report. Groups of references that have been accumulated or are produced by the bibliography command are preceded by a call to the ]< macro and followed by a call to the ]> macro. π«Ά
π οΈ OPTIONS π οΈ
--help displays a usage message, while -v and --version show version information; all exit afterward. π
-Rβ donβt recognize lines beginning with.R1/.R2.
Other options are equivalent to refer commands.
-a nβreverse An-bβno-label-in-text; no-label-in-reference-Bβ see below π-c fieldsβcapitalize fields-Cβcompatible-eβaccumulate-f nβlabel %n-i fieldsβsearch-ignore fields-kβlabel L~%a-k fieldβlabel field~%a-lβlabel A.nD.y%a-l mβlabel A.n+mD.y%a-l ,nβlabel A.nD.y-n%a-l m,nβlabel A.n+mD.y-n%a-nβno-default-database-p db-fileβdatabase db-file-Pβmove-punctuation-s specβsort spec-Sβlabel "(A.n|Q) ', ' (D.y|D)"; bracket-label " (" ) "; "-t nβsearch-truncate n
The B option has command equivalents with the addition that the file names specified on the command line are processed as if they were arguments to the bibliography command instead of in the normal way. β¨
-Bβannotate X AP; no-label-in-reference-B field.macroβannotate field macro; no-label-in-reference
π ENVIRONMENT π
REFERβ if set, overrides the default database.
π FILES π
/usr/dict/papers/Indβ default database.file.iβ index files./usr/share/groff/1.23.0/tmac/refer.tmacβ defines macros and strings facilitating integration with macro packages that wish to supportrefer.
refer uses temporary files. See the groff(1) man page for details of where such files are created.
π BUGS π
In label expressions, <> expressions are ignored inside .char expressions. π
πΈ EXAMPLES πΈ
We can illustrate the operation of refer with a sample bibliographic database containing one entry and a simple roff document to cite that entry. π
$ cat > my-db-file
%A Daniel P.\& Friedman
%A Matthias Felleisen
%C Cambridge, Massachusetts
%D 1996
%I The MIT Press
%T The Little Schemer, Fourth Edition
$ refer -p my-db-file
Read the book
.[
friedman
.]
on your summer vacation.
<Control+D>
.lf 1 -
Read the book\*([.1\*(.]
.ds [F 1
.]-
.ds [A Daniel P. Friedman and Matthias Felleisen
.ds [C Cambridge, Massachusetts
.ds [D 1996
.ds [I The MIT Press
.ds [T The Little Schemer, Fourth Edition
.nr [T 0
.nr [A 0
.][ 2 book
.lf 5 -
on your summer vacation.
The foregoing shows us that refer (a) produces a label 1; (b) brackets that label with interpolations of the [. and .] strings; (c) calls a macro ]-; (d) defines strings and registers containing the label and bibliographic data for the reference; (e) calls a macro ][; and (f) uses the lf request to restore the line numbers of the original input. As discussed in subsection βMacro interfaceβ above, it is up to the document or a macro package to employ and format this information usefully. Letβs see how we might turn groff_ms(7) to this task. π¦
$ REFER=my-db-file groff -R -ms
.LP
Read the book
.[
friedman
.]
on your summer vacation.
Commentary is available.\*{*\*}
.FS \*{*\*}
Space reserved for penetrating insight.
.FE
msβs automatic footnote numbering mechanism is not aware of referβs label numbering, so we have manually specified a (superscripted) symbolic footnote for our non-bibliographic aside. π
π SEE ALSO π
- βSome Applications of Inverted Indexes on the Unix Systemβ, by M. E. Lesk, 1978, AT&T Bell Laboratories Computing Science Technical Report No. 69.
indxbib(1),lookbib(1),lkbib(1)
Thatβs the whole vibe, bestie: groff 1.23.0 on 29 October 2024, and yes β itβs refer(1) π
β¨π
π¦ where this page comes from
- centos-stream 10: groff 1.23.0-10.el10 Β· GPL-3.0-or-later AND GFDL-1.3-or-later AND BSD-4-Clause-UC AND MIT AND X11 AND LicenseRef-Fedora-Public-Domain
- Copyright (C) 1989-2021 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms