Debian Codegraph @

texmf-dist/bibtex/bst/listbib/listbib.bst

raw
1 % listbib.doc
2 % listbib.bst
3 %
4 % This file was generated by Volker Kuhlmann on 10 Mar 2000
5 % from the file btxbst.doc version 0.99b by Oren Patashnik
6 % [ 3/23/88 (OP) Version 0.99b for BibTeX 0.99c ]
7 % with the command "/lib/cpp -P -DUNSRT btxbst.doc listbib.doc".
8 %
9 % Then comments at the beginning of the file were edited,
10 % and the essence of biblist version 1.3 by Joachim Schrod were worked in.
11 % Oh yes, and some improvements were added too...
12 %
13 % To obtain listbib.bst, a fast-load no-comment version for bibtex, run
14 % listbib.doc through the command
15 % sed -e '/^%/d' -e '/^[ ]*$/d'
16 % or simply install listbib.doc as listbib.bst (recommended).
17 % On contemporary computers the speed increase is very negligible and the loss
18 % of documentation weighs much more.
19 %
20 % Volker Kuhlmann
21 % 10, 14, 15, 16, 19 Mar; 28 Aug 2000
22 % 19 Mar 2000:
23 % Inheritance check for volume (result of check is still ignored),
24 % month, totalpages, URL
25 % 28 Aug 2000:
26 % Now not printing totalpages and URL if inherited.
27 % If undefined, defining \url which takes 1 arg and expands to its arg. Load
28 % package url instead!
29 %
30
31 % unsrt style (unsorted numbers)
32
33 %
34 % The ENTRY declaration
35 % Like Scribe's (according to pages 231-2 of the April '84 edition),
36 % but no fullauthor or editors fields because BibTeX does name handling.
37 % The annote field is commented out here because this family doesn't
38 % include an annotated bibliography style. And in addition to the fields
39 % listed here, BibTeX has a built-in crossref field, explained later.
40
41 ENTRY
42 % Fields:
43 { address
44 % Usually the address of a publisher or other type of organization.
45 % Put information in this field only if it helps the reader find the
46 % thing---for example you should omit the address of a major
47 % publisher entirely. For a PROCEEDINGS or an INPROCEEDINGS,
48 % however, it's the address of the conference; for those two entry
49 % types, include the publisher's or organization's address, if
50 % necessary, in the publisher or organization field.
51 % annote
52 % Long annotation---for annotated bibliographies (begins sentence).
53 annote
54 % Used by listbib. Not used by the 4 standard styles, and probably
55 % not used by too many other styles either.
56 % Useful for storing comments about bibliographic items which are
57 % not meant to end up in documents.
58 author
59 % Name(s) of author(s), in BibTeX name format.
60 booktitle
61 % Book title when the thing being referenced isn't the whole book.
62 % For book entries, the title field should be used instead.
63 chapter
64 % Chapter (or section or whatever) number.
65 edition
66 % Edition of a book---should be an ordinal (e.g., "Second").
67 editor
68 % Name(s) of editor(s), in BibTeX name format.
69 % If there is also an author field, then the editor field should be
70 % for the book or collection that the work appears in.
71 howpublished
72 % How something strange has been published (begins sentence).
73 institution
74 % Sponsoring institution of a technical report.
75 isbn
76 issn
77 % The obvious purpose...
78 journal
79 % Journal name (macros are provided for many).
80 key
81 % Alphabetizing, labeling, and cross-referencing key
82 % (needed when an entry has no author or editor).
83 library
84 % Location of the bibliographic item. This is useful for noting where
85 % in a library a book is. This is not meant to be printed in
86 % documents of course.
87 month
88 % Month (macros are provided).
89 note
90 % To help the reader find a reference (begins sentence).
91 number
92 % Number of a journal or technical report, or of a work in a series.
93 organization
94 % Organization sponsoring a conference (or publishing a manual); if
95 % the editor (or author) is empty, and if the organization produces
96 % an awkward label or cross reference, you should put appropriately
97 % condensed organization information in the key field as well.
98 pages
99 % Page number or numbers (use `--' to separate a range, use `+'
100 % to indicate pages following that don't form a simple range).
101 publisher
102 % Publisher name.
103 school
104 % School name (for theses).
105 series
106 % The name of a series or set of books.
107 % An individual book will will also have it's own title.
108 title
109 % The title of the thing you're referred to.
110 totalpages
111 % Total number of pages of the work.
112 % Is this what custom-bib uses it for?
113 type
114 % Type of a Techreport (e.g., "Research Note") to be used instead of
115 % the default "Technical Report"; or, similarly, the type of a
116 % thesis; or of a part of a book.
117 url
118 % The URL of an entry which is an electronic document.
119 % Is this what custom-bib uses it for?
120 volume
121 % The volume number of a journal or multivolume work.
122 year
123 % The year should contain only numerals (technically, it should end
124 % with four numerals, after purification; doesn't a begin sentence).
125 }
126 %
127 % Integer entry variables
128 {
129 num.entry
130 % The cardinal number of the entry in the data base.
131 % Checking for inheritance requires a resort; this number can be used
132 % to restore the original sort order.
133 inherited.note
134 inherited.annote
135 inherited.isbn
136 inherited.issn
137 inherited.library
138 inherited.volume
139 inherited.month
140 inherited.totalpages
141 inherited.url
142 % Flags which, when set, indicate that the respective field is
143 % inherited from another crossref'ed entry.
144 }
145 %
146 % String entry variables
147 {
148 label
149 sort.label
150 }
151
152
153 % These three functions pop one or two (integer) arguments from the stack
154 % and push a single one, either 0 or 1.
155 % The 'skip$ in the `and' and `or' functions are used because
156 % the corresponding if$ would be idempotent
157
158 FUNCTION {not}
159 { { #0 }
160 { #1 }
161 if$
162 }
163
164 FUNCTION {and}
165 { 'skip$
166 { pop$ #0 }
167 if$
168 }
169
170 FUNCTION {or}
171 { { pop$ #1 }
172 'skip$
173 if$
174 }
175
176 % Each entry function starts by calling output.bibitem, to write the
177 % \bibitem and its arguments to the .BBL file. Then the various fields
178 % are formatted and printed by output or output.check. Those functions
179 % handle the writing of separators (commas, periods, \newblock's),
180 % taking care not to do so when they are passed a null string.
181 % Finally, fin.entry is called to add the final period and finish the
182 % entry.
183 %
184 % A bibliographic reference is formatted into a number of `blocks':
185 % in the open format, a block begins on a new line and subsequent
186 % lines of the block are indented. A block may contain more than
187 % one sentence (well, not a grammatical sentence, but something to
188 % be ended with a sentence ending period). The entry functions should
189 % call new.block whenever a block other than the first is about to be
190 % started. They should call new.sentence whenever a new sentence is
191 % to be started. The output functions will ensure that if two
192 % new.sentence's occur without any non-null string being output between
193 % them then there won't be two periods output. Similarly for two
194 % successive new.block's.
195 %
196 % The output routines don't write their argument immediately.
197 % Instead, by convention, that argument is saved on the stack to be
198 % output next time (when we'll know what separator needs to come
199 % after it). Meanwhile, the output routine has to pop the pending
200 % output off the stack, append any needed separator, and write it.
201 %
202 % To tell which separator is needed, we maintain an output.state.
203 % It will be one of these values:
204 % before.all just after the \bibitem
205 % mid.sentence in the middle of a sentence: comma needed
206 % if more sentence is output
207 % after.sentence just after a sentence: period needed
208 % after.block just after a block (and sentence):
209 % period and \newblock needed.
210 % Note: These styles don't use after.sentence
211 %
212 % VAR: output.state : INTEGER -- state variable for output
213 %
214 % The output.nonnull function saves its argument (assumed to be nonnull)
215 % on the stack, and writes the old saved value followed by any needed
216 % separator. The ordering of the tests is decreasing frequency of
217 % occurrence.
218 %
219 % output.nonnull(s) ==
220 % BEGIN
221 % s := argument on stack
222 % if output.state = mid.sentence then
223 % write$(pop() * ", ")
224 % -- "pop" isn't a function: just use stack top
225 % else
226 % if output.state = after.block then
227 % write$(add.period$(pop()))
228 % newline$
229 % write$("\newblock ")
230 % else
231 % if output.state = before.all then
232 % write$(pop())
233 % else -- output.state should be after.sentence
234 % write$(add.period$(pop()) * " ")
235 % fi
236 % fi
237 % output.state := mid.sentence
238 % fi
239 % push s on stack
240 % END
241 %
242 % The output function calls output.nonnull if its argument is non-empty;
243 % its argument may be a missing field (thus, not necessarily a string)
244 %
245 % output(s) ==
246 % BEGIN
247 % if not empty$(s) then output.nonnull(s)
248 % fi
249 % END
250 %
251 % The output.check function is the same as the output function except that, if
252 % necessary, output.check warns the user that the t field shouldn't be empty
253 % (this is because it probably won't be a good reference without the field;
254 % the entry functions try to make the formatting look reasonable even when
255 % such fields are empty).
256 %
257 % output.check(s,t) ==
258 % BEGIN
259 % if empty$(s) then
260 % warning$("empty " * t * " in " * cite$)
261 % else output.nonnull(s)
262 % fi
263 % END
264 %
265 % The output.bibitem function writes the \bibitem for the current entry
266 % (the label should already have been set up), and sets up the separator
267 % state for the output functions. And, it leaves a string on the stack
268 % as per the output convention.
269 %
270 % output.bibitem ==
271 % BEGIN
272 % newline$
273 % write$("\bibitem[") % for alphabetic labels,
274 % write$(label) % these three lines
275 % write$("]{") % are used
276 % write$("\bibitem{") % this line for numeric labels
277 % write$(cite$)
278 % write$("}")
279 % push "" on stack
280 % output.state := before.all
281 % END
282 %
283 % The fin.entry function finishes off an entry by adding a period to the
284 % string remaining on the stack. If the state is still before.all
285 % then nothing was produced for this entry, so the result will look bad,
286 % but the user deserves it. (We don't omit the whole entry because the
287 % entry was cited, and a bibitem is needed to define the citation label.)
288 %
289 % fin.entry ==
290 % BEGIN
291 % write$(add.period$(pop()))
292 % newline$
293 % END
294 %
295 % The new.block function prepares for a new block to be output, and
296 % new.sentence prepares for a new sentence.
297 %
298 % new.block ==
299 % BEGIN
300 % if output.state <> before.all then
301 % output.state := after.block
302 % fi
303 % END
304 %
305 % new.sentence ==
306 % BEGIN
307 % if output.state <> after.block then
308 % if output.state <> before.all then
309 % output.state := after.sentence
310 % fi
311 % fi
312 % END
313 %
314
315 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
316
317 FUNCTION {init.state.consts}
318 { #0 'before.all :=
319 #1 'mid.sentence :=
320 #2 'after.sentence :=
321 #3 'after.block :=
322 }
323
324 % the variables s and t are temporary string holders
325
326 STRINGS { s t }
327
328 FUNCTION {output.nonnull}
329 { 's :=
330 output.state mid.sentence =
331 { ", " * write$ }
332 { output.state after.block =
333 { add.period$ write$
334 newline$
335 "\newblock " write$
336 }
337 { output.state before.all =
338 'write$
339 { add.period$ " " * write$ }
340 if$
341 }
342 if$
343 mid.sentence 'output.state :=
344 }
345 if$
346 s
347 }
348
349 FUNCTION {output}
350 { duplicate$ empty$
351 'pop$
352 'output.nonnull
353 if$
354 }
355
356 FUNCTION {output.check}
357 { 't :=
358 duplicate$ empty$
359 { pop$ "empty " t * " in " * cite$ * warning$ }
360 'output.nonnull
361 if$
362 }
363
364 FUNCTION {output.bibitem}
365 { newline$
366
367 "\bibitem{" write$
368
369 cite$ write$
370 "}" write$
371 newline$
372 ""
373 before.all 'output.state :=
374 }
375
376 % This function finishes all entries.
377
378 FUNCTION {fin.entry}
379 { add.period$
380 write$
381 newline$
382 }
383
384 FUNCTION {new.block}
385 { output.state before.all =
386 'skip$
387 { after.block 'output.state := }
388 if$
389 }
390
391 FUNCTION {new.sentence}
392 { output.state after.block =
393 'skip$
394 { output.state before.all =
395 'skip$
396 { after.sentence 'output.state := }
397 if$
398 }
399 if$
400 }
401
402 % Sometimes we begin a new block only if the block will be big enough. The
403 % new.block.checka function issues a new.block if its argument is nonempty;
404 % new.block.checkb does the same if either of its TWO arguments is nonempty.
405
406 FUNCTION {new.block.checka}
407 { empty$
408 'skip$
409 'new.block
410 if$
411 }
412
413 FUNCTION {new.block.checkb}
414 { empty$
415 swap$ empty$
416 and
417 'skip$
418 'new.block
419 if$
420 }
421
422 % The new.sentence.check functions are analogous.
423
424 FUNCTION {new.sentence.checka}
425 { empty$
426 'skip$
427 'new.sentence
428 if$
429 }
430
431 FUNCTION {new.sentence.checkb}
432 { empty$
433 swap$ empty$
434 and
435 'skip$
436 'new.sentence
437 if$
438 }
439
440 % Here are some functions for formatting chunks of an entry.
441 % By convention they either produce a string that can be followed by
442 % a comma or period (using add.period$, so it is OK to end in a period),
443 % or they produce the null string.
444 %
445 % A useful utility is the field.or.null function, which checks if the
446 % argument is the result of pushing a `missing' field (one for which no
447 % assignment was made when the current entry was read in from the database)
448 % or the result of pushing a string having no non-white-space characters.
449 % It returns the null string if so, otherwise it returns the field string.
450 % Its main (but not only) purpose is to guarantee that what's left on the
451 % stack is a string rather than a missing field.
452 %
453 % field.or.null(s) ==
454 % BEGIN
455 % if empty$(s) then return ""
456 % else return s
457 % END
458 %
459 % Another helper function is emphasize, which returns the argument emphazised,
460 % if that is non-empty, otherwise it returns the null string. Italic
461 % corrections aren't used, so this function should be used when punctation
462 % will follow the result.
463 % LaTeX's \emph{} will take care of italic correction.
464 %
465 % emphasize(s) ==
466 % BEGIN
467 % if empty$(s) then return ""
468 % %else return "{\em " * s * "}"
469 % else return "\emph{" * s * "}"
470 %
471 % The format.names function formats the argument (which should be in
472 % BibTeX name format) into "First Von Last, Junior", separated by commas
473 % and with an "and" before the last (but ending with "et~al." if the last
474 % of multiple authors is "others"). This function's argument should always
475 % contain at least one name.
476 %
477 % VAR: nameptr, namesleft, numnames: INTEGER
478 % pseudoVAR: nameresult: STRING (it's what's accumulated on the stack)
479 %
480 % format.names(s) ==
481 % BEGIN
482 % nameptr := 1
483 % numnames := num.names$(s)
484 % namesleft := numnames
485 % while namesleft > 0
486 % do
487 % % for full names:
488 % t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
489 % % for abbreviated first names:
490 % t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
491 % if nameptr > 1 then
492 % if namesleft > 1 then nameresult := nameresult * ", " * t
493 % else if numnames > 2
494 % then nameresult := nameresult * ","
495 % fi
496 % if t = "others"
497 % then nameresult := nameresult * " et~al."
498 % else nameresult := nameresult * " and " * t
499 % fi
500 % fi
501 % else nameresult := t
502 % fi
503 % nameptr := nameptr + 1
504 % namesleft := namesleft - 1
505 % od
506 % return nameresult
507 % END
508 %
509 % The format.authors function returns the result of format.names(author)
510 % if the author is present, or else it returns the null string
511 %
512 % format.authors ==
513 % BEGIN
514 % if empty$(author) then return ""
515 % else return format.names(author)
516 % fi
517 % END
518 %
519 % Format.editors is like format.authors, but it uses the editor field,
520 % and appends ", editor" or ", editors"
521 %
522 % format.editors ==
523 % BEGIN
524 % if empty$(editor) then return ""
525 % else
526 % if num.names$(editor) > 1 then
527 % return format.names(editor) * ", editors"
528 % else
529 % return format.names(editor) * ", editor"
530 % fi
531 % fi
532 % END
533 %
534 % Other formatting functions are similar, so no "comment version" will be
535 % given for them.
536 %
537 % The `pop$' in this function gets rid of the duplicate `empty' value and
538 % the `skip$' returns the duplicate field value
539
540 FUNCTION {field.or.null}
541 { duplicate$ empty$
542 { pop$ "" }
543 'skip$
544 if$
545 }
546
547 FUNCTION {emphasize}
548 { duplicate$ empty$
549 { pop$ "" }
550 %%{ "{\em " swap$ * "}" * }
551 { "\emph{" swap$ * "}" * }
552 if$
553 }
554
555 INTEGERS { nameptr namesleft numnames }
556
557 FUNCTION {format.names}
558 { 's :=
559 #1 'nameptr :=
560 s num.names$ 'numnames :=
561 numnames 'namesleft :=
562 { namesleft #0 > }
563
564 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
565
566 nameptr #1 >
567 { namesleft #1 >
568 { ", " * t * }
569 { numnames #2 >
570 { "," * }
571 'skip$
572 if$
573 t "others" =
574 { " et~al." * }
575 { " and " * t * }
576 if$
577 }
578 if$
579 }
580 't
581 if$
582 nameptr #1 + 'nameptr :=
583 namesleft #1 - 'namesleft :=
584 }
585 while$
586 }
587
588 FUNCTION {format.authors}
589 { author empty$
590 { "" }
591 { author format.names }
592 if$
593 }
594
595 FUNCTION {format.editors}
596 { editor empty$
597 { "" }
598 { editor format.names
599 editor num.names$ #1 >
600 { ", editors" * }
601 { ", editor" * }
602 if$
603 }
604 if$
605 }
606
607 % Format note.
608 % Need to introduce this because we check whether it's inherited.
609
610 FUNCTION {note.output}
611 { inherited.note
612 { }
613 { note output }
614 if$
615 }
616
617 % Format totalpages and URL.
618
619 FUNCTION {format.totalpages}
620 { totalpages empty$
621 { "" }
622 { "Pages: " totalpages * }
623 if$
624 }
625
626 FUNCTION {format.url}
627 { url empty$
628 { "" }
629 { "URL: \url{" url * "}" * }
630 if$
631 }
632
633 FUNCTION {check.bullet}
634 { duplicate$ empty$
635 'skip$
636 { " \ensuremath{\bullet} " * }
637 if$
638 }
639
640 FUNCTION {check.par}
641 { duplicate$ empty$
642 'skip$
643 { "\par " * }
644 if$
645 }
646
647 FUNCTION {format.totalpages.url}
648 { totalpages missing$
649 inherited.totalpages
650 or
651 { "" }
652 { format.totalpages }
653 if$
654 url missing$
655 inherited.url
656 or
657 { }
658 { check.bullet
659 format.url * }
660 if$
661 %check.par
662 }
663
664 FUNCTION {output.totalpages.url}
665 { new.block output
666 newline$ "\annote " write$
667 write$
668 %newline$
669 "\endannote"
670 }
671
672 % Deal with annote.
673 % This will also output totalpages and URL.
674
675 FUNCTION {output.annote}
676 { new.block "\annote " output
677 newline$ write$
678 annote add.period$ write$ newline$
679 "\endannote"
680 }
681
682 FUNCTION {annote.output}
683 { format.totalpages.url
684 duplicate$ empty$
685 'pop$
686 { output.totalpages.url }
687 if$
688 %
689 annote empty$
690 inherited.annote
691 or
692 'skip$
693 { output.annote }
694 if$
695 }
696
697 % Formatting + outputting ISBN and ISSN
698
699 FUNCTION {format.isbn}
700 { isbn empty$
701 { "" }
702 { new.sentence "ISBN~" isbn * }
703 if$
704 }
705
706 FUNCTION {format.issn}
707 { issn empty$
708 { "" }
709 { new.sentence "ISSN~" issn * }
710 if$
711 }
712
713 FUNCTION {isbn.output}
714 { inherited.isbn
715 { "" }
716 { format.isbn }
717 if$
718 output
719 }
720
721 FUNCTION {issn.output}
722 { inherited.issn
723 { "" }
724 { format.issn }
725 if$
726 output
727 }
728
729 FUNCTION {isbn.issn.output}
730 { %% both isbn and issn, but not both inherited
731 isbn empty$ not
732 issn empty$ not
733 and
734 inherited.isbn
735 inherited.issn
736 and not and
737 { "used both ISBN and ISSN fields in " cite$ * warning$ }
738 'skip$
739 if$
740 isbn.output
741 issn.output
742 }
743
744 % Formatting library
745 % We need to check and possibly alter the output state to avoid a period
746 % being output after the library part.
747 % In fact, we can't call output (because it can never work in this case),
748 % instead we write to the output buffer ourselves and set the output.state
749 % to something useful.
750
751 FUNCTION {format.library}
752 { library empty$
753 { "" }
754 { "\library{" library * "}" * }
755 if$
756 }
757
758 FUNCTION {library.output}
759 { % "checking lib out stat" top$ %% debug
760 inherited.library
761 { "" }
762 { format.library }
763 if$
764 duplicate$ empty$
765 { output }
766 { "%" * write$ newline$
767 before.all 'output.state :=
768 }
769 if$
770 }
771
772 % The format.title function is used for non-book-like titles.
773 % For most styles we convert to lowercase (except for the very first letter,
774 % and except for the first one after a colon (followed by whitespace)),
775 % and hope the user has brace-surrounded words that need to stay capitilized;
776 % for some styles, however, we leave it as it is in the database.
777
778 FUNCTION {format.title}
779 { title empty$
780 { "" }
781
782 % { title "t" change.case$ }
783 'title
784
785 if$
786 }
787
788 % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
789 % constant glob_str_size, the maximum length of a global string variable.
790 % Analogously, BibTeX sets the global integer variable entry.max$ to
791 % ent_str_size, the maximum length of an entry string variable.
792 % The style designer may change these if necessary (but this is unlikely)
793
794 % The n.dashify function makes each single `-' in a string a double `--'
795 % if it's not already
796 %
797 % pseudoVAR: pageresult: STRING (it's what's accumulated on the stack)
798 %
799 % n.dashify(s) ==
800 % BEGIN
801 % t := s
802 % pageresult := ""
803 % while (not empty$(t))
804 % do
805 % if (first character of t = "-")
806 % then
807 % if (next character isn't)
808 % then
809 % pageresult := pageresult * "--"
810 % t := t with the "-" removed
811 % else
812 % while (first character of t = "-")
813 % do
814 % pageresult := pageresult * "-"
815 % t := t with the "-" removed
816 % od
817 % fi
818 % else
819 % pageresult := pageresult * the first character
820 % t := t with the first character removed
821 % fi
822 % od
823 % return pageresult
824 % END
825
826 FUNCTION {n.dashify}
827 { 't :=
828 ""
829 { t empty$ not }
830 { t #1 #1 substring$ "-" =
831 { t #1 #2 substring$ "--" = not
832 { "--" *
833 t #2 global.max$ substring$ 't :=
834 }
835 { { t #1 #1 substring$ "-" = }
836 { "-" *
837 t #2 global.max$ substring$ 't :=
838 }
839 while$
840 }
841 if$
842 }
843 { t #1 #1 substring$ *
844 t #2 global.max$ substring$ 't :=
845 }
846 if$
847 }
848 while$
849 }
850
851 % The format.date function is for the month and year, but we give a warning if
852 % there's an empty year but the month is there, and we return the empty string
853 % if they're both empty.
854
855 FUNCTION {format.date}
856 { year empty$
857 { month empty$
858 inherited.month
859 or
860 { "" }
861 { "there's a month but no year in " cite$ * warning$
862 month
863 }
864 if$
865 }
866 { month empty$
867 inherited.month
868 or
869 'year
870 { month " " * year * }
871 if$
872 }
873 if$
874 }
875
876 % The format.btitle is for formatting the title field when it is a book-like
877 % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
878
879 FUNCTION {format.btitle}
880 { title emphasize
881 }
882
883 % For several functions we'll need to connect two strings with a
884 % tie (~) if the second one isn't very long (fewer than 3 characters).
885 % The tie.or.space.connect function does that. It concatenates the two
886 % strings on top of the stack, along with either a tie or space between
887 % them, and puts this concatenation back onto the stack:
888 %
889 % tie.or.space.connect(str1,str2) ==
890 % BEGIN
891 % if text.length$(str2) < 3
892 % then return the concatenation of str1, "~", and str2
893 % else return the concatenation of str1, " ", and str2
894 % END
895
896 FUNCTION {tie.or.space.connect}
897 { duplicate$ text.length$ #3 <
898 { "~" }
899 { " " }
900 if$
901 swap$ * *
902 }
903
904 % The either.or.check function complains if both fields of an either-or pair
905 % are nonempty.
906 %
907 % either.or.check(t,s) ==
908 % BEGIN
909 % if not empty$(s) then
910 % warning$(can't use both " * t * " fields in " * cite$)
911 % fi
912 % END
913
914 FUNCTION {either.or.check}
915 { empty$
916 'pop$
917 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
918 if$
919 }
920
921 % The format.bvolume function is for formatting the volume and perhaps
922 % series name of a multivolume work. If both a volume and a series field
923 % are there, we assume the series field is the title of the whole multivolume
924 % work (the title field should be the title of the thing being referred to),
925 % and we add an "of <series>". This function is called in mid-sentence.
926
927 FUNCTION {format.bvolume}
928 { volume empty$
929 { "" }
930 { "volume" volume tie.or.space.connect
931 series empty$
932 'skip$
933 { " of " * series emphasize * }
934 if$
935 "volume and number" number either.or.check
936 }
937 if$
938 }
939
940 % The format.number.series function is for formatting the series name
941 % and perhaps number of a work in a series. This function is similar to
942 % format.bvolume, although for this one the series must exist (and the
943 % volume must not exist). If the number field is empty we output either
944 % the series field unchanged if it exists or else the null string.
945 % If both the number and series fields are there we assume the series field
946 % gives the name of the whole series (the title field should be the title
947 % of the work being one referred to), and we add an "in <series>".
948 % We capitilize Number when this function is used at the beginning of a block.
949
950 FUNCTION {format.number.series}
951 { volume empty$
952 { number empty$
953 { series field.or.null }
954 { output.state mid.sentence =
955 { "number" }
956 { "Number" }
957 if$
958 number tie.or.space.connect
959 series empty$
960 { "there's a number but no series in " cite$ * warning$ }
961 { " in " * series * }
962 if$
963 }
964 if$
965 }
966 { "" }
967 if$
968 }
969
970 % The format.edition function appends " edition" to the edition, if present.
971 % We lowercase the edition (it should be something like "Third"), because
972 % this doesn't start a sentence.
973
974 FUNCTION {format.edition}
975 { edition empty$
976 { "" }
977 { output.state mid.sentence =
978 { edition "l" change.case$ " edition" * }
979 { edition "t" change.case$ " edition" * }
980 if$
981 }
982 if$
983 }
984
985 % The format.pages function is used for formatting a page range in a book
986 % (and in rare circumstances, an article).
987 %
988 % The multi.page.check function examines the page field for a "-" or "," or "+"
989 % so that format.pages can use "page" instead of "pages" if none exists.
990 % Note: global.max$ here means "take the rest of the string"
991 %
992 % VAR: multiresult: INTEGER (actually, a boolean)
993 %
994 % multi.page.check(s) ==
995 % BEGIN
996 % t := s
997 % multiresult := false
998 % while ((not multiresult) and (not empty$(t)))
999 % do
1000 % if (first character of t = "-" or "," or "+")
1001 % then multiresult := true
1002 % else t := t with the first character removed
1003 % fi
1004 % od
1005 % return multiresult
1006 % END
1007
1008 INTEGERS { multiresult }
1009
1010 FUNCTION {multi.page.check}
1011 { 't :=
1012 #0 'multiresult :=
1013 { multiresult not
1014 t empty$ not
1015 and
1016 }
1017 { t #1 #1 substring$
1018 duplicate$ "-" =
1019 swap$ duplicate$ "," =
1020 swap$ "+" =
1021 or or
1022 { #1 'multiresult := }
1023 { t #2 global.max$ substring$ 't := }
1024 if$
1025 }
1026 while$
1027 multiresult
1028 }
1029
1030 % This function doesn't begin a sentence so "pages" isn't capitalized.
1031 % Other functions that use this should keep that in mind.
1032
1033 FUNCTION {format.pages}
1034 { pages empty$
1035 { "" }
1036 { pages multi.page.check
1037 { "pages" pages n.dashify tie.or.space.connect }
1038 { "page" pages tie.or.space.connect }
1039 if$
1040 }
1041 if$
1042 }
1043
1044 % The format.vol.num.pages function is for the volume, number, and page range
1045 % of a journal article. We use the format: vol(number):pages, with some
1046 % variations for empty fields. This doesn't begin a sentence.
1047
1048 FUNCTION {format.vol.num.pages}
1049 { volume field.or.null
1050 number empty$
1051 'skip$
1052 { "(" number * ")" * *
1053 volume empty$
1054 { "there's a number but no volume in " cite$ * warning$ }
1055 'skip$
1056 if$
1057 }
1058 if$
1059 pages empty$
1060 'skip$
1061 { duplicate$ empty$
1062 { pop$ format.pages }
1063 { ":" * pages n.dashify * }
1064 if$
1065 }
1066 if$
1067 }
1068
1069
1070 % The format.chapter.pages, if the chapter is present, puts whatever is in the
1071 % type field (or else "chapter" if type is empty) in front of a chapter number.
1072 % It then appends the pages, if present. This doesn't begin a sentence.
1073
1074 FUNCTION {format.chapter.pages}
1075 { chapter empty$
1076 'format.pages
1077 { type empty$
1078 { "chapter" }
1079 { type "l" change.case$ }
1080 if$
1081 chapter tie.or.space.connect
1082 pages empty$
1083 'skip$
1084 { ", " * format.pages * }
1085 if$
1086 }
1087 if$
1088 }
1089
1090 % The format.in.ed.booktitle function is used for starting out a sentence
1091 % that begins "In <booktitle>", putting an editor before the title if one
1092 % exists.
1093
1094 FUNCTION {format.in.ed.booktitle}
1095 { booktitle empty$
1096 { "" }
1097 { editor empty$
1098 { "In " booktitle emphasize * }
1099 { "In " format.editors * ", " * booktitle emphasize * }
1100 if$
1101 }
1102 if$
1103 }
1104
1105 % The function empty.misc.check complains if all six fields are empty, and
1106 % if there's been no sorting or alphabetic-label complaint.
1107
1108 FUNCTION {empty.misc.check}
1109 { author empty$ title empty$ howpublished empty$
1110 month empty$ year empty$ note empty$
1111 and and and and and
1112
1113
1114
1115 { "all relevant fields are empty in " cite$ * warning$ }
1116 'skip$
1117 if$
1118 }
1119
1120 % The function format.thesis.type returns either the (case-changed) type field,
1121 % if it is defined, or else the default string already on the stack
1122 % (like "Master's thesis" or "PhD thesis").
1123
1124 FUNCTION {format.thesis.type}
1125 { type empty$
1126 'skip$
1127 { pop$
1128 type "t" change.case$
1129 }
1130 if$
1131 }
1132
1133 % The function format.tr.number makes a string starting with "Technical Report"
1134 % (or type, if that field is defined), followed by the number if there is one;
1135 % it returns the starting part (with a case change) even if there is no number.
1136 % This is used at the beginning of a sentence.
1137
1138 FUNCTION {format.tr.number}
1139 { type empty$
1140 { "Technical Report" }
1141 'type
1142 if$
1143 number empty$
1144 { "t" change.case$ }
1145 { number tie.or.space.connect }
1146 if$
1147 }
1148
1149 % Now come the cross-referencing functions (these are invoked because
1150 % one entry in the database file(s) cross-references another, by giving
1151 % the other entry's database key in a `crossref' field). This feature
1152 % allows one or more titled things that are part of a larger titled
1153 % thing to cross-reference the larger thing. These styles allow for
1154 % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
1155 % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
1156 % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
1157 % Each of these is explained in more detail later.
1158 %
1159 % An ARTICLE entry type may cross reference another ARTICLE (this is
1160 % intended for when an entire journal is devoted to a single topic---
1161 % but since there is no JOURNAL entry type, the journal, too, should be
1162 % classified as an ARTICLE but without the author and title fields).
1163 % This will result in two warning messages for the journal's entry
1164 % if it's included in the reference list, but such is life.
1165 %
1166 % format.article.crossref ==
1167 % BEGIN
1168 % if empty$(key) then
1169 % if empty$(journal) then
1170 % warning$("need key or journal for " * cite$ *
1171 % " to crossref " * crossref)
1172 % return(" \cite{" * crossref * "}")
1173 % else
1174 % return("In " * emphazise.correct (journal) *
1175 % " \cite{" * crossref * "}")
1176 % fi
1177 % else
1178 % return("In " * key * " \cite{" * crossref * "}")
1179 % fi
1180 % END
1181 %
1182 % The other cross-referencing functions are similar, so no "comment version"
1183 % will be given for them.
1184
1185 FUNCTION {format.article.crossref}
1186 { key empty$
1187 { journal empty$
1188 { "need key or journal for " cite$ * " to crossref " * crossref *
1189 warning$
1190 ""
1191 }
1192 %{ "In {\em " journal * "\/}" * }
1193 { "In " journal emphasize * }
1194 if$
1195 }
1196 { "In " key * }
1197 if$
1198 " \cite{" * crossref * "}" *
1199 }
1200
1201 % We use just the last names of editors for a cross reference: either
1202 % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
1203 % whether there are one, or two, or more than two editors.
1204
1205 FUNCTION {format.crossref.editor}
1206 { editor #1 "{vv~}{ll}" format.name$
1207 editor num.names$ duplicate$
1208 #2 >
1209 { pop$ " et~al." * }
1210 { #2 <
1211 'skip$
1212 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1213 { " et~al." * }
1214 { " and " * editor #2 "{vv~}{ll}" format.name$ * }
1215 if$
1216 }
1217 if$
1218 }
1219 if$
1220 }
1221
1222 % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
1223 % multivolume work) may cross reference another BOOK (the entire multivolume).
1224 % Usually there will be an editor, in which case we use that to construct the
1225 % cross reference; otherwise we use a nonempty key field or else the series
1226 % field (since the series gives the title of the multivolume work).
1227
1228 FUNCTION {format.book.crossref}
1229 { volume empty$
1230 { % We have a problem here: this function is called from both book and
1231 % inbook when there is a crossref. While it makes sense to warn about an
1232 % empty volume for a book which crossreferences another book (e.g. when
1233 % it is volume N of a multivolume work), this does not hold for inbook.
1234 % An inbook is a part of a book; a volume doesn't make sense (even
1235 % less warning about one).
1236 % Solution: disable warning for inbook. [VK Mar 2000]
1237 %"empty volume in " cite$ * "'s crossref of " * crossref * warning$
1238 type$ "inbook" =
1239 'skip$
1240 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ }
1241 if$
1242 "In "
1243 }
1244 { "Volume" volume tie.or.space.connect
1245 " of " *
1246 }
1247 if$
1248 editor empty$
1249 editor field.or.null author field.or.null =
1250 or
1251 { key empty$
1252 { series empty$
1253 { "need editor, key, or series for " cite$ * " to crossref " *
1254 crossref * warning$
1255 "" *
1256 }
1257 %{ "{\em " * series * "\/}" * }
1258 { series emphasize * }
1259 if$
1260 }
1261 { key * }
1262 if$
1263 }
1264 { format.crossref.editor * }
1265 if$
1266 " \cite{" * crossref * "}" *
1267 }
1268
1269 % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
1270 % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
1271 % Often there will be an editor, in which case we use that to construct
1272 % the cross reference; otherwise we use a nonempty key field or else
1273 % the booktitle field (which gives the cross-referenced work's title).
1274
1275 FUNCTION {format.incoll.inproc.crossref}
1276 { editor empty$
1277 editor field.or.null author field.or.null =
1278 or
1279 { key empty$
1280 { booktitle empty$
1281 { "need editor, key, or booktitle for " cite$ * " to crossref " *
1282 crossref * warning$
1283 ""
1284 }
1285 %{ "In {\em " booktitle * "\/}" * }
1286 { "In " booktitle emphasize * }
1287 if$
1288 }
1289 { "In " key * }
1290 if$
1291 }
1292 { "In " format.crossref.editor * }
1293 if$
1294 " \cite{" * crossref * "}" *
1295 }
1296
1297 % Now we define the type functions for all entry types that may appear
1298 % in the .BIB file---e.g., functions like `article' and `book'. These
1299 % are the routines that actually generate the .BBL-file output for
1300 % the entry. These must all precede the READ command. In addition, the
1301 % style designer should have a function `default.type' for unknown types.
1302 % Note: The fields (within each list) are listed in order of appearance,
1303 % except as described for an `inbook' or a `proceedings'.
1304 %
1305 % The article function is for an article in a journal. An article may
1306 % CROSSREF another article.
1307 % Required fields: author, title, journal, year
1308 % Optional fields: volume, number, pages, month, note
1309 % Also optional: library, issn, annote
1310 %
1311 % article ==
1312 % BEGIN
1313 % output.bibitem
1314 % output.check(format.authors,"author")
1315 % new.block
1316 % output.check(format.title,"title")
1317 % new.block
1318 % if missing$(crossref) then
1319 % output.check(emphasize(journal),"journal")
1320 % output(format.vol.num.pages)
1321 % output.check(format.date,"year")
1322 % else
1323 % output.nonnull(format.article.crossref)
1324 % output(format.pages)
1325 % fi
1326 % new.block
1327 % output(note)
1328 % fin.entry
1329 % END
1330 %
1331 % The book function is for a whole book. A book may CROSSREF another book.
1332 % Required fields: author or editor, title, publisher, year
1333 % Optional fields: volume or number, series, address, edition, month,
1334 % note
1335 % Also optional: library, isbn, issn, annote
1336 %
1337 % book ==
1338 % BEGIN
1339 % if empty$(author) then output.check(format.editors,"author and editor")
1340 % else output.check(format.authors,"author")
1341 % if missing$(crossref) then
1342 % either.or.check("author and editor",editor)
1343 % fi
1344 % fi
1345 % new.block
1346 % output.check(format.btitle,"title")
1347 % if missing$(crossref) then
1348 % output(format.bvolume)
1349 % new.block
1350 % output(format.number.series)
1351 % new.sentence
1352 % output.check(publisher,"publisher")
1353 % output(address)
1354 % else
1355 % new.block
1356 % output.nonnull(format.book.crossref)
1357 % fi
1358 % output(format.edition)
1359 % output.check(format.date,"year")
1360 % new.block
1361 % output(note)
1362 % fin.entry
1363 % END
1364 %
1365 % The other entry functions are all quite similar, so no "comment version"
1366 % will be given for them.
1367
1368 FUNCTION {article}
1369 { output.bibitem
1370 library.output
1371 new.sentence
1372 format.authors "author" output.check
1373 new.block
1374 format.title "title" output.check
1375 new.block
1376 crossref missing$
1377 { journal emphasize "journal" output.check
1378 format.vol.num.pages output
1379 format.date "year" output.check
1380 }
1381 { format.article.crossref output.nonnull
1382 format.pages output
1383 }
1384 if$
1385 issn.output
1386 new.block
1387 note.output
1388 annote.output
1389 fin.entry
1390 }
1391
1392 FUNCTION {book}
1393 { output.bibitem
1394 library.output
1395 new.sentence
1396 author empty$
1397 { format.editors "author and editor" output.check }
1398 { format.authors output.nonnull
1399 crossref missing$
1400 { "author and editor" editor either.or.check }
1401 'skip$
1402 if$
1403 }
1404 if$
1405 new.block
1406 format.btitle "title" output.check
1407 crossref missing$
1408 { format.bvolume output
1409 new.block
1410 format.number.series output
1411 new.sentence
1412 publisher "publisher" output.check
1413 address output
1414 }
1415 { new.block
1416 format.book.crossref output.nonnull
1417 }
1418 if$
1419 format.edition output
1420 format.date "year" output.check
1421 isbn.issn.output
1422 new.block
1423 note.output
1424 annote.output
1425 fin.entry
1426 }
1427
1428 % A booklet is a bound thing without a publisher or sponsoring institution.
1429 % Required: title
1430 % Optional: author, howpublished, address, month, year, note
1431 % Also optional: library, isbn, issn, annote
1432
1433 FUNCTION {booklet}
1434 { output.bibitem
1435 library.output
1436 new.sentence
1437 format.authors output
1438 new.block
1439 format.title "title" output.check
1440 howpublished address new.block.checkb
1441 howpublished output
1442 address output
1443 format.date output
1444 isbn.issn.output
1445 new.block
1446 note.output
1447 annote.output
1448 fin.entry
1449 }
1450
1451 % For the conference entry type, see inproceedings.
1452
1453 % An inbook is a piece of a book: either a chapter and/or a page range.
1454 % It may CROSSREF a book. If there's no volume field, the type field
1455 % will come before number and series.
1456 % Required: author or editor, title, chapter and/or pages, publisher,year
1457 % Optional: volume or number, series, type, address, edition, month, note
1458 % Also optional: library, isbn, issn, annote
1459
1460 FUNCTION {inbook}
1461 { output.bibitem
1462 library.output
1463 new.sentence
1464 author empty$
1465 { format.editors "author and editor" output.check }
1466 { format.authors output.nonnull
1467 crossref missing$
1468 { "author and editor" editor either.or.check }
1469 'skip$
1470 if$
1471 }
1472 if$
1473 new.block
1474 format.btitle "title" output.check
1475 crossref missing$
1476 { format.bvolume output
1477 format.chapter.pages "chapter and pages" output.check
1478 new.block
1479 format.number.series output
1480 new.sentence
1481 publisher "publisher" output.check
1482 address output
1483 }
1484 { format.chapter.pages "chapter and pages" output.check
1485 new.block
1486 format.book.crossref output.nonnull
1487 }
1488 if$
1489 format.edition output
1490 format.date "year" output.check
1491 isbn.issn.output
1492 new.block
1493 note.output
1494 annote.output
1495 fin.entry
1496 }
1497
1498 % An incollection is like inbook, but where there is a separate title
1499 % for the referenced thing (and perhaps an editor for the whole).
1500 % An incollection may CROSSREF a book.
1501 % Required: author, title, booktitle, publisher, year
1502 % Optional: editor, volume or number, series, type, chapter, pages,
1503 % address, edition, month, note
1504 % Also optional: library, isbn, issn, annote
1505
1506 FUNCTION {incollection}
1507 { output.bibitem
1508 library.output
1509 new.sentence
1510 format.authors "author" output.check
1511 new.block
1512 format.title "title" output.check
1513 new.block
1514 crossref missing$
1515 { format.in.ed.booktitle "booktitle" output.check
1516 format.bvolume output
1517 format.number.series output
1518 format.chapter.pages output
1519 new.sentence
1520 publisher "publisher" output.check
1521 address output
1522 format.edition output
1523 format.date "year" output.check
1524 }
1525 { format.incoll.inproc.crossref output.nonnull
1526 format.chapter.pages output
1527 }
1528 if$
1529 isbn.issn.output
1530 new.block
1531 note.output
1532 annote.output
1533 fin.entry
1534 }
1535
1536 % An inproceedings is an article in a conference proceedings, and it may
1537 % CROSSREF a proceedings. If there's no address field, the month (& year)
1538 % will appear just before note.
1539 % Required: author, title, booktitle, year
1540 % Optional: editor, volume or number, series, pages, address, month,
1541 % organization, publisher, note
1542 % Also optional: library, isbn, issn, annote
1543
1544 FUNCTION {inproceedings}
1545 { output.bibitem
1546 library.output
1547 new.sentence
1548 format.authors "author" output.check
1549 new.block
1550 format.title "title" output.check
1551 new.block
1552 crossref missing$
1553 { format.in.ed.booktitle "booktitle" output.check
1554 format.bvolume output
1555 format.number.series output
1556 format.pages output
1557 address empty$
1558 { organization publisher new.sentence.checkb
1559 organization output
1560 publisher output
1561 format.date "year" output.check
1562 }
1563 { address output.nonnull
1564 format.date "year" output.check
1565 new.sentence
1566 organization output
1567 publisher output
1568 }
1569 if$
1570 }
1571 { format.incoll.inproc.crossref output.nonnull
1572 format.pages output
1573 }
1574 if$
1575 isbn.issn.output
1576 new.block
1577 note.output
1578 annote.output
1579 fin.entry
1580 }
1581
1582 % The conference function is included for Scribe compatibility.
1583
1584 FUNCTION {conference} { inproceedings }
1585
1586 % A manual is technical documentation.
1587 % Required: title
1588 % Optional: author, organization, address, edition, month, year, note
1589 % Also optional: library, isbn, issn, annote
1590
1591 FUNCTION {manual}
1592 { output.bibitem
1593 library.output
1594 new.sentence
1595 author empty$
1596 { organization empty$
1597 'skip$
1598 { organization output.nonnull
1599 address output
1600 }
1601 if$
1602 }
1603 { format.authors output.nonnull }
1604 if$
1605 new.block
1606 format.btitle "title" output.check
1607 author empty$
1608 { organization empty$
1609 { address new.block.checka
1610 address output
1611 }
1612 'skip$
1613 if$
1614 }
1615 { organization address new.block.checkb
1616 organization output
1617 address output
1618 }
1619 if$
1620 format.edition output
1621 format.date output
1622 isbn.issn.output
1623 new.block
1624 note.output
1625 annote.output
1626 fin.entry
1627 }
1628
1629 % A mastersthesis is a Master's thesis.
1630 % Required: author, title, school, year
1631 % Optional: type, address, month, note
1632 % Also optional: library, isbn, issn, annote
1633
1634 FUNCTION {mastersthesis}
1635 { output.bibitem
1636 library.output
1637 new.sentence
1638 format.authors "author" output.check
1639 new.block
1640 format.title "title" output.check
1641 new.block
1642 "Master's thesis" format.thesis.type output.nonnull
1643 school "school" output.check
1644 address output
1645 format.date "year" output.check
1646 isbn.issn.output
1647 new.block
1648 note.output
1649 annote.output
1650 fin.entry
1651 }
1652
1653 % A misc is something that doesn't fit elsewhere.
1654 % Required: at least one of the `optional' fields
1655 % Optional: author, title, howpublished, month, year, note
1656 % Also optional: library, isbn, issn, annote
1657
1658 FUNCTION {misc}
1659 { output.bibitem
1660 library.output
1661 new.sentence
1662 format.authors output
1663 title howpublished new.block.checkb
1664 format.title output
1665 howpublished new.block.checka
1666 howpublished output
1667 format.date output
1668 isbn.issn.output
1669 new.block
1670 note.output
1671 annote.output
1672 fin.entry
1673 empty.misc.check
1674 }
1675
1676 % A phdthesis is like a mastersthesis.
1677 % Required: author, title, school, year
1678 % Optional: type, address, month, note
1679 % Also optional: library, isbn, issn, annote
1680
1681 FUNCTION {phdthesis}
1682 { output.bibitem
1683 library.output
1684 new.sentence
1685 format.authors "author" output.check
1686 new.block
1687 format.btitle "title" output.check
1688 new.block
1689 "PhD thesis" format.thesis.type output.nonnull
1690 school "school" output.check
1691 address output
1692 format.date "year" output.check
1693 isbn.issn.output
1694 new.block
1695 note.output
1696 annote.output
1697 fin.entry
1698 }
1699
1700 % A proceedings is a conference proceedings.
1701 % If there is an organization but no editor field, the organization will
1702 % appear as the first optional field (we try to make the first block nonempty);
1703 % if there's no address field, the month (& year) will appear just before note.
1704 % Required: title, year
1705 % Optional: editor, volume or number, series, address, month,
1706 % organization, publisher, note
1707 % Also optional: library, isbn, issn, annote
1708
1709 FUNCTION {proceedings}
1710 { output.bibitem
1711 library.output
1712 new.sentence
1713 editor empty$
1714 { organization output }
1715 { format.editors output.nonnull }
1716 if$
1717 new.block
1718 format.btitle "title" output.check
1719 format.bvolume output
1720 format.number.series output
1721 address empty$
1722 { editor empty$
1723 { publisher new.sentence.checka }
1724 { organization publisher new.sentence.checkb
1725 organization output
1726 }
1727 if$
1728 publisher output
1729 format.date "year" output.check
1730 }
1731 { address output.nonnull
1732 format.date "year" output.check
1733 new.sentence
1734 editor empty$
1735 'skip$
1736 { organization output }
1737 if$
1738 publisher output
1739 }
1740 if$
1741 isbn.issn.output
1742 new.block
1743 note.output
1744 annote.output
1745 fin.entry
1746 }
1747
1748 % A techreport is a technical report.
1749 % Required: author, title, institution, year
1750 % Optional: type, number, address, month, note
1751 % Also optional: library, isbn, issn, annote
1752
1753 FUNCTION {techreport}
1754 { output.bibitem
1755 library.output
1756 new.sentence
1757 format.authors "author" output.check
1758 new.block
1759 format.title "title" output.check
1760 new.block
1761 format.tr.number output.nonnull
1762 institution "institution" output.check
1763 address output
1764 format.date "year" output.check
1765 isbn.issn.output
1766 new.block
1767 note.output
1768 annote.output
1769 fin.entry
1770 }
1771
1772 % An unpublished is something that hasn't been published.
1773 % Required: author, title, note
1774 % Optional: month, year
1775 % Also optional: library, annote
1776
1777 FUNCTION {unpublished}
1778 { output.bibitem
1779 library.output
1780 new.sentence
1781 format.authors "author" output.check
1782 new.block
1783 format.title "title" output.check
1784 new.block
1785 note "note" output.check
1786 format.date output
1787 annote.output
1788 fin.entry
1789 }
1790
1791 % We use entry type `misc' for an unknown type; BibTeX gives a warning.
1792
1793 FUNCTION {default.type} { misc }
1794
1795 % Here are macros for common things that may vary from style to style.
1796 % Users are encouraged to use these macros.
1797 %
1798 % Months are either written out in full or abbreviated
1799
1800
1801
1802 MACRO {jan} {"January"}
1803
1804 MACRO {feb} {"February"}
1805
1806 MACRO {mar} {"March"}
1807
1808 MACRO {apr} {"April"}
1809
1810 MACRO {may} {"May"}
1811
1812 MACRO {jun} {"June"}
1813
1814 MACRO {jul} {"July"}
1815
1816 MACRO {aug} {"August"}
1817
1818 MACRO {sep} {"September"}
1819
1820 MACRO {oct} {"October"}
1821
1822 MACRO {nov} {"November"}
1823
1824 MACRO {dec} {"December"}
1825
1826
1827
1828 % Journals are either written out in full or abbreviated;
1829 % the abbreviations are like those found in ACM publications.
1830 %
1831 % To get a completely different set of abbreviations, it may be best to make
1832 % a separate .bib file with nothing but those abbreviations; users could then
1833 % include that file name as the first argument to the \bibliography command
1834
1835
1836
1837 MACRO {acmcs} {"ACM Computing Surveys"}
1838
1839 MACRO {acta} {"Acta Informatica"}
1840
1841 MACRO {cacm} {"Communications of the ACM"}
1842
1843 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1844
1845 MACRO {ibmsj} {"IBM Systems Journal"}
1846
1847 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1848
1849 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1850
1851 MACRO {ieeetcad}
1852 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1853
1854 MACRO {ipl} {"Information Processing Letters"}
1855
1856 MACRO {jacm} {"Journal of the ACM"}
1857
1858 MACRO {jcss} {"Journal of Computer and System Sciences"}
1859
1860 MACRO {scp} {"Science of Computer Programming"}
1861
1862 MACRO {sicomp} {"SIAM Journal on Computing"}
1863
1864 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1865
1866 MACRO {tods} {"ACM Transactions on Database Systems"}
1867
1868 MACRO {tog} {"ACM Transactions on Graphics"}
1869
1870 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1871
1872 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1873
1874 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1875
1876 MACRO {tcs} {"Theoretical Computer Science"}
1877
1878
1879
1880 % Now we read in the .BIB entries.
1881
1882 READ
1883
1884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1885 %% The following part tries to establish whether fields in entries which
1886 %% crossreference another entry are inherited from that entry or not.
1887 %% Unfortunately BibTeX does not make that information available.
1888 %% The basic assumption is that if the fields are identical, they are
1889 %% assumed to be inherited.
1890 %% By Volker Kuhlmann <[email protected]>
1891 %% with help from Oren Patashnik.
1892 %% 15, 16, 17 March 2000
1893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1894
1895 % Display some debugging output (sort output on column 2 and check)
1896 INTEGERS { debug.inheritance }
1897 FUNCTION {debug.inheritance.disable} { #0 'debug.inheritance := }
1898 FUNCTION {debug.inheritance.enable} { #1 'debug.inheritance := }
1899 EXECUTE {debug.inheritance.disable}% do not uncomment this!
1900 %% uncomment if desired:
1901 %EXECUTE {debug.inheritance.enable}
1902
1903 % We need a global string variable to hold field values between entries.
1904 % One per field checked for inheritance, plus cite.
1905 % Really, we should also save a flag "missing" for each field, but we
1906 % won't bother for now.
1907 STRINGS {
1908 inh.cite
1909 inh.note
1910 inh.annote
1911 inh.isbn
1912 inh.issn
1913 inh.library
1914 inh.volume
1915 inh.month
1916 inh.totalpages
1917 inh.url
1918 }
1919
1920 % Adds leading "0" to integers to fill up a field width. Was there a printf$ ...
1921 % pop: integer; push: string
1922 FUNCTION {fillint3.to.str}% (field width = 3)
1923 {
1924 duplicate$ #100 <
1925 {
1926 duplicate$ #10 <
1927 { "00" }
1928 { "0" }
1929 if$
1930 }
1931 { "" }
1932 if$
1933 swap$ int.to.str$ *
1934 }
1935 % Field width = 5, i.e. works up to 99 999 (= 10^6 - 1)
1936 FUNCTION {fillint.to.str}
1937 {
1938 duplicate$ #10000 <
1939 { duplicate$ #1000 <
1940 { duplicate$ #100 <
1941 { duplicate$ #10 <
1942 { "0000" }
1943 { "000" }
1944 if$
1945 }
1946 { "00" }
1947 if$
1948 }
1949 { "0" }
1950 if$
1951 }
1952 { "" }
1953 if$
1954 swap$ int.to.str$ *
1955 }
1956
1957 FUNCTION {zero.inherited}
1958 {
1959 #0 'inherited.note :=
1960 #0 'inherited.annote :=
1961 #0 'inherited.isbn :=
1962 #0 'inherited.issn :=
1963 #0 'inherited.library :=
1964 #0 'inherited.volume :=
1965 #0 'inherited.month :=
1966 #0 'inherited.totalpages :=
1967 #0 'inherited.url :=
1968 }
1969
1970 FUNCTION {debug.entry.dump.head}
1971 { debug.inheritance
1972 { "*** Dumping data base entries ... ***" top$ }
1973 'skip$
1974 if$
1975 }
1976
1977 % This is for debugging. Dumps an entry with its cardinal number.
1978 FUNCTION {debug.entry.dump}
1979 { debug.inheritance
1980 { "entry " num.entry fillint.to.str * " > " * cite$ * top$ }
1981 'skip$
1982 if$
1983 }
1984
1985 % First, we number all entries through.
1986 % Later in the process of establishing field inheritance, we need to sort
1987 % all entries. Saving a cardinal entry number allows us to restore the
1988 % original order.
1989 % While we're at it, we also initialise the flags variables.
1990
1991 INTEGERS { i }
1992
1993 FUNCTION {number.entries.init}
1994 { #1 'i :=
1995 }
1996
1997 FUNCTION {number.entries}
1998 {
1999 i 'num.entry :=
2000 i #1 + 'i :=
2001 %zero.inherited
2002 }
2003
2004 EXECUTE {number.entries.init}
2005 ITERATE {number.entries}
2006
2007 EXECUTE {debug.entry.dump.head} ITERATE {debug.entry.dump} %% debug
2008
2009 % Sort all entries such that the crossreferenced entry is first, then all
2010 % entries crossreferencing it are immediately following.
2011 % Entries which neither crossreference nor are crossreferenced are somewhere
2012 % in between.
2013
2014 %{ crossref #127 int.to.chr$ * } % the DEL character is ignored by SORT
2015 % tilde is the highest character we get; it's also illegal in cite keys
2016 FUNCTION {generate.crossref.sortkeys}
2017 {
2018 crossref missing$
2019 { cite$ }
2020 { crossref "~" * }
2021 if$
2022 'sort.key$ :=
2023 %% debug:
2024 %"entry " num.entry fillint.to.str * " sort key: '" * sort.key$ * "'" * top$
2025 }
2026
2027 ITERATE {generate.crossref.sortkeys}
2028 SORT
2029
2030 %EXECUTE {debug.entry.dump.head} ITERATE {debug.entry.dump} %% debug
2031
2032 % Now go through and check for equal fields in consecutive entries.
2033 % For each no-crossref entry: save fields
2034 % For each crossref entry: any fields equal to a saved one is assumed
2035 % to be inherited.
2036
2037 % Print current values of inherited.* . For debugging.
2038 FUNCTION {debug.inheritance.dump}
2039 { debug.inheritance
2040 {
2041 "entry " num.entry fillint.to.str * " inh:" *
2042 " note " inherited.note int.to.str$ * *
2043 ", annote " inherited.annote int.to.str$ * *
2044 ", isbn " inherited.isbn int.to.str$ * *
2045 ", issn " inherited.issn int.to.str$ * *
2046 ", lib " inherited.library int.to.str$ * *
2047 ", vol " inherited.volume int.to.str$ * *
2048 ", mon " inherited.month int.to.str$ * *
2049 ", tp " inherited.totalpages int.to.str$ * *
2050 ", url " inherited.url int.to.str$ * *
2051 top$
2052 }
2053 'skip$
2054 if$
2055 }
2056
2057 % save possibly inherited fields in global variables
2058 % It is an error to save a missing field in a string variable, so we save
2059 % an empty string instead.
2060 FUNCTION {inheritance.save.fields}
2061 {
2062 zero.inherited % this entry has no crossref - therefore no inherited fields
2063 cite$ 'inh.cite :=
2064 note missing$
2065 { "" } { note } if$
2066 'inh.note :=
2067 annote missing$
2068 { "" } { annote } if$
2069 'inh.annote :=
2070 isbn missing$
2071 { "" } { isbn } if$
2072 'inh.isbn :=
2073 issn missing$
2074 { "" } { issn } if$
2075 'inh.issn :=
2076 library missing$
2077 { "" } { library } if$
2078 'inh.library :=
2079 volume missing$
2080 { "" } { volume } if$
2081 'inh.volume :=
2082 month missing$
2083 { "" } { month } if$
2084 'inh.month :=
2085 totalpages missing$
2086 { "" } { totalpages } if$
2087 'inh.totalpages :=
2088 url missing$
2089 { "" } { url } if$
2090 'inh.url :=
2091 }
2092
2093 % Check for each non-missing field whether it is equal to the saved one.
2094 % Because we don't have any "field missing" information from the
2095 % crossreferenced entry, a field which is given in the corssreferencing
2096 % entry but is empty will be incorrectly detected as inherited if it is
2097 % missing in the crossreferenced entry.
2098 % Currently empty fields are not printed anyway, so we don't need to worry.
2099 FUNCTION {check.inheritance.fields}
2100 {
2101 note missing$
2102 { #0 } { note inh.note = } if$
2103 'inherited.note :=
2104 annote missing$
2105 { #0 } { annote inh.annote = } if$
2106 'inherited.annote :=
2107 isbn missing$
2108 { #0 } { isbn inh.isbn = } if$
2109 'inherited.isbn :=
2110 issn missing$
2111 { #0 } { issn inh.issn = } if$
2112 'inherited.issn :=
2113 library missing$
2114 { #0 } { library inh.library = } if$
2115 'inherited.library :=
2116 volume missing$
2117 { #0 } { volume inh.volume = } if$
2118 'inherited.volume :=
2119 month missing$
2120 { #0 } { month inh.month = } if$
2121 'inherited.month :=
2122 totalpages missing$
2123 { #0 } { totalpages inh.totalpages = } if$
2124 'inherited.totalpages :=
2125 url missing$
2126 { #0 } { url inh.url = } if$
2127 'inherited.url :=
2128 }
2129
2130 INTEGERS { check.inh.inited }
2131
2132 FUNCTION {check.inheritance.init}
2133 { #0 'check.inh.inited :=
2134 }
2135
2136 FUNCTION {check.inheritance}
2137 { check.inh.inited #0 =
2138 { #1 'check.inh.inited :=
2139 inheritance.save.fields
2140 }
2141 { crossref missing$
2142 { inheritance.save.fields }
2143 { crossref inh.cite =
2144 { check.inheritance.fields }
2145 { zero.inherited
2146 "crossreferencing entry {" cite$ * "} out of order" *
2147 " ****** contact listbib author ******" * warning$ }
2148 if$
2149 }
2150 if$
2151 }
2152 if$
2153 %debug.inheritance.dump %% debug
2154 }
2155
2156 EXECUTE {check.inheritance.init}
2157 ITERATE {check.inheritance}
2158
2159 % Finally, restore original entry order
2160
2161 FUNCTION {generate.num.entry.sortkeys}
2162 {
2163 num.entry fillint.to.str 'sort.key$ :=
2164 }
2165
2166 ITERATE {generate.num.entry.sortkeys}
2167 SORT
2168
2169 %EXECUTE {debug.entry.dump.head} ITERATE {debug.entry.dump} %% debug
2170 ITERATE {debug.inheritance.dump} %% debug
2171
2172 %% End of part checking for inherited fields.
2173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2174
2175 % The sortify function converts to lower case after purify$ing; it's
2176 % used in sorting and in computing alphabetic labels after sorting
2177 %
2178 % The chop.word(w,len,s) function returns either s or, if the first len
2179 % letters of s equals w (this comparison is done in the third line of the
2180 % function's definition), it returns that part of s after w.
2181
2182
2183
2184
2185
2186 % This long comment applies only to alphabetic labels
2187 %
2188 % The format.lab.names function makes a short label by using the initials of
2189 % the von and Last parts of the names (but if there are more than four names,
2190 % (i.e., people) it truncates after three and adds a superscripted "+";
2191 % it also adds such a "+" if the last of multiple authors is "others").
2192 % If there is only one name, and its von and Last parts combined have just
2193 % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
2194 % we take the first three letters of the last name. The boolean
2195 % et.al.char.used tells whether we've used a superscripted "+", so that we
2196 % know whether to include a LaTeX macro for it.
2197 %
2198 % format.lab.names(s) ==
2199 % BEGIN
2200 % numnames := num.names$(s)
2201 % if numnames > 1 then
2202 % if numnames > 4 then
2203 % namesleft := 3
2204 % else
2205 % namesleft := numnames
2206 % nameptr := 1
2207 % nameresult := ""
2208 % while namesleft > 0
2209 % do
2210 % if (name_ptr = numnames) and
2211 % format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
2212 % then nameresult := nameresult * "{\etalchar{+}}"
2213 % et.al.char.used := true
2214 % else nameresult := nameresult *
2215 % format.name$(s, nameptr, "{v{}}{l{}}")
2216 % nameptr := nameptr + 1
2217 % namesleft := namesleft - 1
2218 % od
2219 % if numnames > 4 then
2220 % nameresult := nameresult * "{\etalchar{+}}"
2221 % et.al.char.used := true
2222 % else
2223 % t := format.name$(s, 1, "{v{}}{l{}}")
2224 % if text.length$(t) < 2 then % there's just one name-token
2225 % nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
2226 % else
2227 % nameresult := t
2228 % fi
2229 % fi
2230 % return nameresult
2231 % END
2232 %
2233 % Exactly what fields we look at in constructing the primary part of the label
2234 % depends on the entry type; this selectivity (as opposed to, say, always
2235 % looking at author, then editor, then key) helps ensure that "ignored" fields,
2236 % as described in the LaTeX book, really are ignored. Note that MISC is part
2237 % of the deepest `else' clause in the nested part of calc.label; thus, any
2238 % unrecognized entry type in the database is handled correctly.
2239 %
2240 % There is one auxiliary function for each of the four different sequences of
2241 % fields we use. The first of these functions looks at the author field, and
2242 % then, if necessary, the key field. The other three functions, which might
2243 % look at two fields and the key field, are similar, except that the key field
2244 % takes precedence over the organization field (for labels---not for sorting).
2245 %
2246 % The calc.label function calculates the preliminary label of an entry, which
2247 % is formed by taking three letters of information from the author or editor or
2248 % key or organization field (depending on the entry type and on what's empty,
2249 % but ignoring a leading "The " in the organization), and appending the last
2250 % two characters (digits) of the year. It is an error if the appropriate fields
2251 % among author, editor, organization, and key are missing, and we use
2252 % the first three letters of the cite$ in desperation when this happens.
2253 % The resulting label has the year part, but not the name part, purify$ed
2254 % (purify$ing the year allows some sorting shenanigans by the user).
2255 %
2256 % This function also calculates the version of the label to be used in sorting.
2257 %
2258 % The final label may need a trailing 'a', 'b', etc., to distinguish it from
2259 % otherwise identical labels, but we can't calculated those "extra.label"s
2260 % until after sorting.
2261 %
2262 % calc.label ==
2263 % BEGIN
2264 % if type$ = "book" or "inbook" then
2265 % author.editor.key.label
2266 % else if type$ = "proceedings" then
2267 % editor.key.organization.label
2268 % else if type$ = "manual" then
2269 % author.key.organization.label
2270 % else
2271 % author.key.label
2272 % fi fi fi
2273 % label := label * substring$(purify$(field.or.null(year)), -1, 2)
2274 % % assuming we will also sort, we calculate a sort.label
2275 % sort.label := sortify(label), but use the last four, not two, digits
2276 % END
2277
2278
2279
2280 % When sorting, we compute the sortkey by executing "presort" on each entry.
2281 % The presort key contains a number of "sortify"ed strings, concatenated
2282 % with multiple blanks between them. This makes things like "brinch per"
2283 % come before "brinch hansen per".
2284 %
2285 % The fields used here are: the sort.label for alphabetic labels (as set by
2286 % calc.label), followed by the author names (or editor names or organization
2287 % (with a leading "The " removed) or key field, depending on entry type and on
2288 % what's empty), followed by year, followed by the first bit of the title
2289 % (chopping off a leading "The ", "A ", or "An ").
2290 % Names are formatted: Von Last First Junior.
2291 % The names within a part will be separated by a single blank
2292 % (such as "brinch hansen"), two will separate the name parts themselves
2293 % (except the von and last), three will separate the names,
2294 % four will separate the names from year (and from label, if alphabetic),
2295 % and four will separate year from title.
2296 %
2297 % The sort.format.names function takes an argument that should be in
2298 % BibTeX name format, and returns a string containing " "-separated
2299 % names in the format described above. The function is almost the same
2300 % as format.names.
2301
2302
2303
2304 % This long comment applies only to alphabetic labels, when sorted
2305 %
2306 % Now comes the final computation for alphabetic labels, putting in the 'a's
2307 % and 'b's and so forth if required. This involves two passes: a forward
2308 % pass to put in the 'b's, 'c's and so on, and a backwards pass
2309 % to put in the 'a's (we don't want to put in 'a's unless we know there
2310 % are 'b's).
2311 % We have to keep track of the longest (in width$ terms) label, for use
2312 % by the "thebibliography" environment.
2313 %
2314 % VAR: longest.label, last.sort.label, next.extra: string
2315 % longest.label.width, last.extra.num: integer
2316 %
2317 % initialize.longest.label ==
2318 % BEGIN
2319 % longest.label := ""
2320 % last.sort.label := int.to.chr$(0)
2321 % next.extra := ""
2322 % longest.label.width := 0
2323 % last.extra.num := 0
2324 % END
2325 %
2326 % forward.pass ==
2327 % BEGIN
2328 % if last.sort.label = sort.label then
2329 % last.extra.num := last.extra.num + 1
2330 % extra.label := int.to.chr$(last.extra.num)
2331 % else
2332 % last.extra.num := chr.to.int$("a")
2333 % extra.label := ""
2334 % last.sort.label := sort.label
2335 % fi
2336 % END
2337 %
2338 % reverse.pass ==
2339 % BEGIN
2340 % if next.extra = "b" then
2341 % extra.label := "a"
2342 % fi
2343 % label := label * extra.label
2344 % if width$(label) > longest.label.width then
2345 % longest.label := label
2346 % longest.label.width := width$(label)
2347 % fi
2348 % next.extra := extra.label
2349 % END
2350
2351
2352
2353 % Now comes the computation for numeric labels.
2354 % We use either the sorted order or original order.
2355 % We still have to keep track of the longest (in width$ terms) label, for use
2356 % by the "thebibliography" environment.
2357
2358 STRINGS { longest.label }
2359
2360 INTEGERS { number.label longest.label.width }
2361
2362 FUNCTION {initialize.longest.label}
2363 { "" 'longest.label :=
2364 #1 'number.label :=
2365 #0 'longest.label.width :=
2366 }
2367
2368 FUNCTION {longest.label.pass}
2369 { number.label int.to.str$ 'label :=
2370 number.label #1 + 'number.label :=
2371 label width$ longest.label.width >
2372 { label 'longest.label :=
2373 label width$ 'longest.label.width :=
2374 }
2375 'skip$
2376 if$
2377 }
2378
2379 EXECUTE {initialize.longest.label}
2380
2381 ITERATE {longest.label.pass}
2382
2383
2384
2385 % Now we're ready to start writing the .BBL file.
2386 % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
2387 % label; next comes stuff from the `preamble' command in the database files.
2388 % Then we give an incantation containing the command
2389 % \begin{thebibliography}{...}
2390 % where the `...' is the longest label.
2391 %
2392 % We also call init.state.consts, for use by the output routines.
2393
2394 FUNCTION {begin.bib}
2395 { preamble$ empty$
2396 'skip$
2397 { preamble$ write$ newline$ }
2398 if$
2399 "\begin{thebibliography}{" longest.label * "}" * write$ newline$
2400 "\providecommand\url[1]{#1}" write$ newline$
2401 }
2402
2403 EXECUTE {begin.bib}
2404
2405 EXECUTE {init.state.consts}
2406
2407 % Now we produce the output for all the entries
2408
2409 ITERATE {call.type$}
2410
2411 % Finally, we finish up by writing the `\end{thebibliography}' command.
2412
2413 FUNCTION {end.bib}
2414 { newline$
2415 "\end{thebibliography}" write$ newline$
2416 }
2417
2418 EXECUTE {end.bib}