Add groff 1.19.1, stripped down appropriately.
[dragonfly.git] / contrib / groff-1.19 / src / preproc / refer / refer.man
1 .ig
2 Copyright (C) 1989-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3
4 Permission is granted to make and distribute verbatim copies of
5 this manual provided the copyright notice and this permission notice
6 are preserved on all copies.
7
8 Permission is granted to copy and distribute modified versions of this
9 manual under the conditions for verbatim copying, provided that the
10 entire resulting derived work is distributed under the terms of a
11 permission notice identical to this one.
12
13 Permission is granted to copy and distribute translations of this
14 manual into another language, under the above conditions for modified
15 versions, except that this permission notice may be included in
16 translations approved by the Free Software Foundation instead of in
17 the original English.
18 ..
19 .de TQ
20 .br
21 .ns
22 .TP \\$1
23 ..
24 .\" Like TP, but if specified indent is more than half
25 .\" the current line-length - indent, use the default indent.
26 .de Tp
27 .ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
28 .el .TP "\\$1"
29 ..
30 .\" The BSD man macros can't handle " in arguments to font change macros,
31 .\" so use \(ts instead of ".
32 .tr \(ts"
33 .TH @G@REFER @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
34 .SH NAME
35 @g@refer \- preprocess bibliographic references for groff
36 .SH SYNOPSIS
37 .nr a \n(.j
38 .ad l
39 .nr i \n(.i
40 .in +\w'\fB@g@refer 'u
41 .ti \niu
42 .B @g@refer
43 .de OP
44 .ie \\n(.$-1 .RI "[\ \fB\\$1\fP" "\\$2" "\ ]"
45 .el .RB "[\ " "\\$1" "\ ]"
46 ..
47 .OP \-benvCPRS
48 .OP \-a n
49 .OP \-c fields
50 .OP \-f n
51 .OP \-i fields
52 .OP \-k field
53 .OP \-l m,n
54 .OP \-p filename
55 .OP \-s fields
56 .OP \-t n
57 .OP \-B field.macro
58 .RI [\  filename \|.\|.\|.\ ]
59 .br
60 .ad \na
61 .PP
62 It is possible to have whitespace between a command line option and its
63 parameter.
64 .SH DESCRIPTION
65 This file documents the GNU version of
66 .BR refer ,
67 which is part of the groff document formatting system.
68 .B refer
69 copies the contents of
70 .IR filename \|.\|.\|.\&
71 to the standard output,
72 except that lines between
73 .B .[
74 and
75 .B .]
76 are interpreted as citations,
77 and lines between
78 .B .R1
79 and
80 .B .R2
81 are interpreted as commands about how citations are to be processed.
82 .LP
83 Each citation specifies a reference.
84 The citation can specify a reference that is contained in
85 a bibliographic database by giving a set of keywords
86 that only that reference contains.
87 Alternatively it can specify a reference by supplying a database
88 record in the citation.
89 A combination of these alternatives is also possible.
90 .LP
91 For each citation,
92 .B refer
93 can produce a mark in the text.
94 This mark consists of some label which can be separated from
95 the text and from other labels in various ways.
96 For each reference it also outputs
97 .B groff
98 commands that can be used by a macro package to produce a formatted
99 reference for each citation.
100 The output of
101 .B refer
102 must therefore be processed using a suitable macro package.
103 The
104 .B \-ms
105 and
106 .B \-me
107 macros are both suitable.
108 The commands to format a citation's reference can be output immediately after
109 the citation,
110 or the references may be accumulated,
111 and the commands output at some later point.
112 If the references are accumulated, then multiple citations of the same
113 reference will produce a single formatted reference.
114 .LP
115 The interpretation of lines between
116 .B .R1
117 and
118 .B .R2
119 as commands is a new feature of GNU refer.
120 Documents making use of this feature can still be processed by
121 Unix refer just by adding the lines
122 .RS
123 .LP
124 .nf
125 .ft B
126 \&.de R1
127 \&.ig R2
128 \&..
129 .ft
130 .fi
131 .RE
132 to the beginning of the document.
133 This will cause
134 .B troff
135 to ignore everything between
136 .B .R1
137 and
138 .BR .R2 .
139 The effect of some commands can also be achieved by options.
140 These options are supported mainly for compatibility with Unix refer.
141 It is usually more convenient to use commands.
142 .LP
143 .B refer
144 generates
145 .B .lf
146 lines so that filenames and line numbers in messages produced
147 by commands that read
148 .B refer
149 output will be correct;
150 it also interprets lines beginning with
151 .B .lf
152 so that filenames and line numbers in the messages and
153 .B .lf
154 lines that it produces will be accurate even if the input has been
155 preprocessed by a command such as
156 .BR @g@soelim (@MAN1EXT@).
157 .SH OPTIONS
158 .LP
159 Most options are equivalent to commands
160 (for a description of these commands see the
161 .B Commands
162 subsection):
163 .TP
164 .B \-b
165 .B
166 no-label-in-text; no-label-in-reference
167 .TP
168 .B \-e
169 .B accumulate
170 .TP
171 .B \-n
172 .B no-default-database
173 .TP
174 .B \-C
175 .B compatible
176 .TP
177 .B \-P
178 .B move-punctuation
179 .TP
180 .B \-S
181 .B
182 label "(A.n|Q) ', ' (D.y|D)"; bracket-label " (" ) "; "
183 .TP
184 .BI \-a n
185 .B reverse
186 .BI A n
187 .TP
188 .BI \-c fields
189 .B capitalize
190 .I fields
191 .TP
192 .BI \-f n
193 .B label
194 .BI % n
195 .TP
196 .BI \-i fields
197 .B search-ignore
198 .I fields
199 .TP
200 .B \-k
201 .B label
202 .B L\(ti%a
203 .TP
204 .BI \-k field
205 .B label
206 .IB field \(ti%a
207 .TP
208 .B \-l
209 .B label
210 .BI A.nD.y%a
211 .TP
212 .BI \-l m
213 .B label
214 .BI A.n+ m D.y%a
215 .TP
216 .BI \-l, n
217 .B label
218 .BI A.nD.y\- n %a
219 .TP
220 .BI \-l m , n
221 .B label
222 .BI A.n+ m D.y\- n %a
223 .TP
224 .BI \-p filename
225 .B database
226 .I filename
227 .TP
228 .BI \-s spec
229 .B sort
230 .I spec
231 .TP
232 .BI \-t n
233 .B search-truncate
234 .I n
235 .LP
236 These options are equivalent to the following commands with the
237 addition that the filenames specified on the command line are
238 processed as if they were arguments to the
239 .B bibliography
240 command instead of in the normal way:
241 .TP
242 .B \-B
243 .B
244 annotate X AP; no-label-in-reference
245 .TP
246 .BI \-B field . macro
247 .B annotate
248 .I field
249 .IB macro ;
250 .B no-label-in-reference
251 .LP
252 The following options have no equivalent commands:
253 .TP
254 .B \-v
255 Print the version number.
256 .TP
257 .B \-R
258 Don't recognize lines beginning with
259 .BR .R1 / .R2 .
260 .SH USAGE
261 .SS Bibliographic databases
262 The bibliographic database is a text file consisting of records
263 separated by one or more blank lines.
264 Within each record fields start with a
265 .B %
266 at the beginning of a line.
267 Each field has a one character name that immediately follows the
268 .BR % .
269 It is best to use only upper and lower case letters for the names
270 of fields.
271 The name of the field should be followed by exactly one space,
272 and then by the contents of the field.
273 Empty fields are ignored.
274 The conventional meaning of each field is as follows:
275 .TP
276 .B A
277 The name of an author.
278 If the name contains a title such as
279 .B Jr.
280 at the end,
281 it should be separated from the last name by a comma.
282 There can be multiple occurrences of the
283 .B A
284 field.
285 The order is significant.
286 It is a good idea always to supply an
287 .B A
288 field or a 
289 .B Q
290 field.
291 .TP
292 .B B
293 For an article that is part of a book, the title of the book.
294 .TP
295 .B C
296 The place (city) of publication.
297 .TP
298 .B D
299 The date of publication.
300 The year should be specified in full.
301 If the month is specified, the name rather than the number of the month
302 should be used, but only the first three letters are required.
303 It is a good idea always to supply a
304 .B D
305 field;
306 if the date is unknown, a value such as
307 .B in press
308 or
309 .B unknown
310 can be used.
311 .TP
312 .B E
313 For an article that is part of a book, the name of an editor of the book.
314 Where the work has editors and no authors,
315 the names of the editors should be given as
316 .B A
317 fields and
318 .B ,\ (ed)
319 or
320 .B ,\ (eds)
321 should be appended to the last author.
322 .TP
323 .B G
324 US Government ordering number.
325 .TP
326 .B I
327 The publisher (issuer).
328 .TP
329 .B J
330 For an article in a journal, the name of the journal.
331 .TP
332 .B K
333 Keywords to be used for searching.
334 .TP
335 .B L
336 Label.
337 .TP
338 .B N
339 Journal issue number.
340 .TP
341 .B O
342 Other information.
343 This is usually printed at the end of the reference.
344 .TP
345 .B P
346 Page number.
347 A range of pages can be specified as
348 .IB m \- n\fR.
349 .TP
350 .B Q
351 The name of the author, if the author is not a person.
352 This will only be used if there are no
353 .B A
354 fields.
355 There can only be one
356 .B Q
357 field.
358 .TP
359 .B R
360 Technical report number.
361 .TP
362 .B S
363 Series name.
364 .TP
365 .B T
366 Title.
367 For an article in a book or journal,
368 this should be the title of the article.
369 .TP
370 .B V
371 Volume number of the journal or book.
372 .TP
373 .B X
374 Annotation.
375 .LP
376 For all fields except
377 .B A
378 and
379 .BR E ,
380 if there is more than one occurrence of a particular field in a record,
381 only the last such field will be used.
382 .LP
383 If accent strings are used, they should follow the character to be accented.
384 This means that the
385 .B AM
386 macro must be used with the
387 .B \-ms
388 macros.
389 Accent strings should not be quoted:
390 use one
391 .B \e
392 rather than two.
393 .SS Citations
394 The format of a citation is
395 .RS
396 .BI .[ opening-text
397 .br
398 .I
399 flags keywords
400 .br
401 .I fields
402 .br
403 .BI .] closing-text
404 .RE
405 .LP
406 The
407 .IR opening-text ,
408 .IR closing-text
409 and
410 .I flags
411 components are optional.
412 Only one of the
413 .I keywords
414 and
415 .I fields
416 components need be specified.
417 .LP
418 The
419 .I keywords
420 component says to search the bibliographic databases for a reference
421 that contains all the words in
422 .IR keywords .
423 It is an error if more than one reference if found.
424 .LP
425 The
426 .I fields
427 components specifies additional fields to replace or supplement
428 those specified in the reference.
429 When references are being accumulated and the
430 .I keywords
431 component is non-empty,
432 then additional fields should be specified only on the first
433 occasion that a particular reference is cited,
434 and will apply to all citations of that reference.
435 .LP
436 The
437 .I opening-text
438 and
439 .I closing-text
440 component specifies strings to be used to bracket the label instead
441 of the strings specified in the
442 .B bracket-label
443 command.
444 If either of these components is non-empty,
445 the strings specified in the
446 .B bracket-label
447 command will not be used;
448 this behaviour can be altered using the
449 .B [
450 and
451 .B ]
452 flags.
453 Note that leading and trailing spaces are significant for these components.
454 .LP
455 The
456 .I flags
457 component is a list of
458 non-alphanumeric characters each of which modifies the treatment
459 of this particular citation.
460 Unix refer will treat these flags as part of the keywords and
461 so will ignore them since they are non-alphanumeric.
462 The following flags are currently recognized:
463 .TP
464 .B #
465 This says to use the label specified by the
466 .B short-label
467 command,
468 instead of that specified by the
469 .B label
470 command.
471 If no short label has been specified, the normal label will be used.
472 Typically the short label is used with author-date labels
473 and consists of only the date and possibly a disambiguating letter;
474 the
475 .B #
476 is supposed to be suggestive of a numeric type of label.
477 .TP
478 .B [
479 Precede
480 .I opening-text
481 with the first string specified in the
482 .B bracket-label
483 command.
484 .TP
485 .B ]
486 Follow
487 .I closing-text
488 with the second string specified in the
489 .B bracket-label
490 command.
491 .LP
492 One advantages of using the
493 .B [
494 and
495 .B ]
496 flags rather than including the brackets in
497 .I opening-text
498 and
499 .I closing-text
500 is that
501 you can change the style of bracket used in the document just by changing the
502 .B bracket-label
503 command.
504 Another advantage is that sorting and merging of citations
505 will not necessarily be inhibited if the flags are used.
506 .LP
507 If a label is to be inserted into the text,
508 it will be attached to the line preceding the
509 .B .[
510 line.
511 If there is no such line, then an extra line will be inserted before the
512 .B .[
513 line and a warning will be given.
514 .LP
515 There is no special notation for making a citation to multiple references.
516 Just use a sequence of citations, one for each reference.
517 Don't put anything between the citations.
518 The labels for all the citations will be attached to the line preceding
519 the first citation.
520 The labels may also be sorted or merged.
521 See the description of the
522 .B <>
523 label expression, and of the
524 .B sort-adjacent-labels
525 and
526 .B abbreviate-label-ranges
527 command.
528 A label will not be merged if its citation has a non-empty
529 .I opening-text
530 or
531 .IR closing-text .
532 However, the labels for a citation using the
533 .B ]
534 flag and without any
535 .I closing-text
536 immediately followed by a citation using the
537 .B [
538 flag and without any
539 .I opening-text
540 may be sorted and merged
541 even though the first citation's
542 .I opening-text
543 or the second citation's
544 .I closing-text
545 is non-empty.
546 (If you wish to prevent this just make the first citation's
547 .I closing-text
548 .BR \e& .)
549 .SS Commands
550 Commands are contained between lines starting with
551 .B .R1
552 and
553 .BR .R2 .
554 Recognition of these lines can be prevented by the
555 .B \-R
556 option.
557 When a
558 .B .R1
559 line is recognized any accumulated references are flushed out.
560 Neither
561 .B .R1
562 nor
563 .B .R2
564 lines,
565 nor anything between them
566 is output.
567 .LP
568 Commands are separated by newlines or 
569 .BR ; s.
570 .B #
571 introduces a comment that extends to the end of the line
572 (but does not conceal the newline).
573 Each command is broken up into words.
574 Words are separated by spaces or tabs.
575 A word that begins with
576 .B \(ts
577 extends to the next
578 .B \(ts
579 that is not followed by another
580 .BR \(ts .
581 If there is no such
582 .B \(ts
583 the word extends to the end of the line.
584 Pairs of
585 .B \(ts
586 in a word beginning with
587 .B \(ts
588 collapse to a single
589 .BR \(ts .
590 Neither
591 .B #
592 nor
593 .B ;
594 are recognized inside
595 .BR \(ts s.
596 A line can be continued by ending it with
597 .BR \e ;
598 this works everywhere except after a
599 .BR # .
600 .LP
601 .ds n \fR*
602 Each command
603 .I name
604 that is marked with \*n has an associated negative command
605 .BI no- name
606 that undoes the effect of
607 .IR name .
608 For example, the
609 .B no-sort
610 command specifies that references should not be sorted.
611 The negative commands take no arguments.
612 .LP
613 In the following description each argument must be a single word;
614 .I field
615 is used for a single upper or lower case letter naming a field;
616 .I fields
617 is used for a sequence of such letters;
618 .I m
619 and
620 .I n
621 are used for a non-negative numbers;
622 .I string
623 is used for an arbitrary string;
624 .I filename
625 is used for the name of a file.
626 .Tp \w'\fBabbreviate-label-ranges'u+2n
627 .BI abbreviate\*n\  fields\ string1\ string2\ string3\ string4
628 Abbreviate the first names of
629 .IR fields .
630 An initial letter will be separated from another initial letter by
631 .IR string1 ,
632 from the last name by
633 .IR string2 ,
634 and from anything else
635 (such as a
636 .B von
637 or
638 .BR de )
639 by
640 .IR string3 .
641 These default to a period followed by a space.
642 In a hyphenated first name,
643 the initial of the first part of the name will be separated from the hyphen by
644 .IR string4 ;
645 this defaults to a period.
646 No attempt is made to handle any ambiguities that might
647 result from abbreviation.
648 Names are abbreviated before sorting and before
649 label construction.
650 .TP
651 .BI abbreviate-label-ranges\*n\  string
652 Three or more adjacent labels that refer to consecutive references
653 will be abbreviated to a label consisting
654 of the first label, followed by
655 .I string
656 followed by the last label.
657 This is mainly useful with numeric labels.
658 If
659 .I string
660 is omitted it defaults to
661 .BR \- .
662 .TP
663 .B accumulate\*n
664 Accumulate references instead of writing out each reference
665 as it is encountered.
666 Accumulated references will be written out whenever a reference
667 of the form
668 .RS
669 .IP
670 .B .[
671 .br
672 .B $LIST$
673 .br
674 .B .]
675 .LP
676 is encountered,
677 after all input files hve been processed,
678 and whenever
679 .B .R1
680 line is recognized.
681 .RE
682 .TP
683 .BI annotate\*n\  field\ string
684 .I field
685 is an annotation;
686 print it at the end of the reference as a paragraph preceded by the line
687 .RS
688 .IP
689 .BI . string
690 .LP
691 If
692 .I macro
693 is omitted it will default to
694 .BR AP ;
695 if
696 .I field
697 is also omitted it will default to
698 .BR X .
699 Only one field can be an annotation.
700 .RE
701 .TP
702 .BI articles\  string \fR\|.\|.\|. 
703 .IR string \|.\|.\|.
704 are definite or indefinite articles, and should be ignored at the beginning of
705 .B T
706 fields when sorting.
707 Initially,
708 .BR the ,
709 .B a
710 and
711 .B an
712 are recognized as articles. 
713 .TP
714 .BI bibliography\  filename \fR\|.\|.\|.
715 Write out all the references contained in the bibliographic databases
716 .IR filename \|.\|.\|.
717 .TP
718 .BI bracket-label\  string1\ string2\ string3
719 In the text, bracket each label
720 with
721 .I string1
722 and
723 .IR string2 .
724 An occurrence of
725 .I string2
726 immediately followed by
727 .I string1
728 will be turned into
729 .IR string3 .
730 The default behaviour is
731 .RS
732 .IP
733 .B
734 bracket-label \e*([. \e*(.] ", "
735 .RE
736 .TP
737 .BI capitalize\  fields
738 Convert
739 .I fields
740 to caps and small caps.
741 .TP
742 .B compatible\*n
743 Recognize
744 .B .R1
745 and
746 .B .R2
747 even when followed by a character other than space or newline.
748 .TP
749 .BI database\  filename \fR\|.\|.\|.
750 Search the bibliographic databases
751 .IR filename \|.\|.\|.
752 For each
753 .I filename
754 if an index
755 .IB filename @INDEX_SUFFIX@
756 created by
757 .BR @g@indxbib (@MAN1EXT@)
758 exists, then it will be searched instead;
759 each index can cover multiple databases.
760 .TP
761 .BI date-as-label\*n\  string
762 .I string
763 is a label expression that specifies a string with which to replace the
764 .B D
765 field after constructing the label.
766 See the
767 .B "Label expressions"
768 subsection for a description of label expressions.
769 This command is useful if you do not want explicit labels in the
770 reference list, but instead want to handle any necessary
771 disambiguation by qualifying the date in some way.
772 The label used in the text would typically be some combination of the
773 author and date.
774 In most cases you should also use the
775 .B no-label-in-reference
776 command.
777 For example,
778 .RS
779 .IP
780 .B
781 date-as-label D.+yD.y%a*D.-y
782 .LP
783 would attach a disambiguating letter to the year part of the
784 .B D
785 field in the reference.
786 .RE
787 .TP
788 .B default-database\*n
789 The default database should be searched.
790 This is the default behaviour, so the negative version of
791 this command is more useful.
792 refer determines whether the default database should be searched
793 on the first occasion that it needs to do a search.
794 Thus a
795 .B no-default-database
796 command must be given before then,
797 in order to be effective.
798 .TP
799 .BI discard\*n\  fields
800 When the reference is read,
801 .I fields
802 should be discarded;
803 no string definitions for
804 .I fields
805 will be output.
806 Initially,
807 .I fields
808 are
809 .BR XYZ .
810 .TP
811 .BI et-al\*n\  string\ m\ n
812 Control use of
813 .B
814 et al
815 in the evaluation of
816 .B @
817 expressions in label expressions.
818 If the number of authors needed to make the author sequence
819 unambiguous is
820 .I u
821 and the total number of authors is
822 .I t
823 then the last
824 .IR t \|\-\| u
825 authors will be replaced by
826 .I string
827 provided that
828 .IR t \|\-\| u
829 is not less than
830 .I m
831 and
832 .I t
833 is not less than
834 .IR n .
835 The default behaviour is
836 .RS
837 .IP
838 .B
839 et-al " et al" 2 3
840 .RE
841 .TP
842 .BI include\  filename
843 Include
844 .I filename
845 and interpret the contents as commands.
846 .TP
847 .BI join-authors\  string1\ string2\ string3
848 This says how authors should be joined together.
849 When there are exactly two authors, they will be joined with
850 .IR string1 .
851 When there are more than two authors, all but the last two will
852 be joined with
853 .IR string2 ,
854 and the last two authors will be joined with
855 .IR string3 .
856 If
857 .I string3
858 is omitted,
859 it will default to
860 .IR string1 ;
861 if
862 .I string2
863 is also omitted it will also default to
864 .IR string1 .
865 For example,
866 .RS
867 .IP
868 .B
869 join-authors " and " ", " ", and "
870 .LP
871 will restore the default method for joining authors.
872 .RE
873 .TP
874 .B label-in-reference\*n
875 When outputting the reference,
876 define the string
877 .B [F
878 to be the reference's label.
879 This is the default behaviour; so the negative version
880 of this command is more useful.
881 .TP
882 .B label-in-text\*n
883 For each reference output a label in the text.
884 The label will be separated from the surrounding text as described in the
885 .B bracket-label
886 command.
887 This is the default behaviour; so the negative version
888 of this command is more useful.
889 .TP
890 .BI label\  string
891 .I string
892 is a label expression describing how to label each reference.
893 .TP
894 .BI separate-label-second-parts\  string
895 When merging two-part labels, separate the second part of the second
896 label from the first label with
897 .IR string .
898 See the description of the
899 .B <>
900 label expression.
901 .TP
902 .B move-punctuation\*n
903 In the text, move any punctuation at the end of line past the label.
904 It is usually a good idea to give this command unless you are using
905 superscripted numbers as labels.
906 .TP
907 .BI reverse\*n\  string
908 Reverse the fields whose names
909 are in
910 .IR string .
911 Each field name can be followed by a number which says
912 how many such fields should be reversed.
913 If no number is given for a field, all such fields will be reversed.
914 .TP
915 .BI search-ignore\*n\  fields
916 While searching for keys in databases for which no index exists,
917 ignore the contents of
918 .IR fields .
919 Initially, fields
920 .B XYZ
921 are ignored.
922 .TP
923 .BI search-truncate\*n\  n
924 Only require the first
925 .I n
926 characters of keys to be given.
927 In effect when searching for a given key
928 words in the database are truncated to the maximum of
929 .I n
930 and the length of the key.
931 Initially
932 .I n
933 is 6.
934 .TP
935 .BI short-label\*n\  string
936 .I string
937 is a label expression that specifies an alternative (usually shorter)
938 style of label.
939 This is used when the
940 .B #
941 flag is given in the citation.
942 When using author-date style labels, the identity of the author
943 or authors is sometimes clear from the context, and so it
944 may be desirable to omit the author or authors from the label.
945 The
946 .B short-label
947 command will typically be used to specify a label containing just
948 a date and possibly a disambiguating letter.
949 .TP
950 .BI sort\*n\  string
951 Sort references according to
952 .BR string .
953 References will automatically be accumulated.
954 .I string
955 should be a list of field names, each followed by a number,
956 indicating how many fields with the name should be used for sorting.
957 .B +
958 can be used to indicate that all the fields with the name should be used.
959 Also 
960 .B .
961 can be used to indicate the references should be sorted using the
962 (tentative) label.
963 (The
964 .B
965 Label expressions
966 subsection describes the concept of a tentative label.)
967 .TP
968 .B sort-adjacent-labels\*n
969 Sort labels that are adjacent in the text according to their
970 position in the reference list.
971 This command should usually be given if the
972 .B abbreviate-label-ranges
973 command has been given,
974 or if the label expression contains a
975 .B <>
976 expression.
977 This will have no effect unless references are being accumulated.
978 .SS Label expressions
979 .LP
980 Label expressions can be evaluated both normally and tentatively. 
981 The result of normal evaluation is used for output. 
982 The result of tentative evaluation, called the
983 .I
984 tentative label,
985 is used to gather the information
986 that normal evaluation needs to disambiguate the label.
987 Label expressions specified by the
988 .B date-as-label
989 and
990 .B short-label
991 commands are not evaluated tentatively.
992 Normal and tentative evaluation are the same for all types
993 of expression other than
994 .BR @ ,
995 .BR * ,
996 and
997 .B %
998 expressions. 
999 The description below applies to normal evaluation,
1000 except where otherwise specified. 
1001 .TP
1002 .I field
1003 .TQ
1004 .I field\ n
1005 The
1006 .IR n -th
1007 part of
1008 .IR field . 
1009 If
1010 .I n
1011 is omitted, it defaults to 1. 
1012 .TP
1013 .BI ' string '
1014 The characters in
1015 .I string
1016 literally. 
1017 .TP
1018 .B @
1019 All the authors joined as specified by the
1020 .B join-authors
1021 command.
1022 The whole of each author's name will be used.
1023 However, if the references are sorted by author
1024 (that is the sort specification starts with
1025 .BR A+ ),
1026 then authors' last names will be used instead, provided that this does
1027 not introduce ambiguity,
1028 and also an initial subsequence of the authors may be used
1029 instead of all the authors, again provided that this does not
1030 introduce ambiguity.
1031 The use of only the last name for the
1032 .IR i -th
1033 author of some reference
1034 is considered to be ambiguous if
1035 there is some other reference,
1036 such that the first
1037 .IR i \|-\|1
1038 authors of the references are the same,
1039 the
1040 .IR i -th
1041 authors are not the same,
1042 but the
1043 .IR i -th
1044 authors' last names are the same.
1045 A proper initial subsequence of the sequence
1046 of authors for some reference is considered to be ambiguous if there is
1047 a reference with some other sequence of authors which also has
1048 that subsequence as a proper initial subsequence.
1049 When an initial subsequence of authors is used, the remaining
1050 authors are replaced by the string specified by the
1051 .B et-al
1052 command;
1053 this command may also specify additional requirements that must be
1054 met before an initial subsequence can be used.
1055 .B @
1056 tentatively evaluates to a canonical representation of the authors,
1057 such that authors that compare equally for sorting purpose
1058 will have the same representation.
1059 .TP
1060 .BI % n
1061 .TQ
1062 .B %a
1063 .TQ
1064 .B %A
1065 .TQ
1066 .B %i
1067 .TQ
1068 .B %I
1069 The serial number of the reference formatted according to the character
1070 following the
1071 .BR % . 
1072 The serial number of a reference is 1 plus the number of earlier references
1073 with same tentative label as this reference.
1074 These expressions tentatively evaluate to an empty string.
1075 .TP
1076 .IB expr *
1077 If there is another reference with the same tentative label as
1078 this reference, then
1079 .IR expr ,
1080 otherwise an empty string.
1081 It tentatively evaluates to an empty string.
1082 .TP
1083 .IB expr + n
1084 .TQ
1085 .IB expr \- n
1086 The first
1087 .RB ( + )
1088 or last
1089 .RB ( \- )
1090 .I n
1091 upper or lower case letters or digits of
1092 .IR expr .
1093 Troff special characters (such as
1094 .BR \e('a )
1095 count as a single letter.
1096 Accent strings are retained but do not count towards the total.
1097 .TP
1098 .IB expr .l
1099 .I expr
1100 converted to lowercase. 
1101 .TP
1102 .IB expr .u
1103 .I expr
1104 converted to uppercase. 
1105 .TP
1106 .IB expr .c
1107 .I expr
1108 converted to caps and small caps. 
1109 .TP
1110 .IB expr .r
1111 .I expr
1112 reversed so that the last name is first.
1113 .TP
1114 .IB expr .a
1115 .I expr
1116 with first names abbreviated.
1117 Note that fields specified in the
1118 .B abbreviate
1119 command are abbreviated before any labels are evaluated.
1120 Thus
1121 .B .a
1122 is useful only when you want a field to be abbreviated in a label
1123 but not in a reference.
1124 .TP
1125 .IB expr .y
1126 The year part of
1127 .IR expr . 
1128 .TP
1129 .IB expr .+y
1130 The part of
1131 .I expr
1132 before the year, or the whole of
1133 .I expr
1134 if it does not contain a year.
1135 .TP
1136 .IB expr .\-y
1137 The part of
1138 .I expr
1139 after the year, or an empty string if
1140 .I expr
1141 does not contain a year.
1142 .TP
1143 .IB expr .n
1144 The last name part of
1145 .IR expr . 
1146 .TP
1147 .IB expr1 \(ti expr2
1148 .I expr1
1149 except that if the last character of
1150 .I expr1
1151 is
1152 .B \-
1153 then it will be replaced by
1154 .IR expr2 . 
1155 .TP
1156 .I expr1\ expr2
1157 The concatenation of
1158 .I expr1
1159 and
1160 .IR expr2 . 
1161 .TP
1162 .IB expr1 | expr2
1163 If
1164 .I expr1
1165 is non-empty then
1166 .I expr1
1167 otherwise
1168 .IR expr2 . 
1169 .TP
1170 .IB expr1 & expr2
1171 If
1172 .I expr1
1173 is non-empty
1174 then
1175 .I expr2
1176 otherwise an empty string.
1177 .TP
1178 .IB expr1 ? expr2 : expr3
1179 If
1180 .I expr1
1181 is non-empty
1182 then
1183 .I expr2
1184 otherwise
1185 .IR expr3 . 
1186 .TP
1187 .BI < expr >
1188 The label is in two parts, which are separated by
1189 .IR expr .
1190 Two adjacent two-part labels which have the same first part will be
1191 merged by appending the second part of the second label onto the first
1192 label separated by the string specified in the
1193 .B separate-label-second-parts
1194 command (initially, a comma followed by a space); the resulting label
1195 will also be a two-part label with the same first part as before
1196 merging, and so additional labels can be merged into it.
1197 Note that it is permissible for the first part to be empty;
1198 this maybe desirable for expressions used in the
1199 .B short-label
1200 command.
1201 .TP
1202 .BI ( expr )
1203 The same as
1204 .IR expr .
1205 Used for grouping.
1206 .LP
1207 The above expressions are listed in order of precedence
1208 (highest first);
1209 .B &
1210 and
1211 .B |
1212 have the same precedence.
1213 .SS Macro interface
1214 Each reference starts with a call to the macro
1215 .BR ]- .
1216 The string
1217 .B [F
1218 will be defined to be the label for this reference,
1219 unless the
1220 .B no-label-in-reference
1221 command has been given.
1222 There then follows a series of string definitions,
1223 one for each field:
1224 string
1225 .BI [ X
1226 corresponds to field
1227 .IR X .
1228 The number register
1229 .B [P
1230 is set to 1 if the
1231 .B P
1232 field contains a range of pages.
1233 The
1234 .BR [T ,
1235 .B [A
1236 and
1237 .B [O
1238 number registers are set to 1 according as the
1239 .BR T ,
1240 .B A
1241 and
1242 .B O
1243 fields end with one of the characters
1244 .BR .?! .
1245 The
1246 .B [E
1247 number register will be set to 1 if the
1248 .B [E
1249 string contains more than one name.
1250 The reference is followed by a call to the
1251 .B ][
1252 macro.
1253 The first argument to this macro gives a number representing
1254 the type of the reference.
1255 If a reference contains a
1256 .B J
1257 field, it will be classified as type 1,
1258 otherwise if it contains a
1259 .B B
1260 field, it will type 3,
1261 otherwise if it contains a
1262 .B G
1263 or
1264 .B R
1265 field it will be type 4,
1266 otherwise if contains a
1267 .B I
1268 field it will be type 2,
1269 otherwise it will be type 0.
1270 The second argument is a symbolic name for the type:
1271 .BR other ,
1272 .BR journal-article ,
1273 .BR book ,
1274 .B article-in-book
1275 or
1276 .BR tech-report .
1277 Groups of references that have been accumulated
1278 or are produced by the
1279 .B bibliography
1280 command are preceded by a call to the
1281 .B ]<
1282 macro and followed by a call to the
1283 .B ]>
1284 macro.
1285 .SH FILES
1286 .Tp \w'\fB@DEFAULT_INDEX@'u+2n
1287 .B @DEFAULT_INDEX@
1288 Default database.
1289 .TP
1290 .IB file @INDEX_SUFFIX@
1291 Index files.
1292 .SH ENVIRONMENT
1293 .Tp \w'\fBREFER'u+2n
1294 .B REFER
1295 If set, overrides the default database.
1296 .SH "SEE ALSO"
1297 .BR @g@indxbib (@MAN1EXT@),
1298 .BR @g@lookbib (@MAN1EXT@),
1299 .BR lkbib (@MAN1EXT@)
1300 .br
1301 .SH BUGS
1302 In label expressions,
1303 .B <>
1304 expressions are ignored inside
1305 .BI . char
1306 expressions.
1307 .
1308 .\" Local Variables:
1309 .\" mode: nroff
1310 .\" End: