Debian Codegraph @

texmf-dist/doc/bibtex/abstyles/btxabst.doc

raw
1 % BibTeX `adaptable' family
2 % version 1.10 derived by Hans-Hermann Bode (H2B), Osnabr\"uck,
3 % (BitNet/EARN: HHBODE@DOSUNI1)
4 % from the `plain' family version 0.99b.
5 % The copying statement declared below extends to this file also with
6 % the file names btxabst.doc, aplain.bst, aunsrt.bst, aalpha.bst,
7 % aabbrv.bst, anotit.bst, and aunsnot.bst added.
8 % BibTeX `plain' family
9 % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
10 % Copyright (C) 1985, all rights reserved.
11 % Copying of this file is authorized only if either
12 % (1) you make absolutely no changes to your copy, including name, or
13 % (2) if you do make changes, you name it something other than
14 % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
15 % This restriction helps ensure that all standard styles are identical.
16 % The file btxbst.doc has the documentation for this style.
17 % Please notify Oren Patashnik ([email protected]) of any bugs in
18 % these standard styles or in this documentation file.
19 %
20 % This is file btxbxt.doc; it helps document bibliography styles,
21 % and is also a template file that you can use to make
22 % several different style files, if you have access to a C preprocessor.
23 % For example, the standard styles were made by doing something like
24 % cpp -P -DAPLAIN btxabst.doc aplain.txt
25 % cpp -P -DAUNSRT btxabst.doc aunsrt.txt
26 % cpp -P -DAALPHA btxabst.doc aalpha.txt
27 % cpp -P -DAABBRV btxabst.doc aabbrv.txt
28 % cpp -P -DANOTIT btxabst.doc anotit.txt
29 % cpp -P -DAUNSNOT btxabst.doc aunsnot.txt
30 % and then renaming after removing unwanted comments and blank lines.
31 % If you don't have access,
32 % you can edit this file by hand to imitate the preprocessor,
33 % with the following explanation of the C preprocessor constructs used here.
34 %
35 % The output of the preprocessor is the same as the input, except that certain
36 % lines will be excluded (and some blank lines will be added). The sequence
37 % #if VAR
38 % lines to be included when VAR is not zero
39 % #else
40 % lines to be included when VAR is zero
41 % #endif
42 % (with the #-signs appearing in column 1) means that one set or the other of
43 % the lines are to be included depending on the value of VAR.
44 % The #else part is optional. Comments can be added after #else and #endif.
45 % Variables can be set by
46 % #define VAR value
47 % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
48 % to see if it has none.
49 % Another #if form used in this file is #if !VAR, which includes the lines
50 % after the #if only if VAR is zero.
51 %
52 % Convention: Use all uppercase identifiers for these preprocessor variables
53 % so you can spot them easily
54 %
55 % The command line to the preprocessor should define one of APLAIN, AUNSRT, AALPHA
56 % or AABBRV (though APLAIN will be used by default if none is given),
57 % and the following lines will set various boolean variables to control the
58 % various lines that are chosen from the rest of the file.
59 % Each boolean variable should be set true (1) or false (0) in each style.
60 % Here are the current variables, and their meanings:
61 % LAB_ALPH: an alphabetic label is used (if false then a numeric
62 % label is used)
63 % SORTED: the entries should be sorted by label (if nonnumeric)
64 % and other info, like authors (if false, then
65 % entries remain in order of occurrence)
66 % NAME_FULL: the authors, editors, etc., get the full names as
67 % given in the bibliography file (if false, the first
68 % names become initials)
69 % ATIT_LOWER: titles of non-"books" (e.g., articles) should be
70 % converted to lower-case, except the first letter or
71 % first letter after a colon
72 % (if false then they appear as in the database)
73 % MONTH_FULL: months are spelled out in full (if false, then
74 % they're abbreviated); now used generally for
75 % distinction between ``full'' and ``abbreviated''
76 % styles (H2B)
77 % JOUR_FULL: macro journal names are spelled out in full
78 % (if false then they are abbreviated, currently
79 % as they appear in ACM publications); no more used
80 % (H2B)
81 % NO_TITLE: the titles of articles, incollections, inproceedings
82 % and techreports are omitted, if there are other
83 % informations to identify the work cited (added by H2B)
84 %
85 #ifndef AUNSRT
86 # ifndef AALPHA
87 # ifndef AABBRV
88 # ifndef ANOTIT
89 # ifndef AUNSNOT
90 # define APLAIN 1
91 # endif
92 # endif
93 # endif
94 # endif
95 #endif
96 #ifdef APLAIN
97 % aplain style (sorted numbers)
98 # define LAB_ALPH 0
99 # define SORTED 1
100 # define NAME_FULL 1
101 # define ATIT_LOWER 1
102 # define MONTH_FULL 1
103 # define JOUR_FULL 1
104 # define NO_TITLE 0
105 #endif
106 #ifdef AUNSRT
107 % aunsrt style (unsorted numbers)
108 # define LAB_ALPH 0
109 # define SORTED 0
110 # define NAME_FULL 1
111 # define ATIT_LOWER 1
112 # define MONTH_FULL 1
113 # define JOUR_FULL 1
114 # define NO_TITLE 0
115 #endif
116 #ifdef AALPHA
117 % aalpha style (sorted short alphabetics)
118 # define LAB_ALPH 1
119 # define SORTED 1
120 # define NAME_FULL 1
121 # define ATIT_LOWER 1
122 # define MONTH_FULL 1
123 # define JOUR_FULL 1
124 # define NO_TITLE 0
125 #endif
126 #ifdef AABBRV
127 % aabbrv style (sorted numbers, with abbreviations)
128 # define LAB_ALPH 0
129 # define SORTED 1
130 # define NAME_FULL 0
131 # define ATIT_LOWER 1
132 # define MONTH_FULL 0
133 # define JOUR_FULL 0
134 # define NO_TITLE 0
135 #endif
136 #ifdef ANOTIT
137 % anotit style (sorted numbers, with abbreviations, no article titles)
138 # define LAB_ALPH 0
139 # define SORTED 1
140 # define NAME_FULL 0
141 # define ATIT_LOWER 1
142 # define MONTH_FULL 0
143 # define JOUR_FULL 0
144 # define NO_TITLE 1
145 #endif
146 #ifdef AUNSNOT
147 % aunsnot style (unsorted numbers, with abbreviations, no article titles)
148 # define LAB_ALPH 0
149 # define SORTED 0
150 # define NAME_FULL 0
151 # define ATIT_LOWER 1
152 # define MONTH_FULL 0
153 # define JOUR_FULL 0
154 # define NO_TITLE 1
155 #endif
156 %
157 % Entry formatting: Similar to that recommended by Mary-Claire van Leunen
158 % in "A Handbook for Scholars". Book-like titles are italicized
159 % (emphasized) and non-book titles are converted to sentence
160 % capitilization (and not enclosed in quotes).
161 % This file outputs a \newblock between major blocks of an entry
162 % (the name \newblock is analogous to the names \newline and \newpage)
163 % so that the user can obtain an "open" format, which has a line break
164 % before each block and lines after the first are indented within blocks,
165 % by giving the optional \documentstyle argument `openbib';
166 % The default is the "closed" format---blocks runs together.
167 %
168 % Citation alphabetic label format:
169 % [Knu73] for single author (or editor or key)
170 % [AHU83] (first letters of last names) for multiple authors
171 %
172 % Citation label numberic format:
173 % [number]
174 %
175 % Reference list ordering for sorted, alphabetic lables:
176 % alphabetical by citation label, then by author(s) or whatever
177 % passes for author in the absence of one, then by year,
178 % then title
179 %
180 % Reference list ordering for sorted, numeric lables:
181 % alphabetical by author(s) or whatever passes
182 % for author in the absence of one, then by year, then title
183 %
184 % Reference list ordering for unsorted:
185 % by the order cited in the text
186 %
187 % History
188 % 12/16/84 (HWT) Original `plain' version, by Howard Trickey.
189 % 12/23/84 (LL) Some comments made by Leslie Lamport.
190 % 2/16/85 (OP) Changes based on LL's comments, Oren Patashnik.
191 % 2/17/85 (HWT) Template file and other standard styles made.
192 % 3/28/85 (OP) First release, version 0.98b for BibTeX 0.98f.
193 % 5/ 9/85 (OP) Version 0.98c for BibTeX 0.98i:
194 % fixed Theoretical Computer Science macro name;
195 % fixed the format.vol.num.pages function.
196 % 1/24/88 (OP) Version 0.99a for BibTeX 0.99a, main changes:
197 % assignment operator (:=) arguments reversed;
198 % the preamble$ function outputs the database PREAMBLE;
199 % entry.max$ and global.max$ (built-in) variables replace
200 % entry.string.max and global.string.max functions;
201 % alphabetizing by year then title, not just title;
202 % many unnecessary ties removed; \it ==> \em;
203 % the `alpha' style uses a superscripted `+' instead of a
204 % `*' for unnamed names in constructing the label;
205 % the `abbrv' style now uses "Mar." and "Sept.";
206 % the functions calc.label and presort now look at just
207 % the fields they're supposed to;
208 % BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
209 % INBOOK and INCOLLECTION take an optional type (e.g.
210 % type = "Section"), overriding the default "chapter";
211 % BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
212 % either volume or number, not just volume;
213 % INCOLLECTION now allows an edition and series field;
214 % PROCEEDINGS and INPROCEEDINGS now use the address field
215 % to tell where a conference was held;
216 % INPROCEEDINGS and PROCEEDINGS now allow either volume
217 % or number, and also a series field;
218 % MASTERSTHESIS and PHDTHESIS accept types other than
219 % "Master's thesis" and "PhD thesis";
220 % UNPUBLISHED now outputs, in one block, note then date;
221 % MANUAL now prints out the organization in
222 % the first block if the author field is empty;
223 % MISC can't be empty---it requires some optional field.
224 % 3/23/88 (OP) Version 0.99b for BibTeX 0.99c---changed the three
225 % erroneous occurrences of `cite ' to `cite$ '; this
226 % change didn't affect the four standard styles, so the
227 % 0.99a versions of those styles are still current.
228 % 5/11/91 (H2B) Version 1.00 of the `b' style family by
229 % Hans-Hermann Bode with the following changes and
230 % extensions: renaming the styles, adding a `anotit'
231 % style; adding an output.state named continue.sentence
232 % and a new.clause function; setting author names in
233 % small caps, putting booktitles in quotes rather than
234 % to emphasize them, boldfacing volume numbers of
235 % journals, including date specification in parentheses,
236 % discarding macros for journal names.
237 % 6/15/91 (H2B) Version 1.10 of the `adaptable' style family (which
238 % replaces the `b' style family) with adaptable
239 % type styles, phrases, conjunctions etc., new macros
240 % for edition numbers and ``chapter'' names and a new
241 % `aunsnot' style.
242 %
243 % The ENTRY declaration
244 % Like Scribe's (according to pages 231-2 of the April '84 edition),
245 % but no fullauthor or editors fields because BibTeX does name handling.
246 % The annote field is commented out here because this family doesn't
247 % include an annotated bibliography style. And in addition to the fields
248 % listed here, BibTeX has a built-in crossref field, explained later.
249
250 ENTRY
251 % Fields:
252 { address
253 % Usually the address of a publisher or other type of organization.
254 % Put information in this field only if it helps the reader find the
255 % thing---for example you should omit the address of a major
256 % publisher entirely. For a PROCEEDINGS or an INPROCEEDINGS,
257 % however, it's the address of the conference; for those two entry
258 % types, include the publisher's or organization's address, if
259 % necessary, in the publisher or organization field.
260 % annote
261 % Long annotation---for annotated bibliographies (begins sentence).
262 author
263 % Name(s) of author(s), in BibTeX name format.
264 booktitle
265 % Book title when the thing being referenced isn't the whole book.
266 % For book entries, the title field should be used instead.
267 chapter
268 % Chapter (or section or whatever) number.
269 edition
270 % Edition of a book---should be an ordinal (e.g., "Second").
271 editor
272 % Name(s) of editor(s), in BibTeX name format.
273 % If there is also an author field, then the editor field should be
274 % for the book or collection that the work appears in.
275 howpublished
276 % How something strange has been published (begins sentence).
277 institution
278 % Sponsoring institution of a technical report.
279 journal
280 % Journal name (macros are provided for many).
281 key
282 % Alphabetizing, labeling, and cross-referencing key
283 % (needed when an entry has no author or editor).
284 month
285 % Month (macros are provided).
286 note
287 % To help the reader find a reference (begins sentence).
288 number
289 % Number of a journal or technical report, or of a work in a series.
290 organization
291 % Organization sponsoring a conference (or publishing a manual); if
292 % the editor (or author) is empty, and if the organization produces
293 % an awkward label or cross reference, you should put appropriately
294 % condensed organization information in the key field as well.
295 pages
296 % Page number or numbers (use `--' to separate a range, use `+'
297 % to indicate pages following that don't form a simple range).
298 publisher
299 % Publisher name.
300 school
301 % School name (for theses).
302 series
303 % The name of a series or set of books.
304 % An individual book will will also have it's own title.
305 title
306 % The title of the thing you're referred to.
307 type
308 % Type of a Techreport (e.g., "Research Note") to be used instead of
309 % the default "Technical Report"; or, similarly, the type of a
310 % thesis; or of a part of a book.
311 volume
312 % The volume number of a journal or multivolume work.
313 year
314 % The year should contain only numerals (technically, it should end
315 % with four numerals, after purification; doesn't a begin sentence).
316 }
317 % There are no integer entry variables
318 {}
319 % These string entry variables are used to form the citation label.
320 % In a storage pinch, sort.label can be easily computed on the fly.
321 #if LAB_ALPH
322 #if SORTED
323 { label extra.label sort.label }
324 #else !SORTED
325 % It doesn't seem like a good idea to use an order-of-citation
326 % reference list when using alphabetic labels, but when this happens
327 % we do things a little differently
328 { label }
329 #endif SORTED
330 #else !LAB_ALPH
331 { label }
332 #endif LAB_ALPH
333
334 % The following macros have to be defined by the user (e.g., with the
335 % expansions given below) for formatting of certain fields and to replace the
336 % constant built-in strings for phrases, conjunctions etc. This makes the
337 % BibTeX style files adaptable---a feature introduced by H2B.
338 %
339 % The type style of certain fields is determined by the \abtype command. The
340 % first parameter is a number, that denotes the field in question, namely:
341 % 0 author and editor names,
342 % 1 titles of books and series,
343 % 2 journal titles,
344 % 3 journal volumes,
345 % 4 journal numbers, and
346 % 5 dates.
347 % The second parameter is the text to format. Hence, the type style macro
348 % could be something like:
349 % \def\abtype#1#2{%
350 % \ifcase#1{\sc#2}\or``#2''\or{\em#2\/}\or{\bf#2}\or(#2)\or(#2)\else#2\fi}
351 % The \else clause returns the text unformatted, if the command is called with
352 % an undefined field number (which is not used in this file).
353 %
354 % Phrases are defined by the \abphrase command. The only parameter is a code
355 % for the phrase:
356 % 0 conjunction between two or before the last name of a name list
357 % 1 comes before the last conjunction of a name list
358 % 2 replaces names of co-authors and co-editors (``et al.'')
359 % 3 marks multiple editors
360 % 4 marks a single editor
361 % 5 ``of'' for a volume of a series or crossref
362 % 6 ``in'' for a number in a series
363 % 7 ``In'' for crossrefs to books, articles, etc.
364 % 8 comes before a volume number, lower-case
365 % 9 comes before a volume number, upper-case
366 % 10 comes before a series number, lower-case
367 % 11 comes before a series number, upper-case
368 % 12 comes after an edition number
369 % 13 comes before multiple page numbers
370 % 14 comes before a single page number
371 % 15 comes before a chapter number
372 % 16 denotes a technical report
373 % 17 denotes a master's thesis
374 % 18 denotes a phd thesis
375 % An appropriate definition of the phrases macro would be:
376 % \def\abphrase#1{%
377 % \ifcase#1{ and }\or{,}\or{ et~al.}\or{, editors}\or{, editor}\or%
378 % { of }\or{ in }\or{In }\or{volume}\or{Volume}\or{number}\or{Number}\or%
379 % { edition}\or{pages}\or{page}\or{chapter}\or%
380 % {Technical Report}\or{Master's thesis}\or{PhD thesis}\fi}
381
382 % Each entry function starts by calling output.bibitem, to write the
383 % \bibitem and its arguments to the .BBL file. Then the various fields
384 % are formatted and printed by output or output.check. Those functions
385 % handle the writing of separators (commas, periods, \newblock's),
386 % taking care not to do so when they are passed a null string.
387 % Finally, fin.entry is called to add the final period and finish the
388 % entry.
389 %
390 % A bibliographic reference is formatted into a number of `blocks':
391 % in the open format, a block begins on a new line and subsequent
392 % lines of the block are indented. A block may contain more than
393 % one sentence (well, not a grammatical sentence, but something to
394 % be ended with a sentence ending period). The entry functions should
395 % call new.block whenever a block other than the first is about to be
396 % started. They should call new.sentence whenever a new sentence is
397 % to be started. The output functions will ensure that if two
398 % new.sentence's occur without any non-null string being output between
399 % them then there won't be two periods output. Similarly for two
400 % successive new.block's.
401 %
402 % The output routines don't write their argument immediately.
403 % Instead, by convention, that argument is saved on the stack to be
404 % output next time (when we'll know what separator needs to come
405 % after it). Meanwhile, the output routine has to pop the pending
406 % output off the stack, append any needed separator, and write it.
407 %
408 % To tell which separator is needed, we maintain an output.state.
409 % It will be one of these values:
410 % before.all just after the \bibitem
411 % continue.sentence in the middle of a sentence: blank---no
412 % comma---needed if more sentence is
413 % output (value added by H2B)
414 % mid.sentence in the middle of a sentence: comma needed
415 % if more sentence is output
416 % after.sentence just after a sentence: period needed
417 % after.block just after a block (and sentence):
418 % period and \newblock needed.
419 % Note: These styles don't use after.sentence.
420 % This note doesn't apply really (H2B).
421 %
422 % VAR: output.state : INTEGER -- state variable for output
423 %
424 % The output.nonnull function saves its argument (assumed to be nonnull)
425 % on the stack, and writes the old saved value followed by any needed
426 % separator. The ordering of the tests is decreasing frequency of
427 % occurrence.
428 %
429 % output.nonnull(s) ==
430 % BEGIN
431 % s := argument on stack
432 % if output.state = continue.sentence then -- added by H2B
433 % write$(pop() * " ") -- dto.
434 % -- "pop" isn't a function: just use stack top
435 % else
436 % if output.state = mid.sentence then
437 % write$(pop() * ", ")
438 % else
439 % if output.state = after.block then
440 % write$(add.period$(pop()))
441 % newline$
442 % write$("\newblock ")
443 % else
444 % if output.state = before.all then
445 % write$(pop())
446 % else -- output.state should be after.sentence
447 % write$(add.period$(pop()) * " ")
448 % fi
449 % fi
450 % fi
451 % output.state := continue.sentence
452 % fi
453 % push s on stack
454 % END
455 %
456 % The output function calls output.nonnull if its argument is non-empty;
457 % its argument may be a missing field (thus, not necessarily a string)
458 %
459 % output(s) ==
460 % BEGIN
461 % if not empty$(s) then output.nonnull(s)
462 % fi
463 % END
464 %
465 % The output.check function is the same as the output function except that, if
466 % necessary, output.check warns the user that the t field shouldn't be empty
467 % (this is because it probably won't be a good reference without the field;
468 % the entry functions try to make the formatting look reasonable even when
469 % such fields are empty).
470 %
471 % output.check(s,t) ==
472 % BEGIN
473 % if empty$(s) then
474 % warning$("empty " * t * " in " * cite$)
475 % else output.nonnull(s)
476 % fi
477 % END
478 %
479 % The output.bibitem function writes the \bibitem for the current entry
480 % (the label should already have been set up), and sets up the separator
481 % state for the output functions. And, it leaves a string on the stack
482 % as per the output convention.
483 %
484 % output.bibitem ==
485 % BEGIN
486 % newline$
487 % write$("\bibitem[") % for alphabetic labels,
488 % write$(label) % these three lines
489 % write$("]{") % are used
490 % write$("\bibitem{") % this line for numeric labels
491 % write$(cite$)
492 % write$("}")
493 % push "" on stack
494 % output.state := before.all
495 % END
496 %
497 % The fin.entry function finishes off an entry by adding a period to the
498 % string remaining on the stack. If the state is still before.all
499 % then nothing was produced for this entry, so the result will look bad,
500 % but the user deserves it. (We don't omit the whole entry because the
501 % entry was cited, and a bibitem is needed to define the citation label.)
502 %
503 % fin.entry ==
504 % BEGIN
505 % write$(add.period$(pop()))
506 % newline$
507 % END
508 %
509 % The new.block function prepares for a new block to be output, and
510 % new.sentence prepares for a new sentence.
511 % Added by H2B was new.clause, that prepares for a new subordinate clause.
512 %
513 % new.block ==
514 % BEGIN
515 % if output.state <> before.all then
516 % output.state := after.block
517 % fi
518 % END
519 %
520 % new.sentence ==
521 % BEGIN
522 % if output.state <> after.block then
523 % if output.state <> before.all then
524 % output.state := after.sentence
525 % fi
526 % fi
527 % END
528 %
529 % new.clause ==
530 % BEGIN
531 % if output.state <> after.sentence then
532 % if output.state <> after.block then
533 % if output.state <> before.all then
534 % output.state := mid.sentence
535 % fi
536 % fi
537 % fi
538 % END
539 %
540
541 INTEGERS { output.state before.all mid.sentence after.sentence after.block
542 continue.sentence }
543
544 FUNCTION {init.state.consts}
545 { #0 'before.all :=
546 #1 'mid.sentence :=
547 #2 'after.sentence :=
548 #3 'after.block :=
549 #4 'continue.sentence :=
550 }
551
552 % the variables s and t are temporary string holders
553
554 STRINGS { s t }
555
556 FUNCTION {output.nonnull}
557 { 's :=
558 output.state continue.sentence =
559 { " " * write$ }
560 { output.state mid.sentence =
561 { ", " * write$ }
562 { output.state after.block =
563 { add.period$ write$
564 newline$
565 "\newblock " write$
566 }
567 { output.state before.all =
568 'write$
569 { add.period$ " " * write$ }
570 if$
571 }
572 if$
573 }
574 if$
575 continue.sentence 'output.state :=
576 }
577 if$
578 s
579 }
580
581 FUNCTION {output}
582 { duplicate$ empty$
583 'pop$
584 'output.nonnull
585 if$
586 }
587
588 FUNCTION {output.check}
589 { 't :=
590 duplicate$ empty$
591 { pop$ "empty " t * " in " * cite$ * warning$ }
592 'output.nonnull
593 if$
594 }
595
596 FUNCTION {output.bibitem}
597 { newline$
598 #if LAB_ALPH
599 "\bibitem[" write$
600 label write$
601 "]{" write$
602 #else
603 "\bibitem{" write$
604 #endif LAB_ALPH
605 cite$ write$
606 "}" write$
607 newline$
608 ""
609 before.all 'output.state :=
610 }
611
612 % This function finishes all entries.
613
614 FUNCTION {fin.entry}
615 { add.period$
616 write$
617 newline$
618 }
619
620 FUNCTION {new.block}
621 { output.state before.all =
622 'skip$
623 { after.block 'output.state := }
624 if$
625 }
626
627 FUNCTION {new.sentence}
628 { output.state after.block =
629 'skip$
630 { output.state before.all =
631 'skip$
632 { after.sentence 'output.state := }
633 if$
634 }
635 if$
636 }
637
638 FUNCTION {new.clause}
639 { output.state after.sentence =
640 'skip$
641 { output.state after.block =
642 'skip$
643 { output.state before.all =
644 'skip$
645 { mid.sentence 'output.state := }
646 if$
647 }
648 if$
649 }
650 if$
651 }
652
653 % These three functions pop one or two (integer) arguments from the stack
654 % and push a single one, either 0 or 1.
655 % The 'skip$ in the `and' and `or' functions are used because
656 % the corresponding if$ would be idempotent
657
658 FUNCTION {not}
659 { { #0 }
660 { #1 }
661 if$
662 }
663
664 FUNCTION {and}
665 { 'skip$
666 { pop$ #0 }
667 if$
668 }
669
670 FUNCTION {or}
671 { { pop$ #1 }
672 'skip$
673 if$
674 }
675
676 % Sometimes we begin a new block only if the block will be big enough. The
677 % new.block.checka function issues a new.block if its argument is nonempty;
678 % new.block.checkb does the same if either of its TWO arguments is nonempty.
679
680 FUNCTION {new.block.checka}
681 { empty$
682 'skip$
683 'new.block
684 if$
685 }
686
687 FUNCTION {new.block.checkb}
688 { empty$
689 swap$ empty$
690 and
691 'skip$
692 'new.block
693 if$
694 }
695
696 % The new.sentence.check functions are analogous.
697
698 FUNCTION {new.sentence.checka}
699 { empty$
700 'skip$
701 'new.sentence
702 if$
703 }
704
705 FUNCTION {new.sentence.checkb}
706 { empty$
707 swap$ empty$
708 and
709 'skip$
710 'new.sentence
711 if$
712 }
713
714 % And the new.clause.check functions, which were added by H2B, also.
715
716 FUNCTION {new.clause.checka}
717 { empty$
718 'skip$
719 'new.clause
720 if$
721 }
722
723 FUNCTION {new.clause.checkb}
724 { empty$
725 swap$ empty$
726 and
727 'skip$
728 'new.clause
729 if$
730 }
731
732 % Here are some functions for formatting chunks of an entry.
733 % By convention they either produce a string that can be followed by
734 % a comma or period (using add.period$, so it is OK to end in a period),
735 % or they produce the null string.
736 %
737 % A useful utility is the field.or.null function, which checks if the
738 % argument is the result of pushing a `missing' field (one for which no
739 % assignment was made when the current entry was read in from the database)
740 % or the result of pushing a string having no non-white-space characters.
741 % It returns the null string if so, otherwise it returns the field string.
742 % Its main (but not only) purpose is to guarantee that what's left on the
743 % stack is a string rather than a missing field.
744 %
745 % field.or.null(s) ==
746 % BEGIN
747 % if empty$(s) then return ""
748 % else return s
749 % END
750 %
751 % Another helper function is emphasize, which returns the argument emphazised,
752 % if that is non-empty, otherwise it returns the null string. Italic
753 % corrections aren't used, so this function should be used when punctation
754 % will follow the result. In contrast to the last sentence, now italic
755 % corrections are always used (H2B).
756 %
757 % emphasize(s) ==
758 % BEGIN
759 % if empty$(s) then return ""
760 % else return "{\em " * s * "\/}"
761 % END
762 %
763 % Similar to emphasize is capitalize, from which the argument comes out in
764 % small caps. This function was added by H2B.
765 %
766 % capitalize(s) ==
767 % BEGIN
768 % if empty$(s) then return ""
769 % else return "{\sc " * s * "}"
770 % END
771 %
772 % And here is another such function---added by H2B---, that returns a boldface
773 % string.
774 %
775 % boldface(s) ==
776 % BEGIN
777 % if empty$(s) then return ""
778 % else return "{\bf " * s * "}"
779 % END
780 %
781 % The function quote will put its argument string in quotes (added by H2B).
782 %
783 % quote(s) ==
784 % BEGIN
785 % if empty$(s) then return ""
786 % else return "``" * s * "''"
787 % END
788 %
789 % And parentheses includes it in parentheses (added by H2B).
790 %
791 % parentheses(s) ==
792 % BEGIN
793 % if empty$(s) then return ""
794 % else return "(" * s * ")"
795 % END
796 %
797 % The format.names function formats the argument (which should be in
798 % BibTeX name format) into "First Von Last, Junior", separated by commas
799 % and with an "and" before the last (but ending with "et~al." if the last
800 % of multiple authors is "others"). This function's argument should always
801 % contain at least one name.
802 %
803 % VAR: nameptr, namesleft, numnames: INTEGER
804 % pseudoVAR: nameresult: STRING (it's what's accumulated on the stack)
805 %
806 % format.names(s) ==
807 % BEGIN
808 % nameptr := 1
809 % numnames := num.names$(s)
810 % namesleft := numnames
811 % while namesleft > 0
812 % do
813 % % for full names:
814 % t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
815 % % for abbreviated first names:
816 % t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
817 % if nameptr > 1 then
818 % if namesleft > 1 then nameresult := nameresult * ", " * t
819 % else if numnames > 2
820 % then nameresult := nameresult * ","
821 % fi
822 % if t = "others"
823 % then nameresult := nameresult * " et~al."
824 % else nameresult := nameresult * " and " * t
825 % fi
826 % fi
827 % else nameresult := t
828 % fi
829 % nameptr := nameptr + 1
830 % namesleft := namesleft - 1
831 % od
832 % return nameresult
833 % END
834 %
835 % The format.authors function returns the result of format.names(author)
836 % if the author is present, or else it returns the null string.
837 % Capitalization of names added by H2B.
838 %
839 % format.authors ==
840 % BEGIN
841 % if empty$(author) then return ""
842 % else return capitalize(format.names(author))
843 % fi
844 % END
845 %
846 % Format.editors is like format.authors, but it uses the editor field,
847 % and appends ", editor" or ", editors".
848 % Capitalization of names added by H2B.
849 %
850 % format.editors ==
851 % BEGIN
852 % if empty$(editor) then return ""
853 % else
854 % if num.names$(editor) > 1 then
855 % return capitalize(format.names(editor)) * ", editors"
856 % else
857 % return capitalize(format.names(editor)) * ", editor"
858 % fi
859 % fi
860 % END
861 %
862 % Other formatting functions are similar, so no "comment version" will be
863 % given for them.
864 %
865 % The `pop$' in this function gets rid of the duplicate `empty' value and
866 % the `skip$' returns the duplicate field value
867
868 FUNCTION {field.or.null}
869 { duplicate$ empty$
870 { pop$ "" }
871 'skip$
872 if$
873 }
874
875 FUNCTION {emphasize}
876 { duplicate$ empty$
877 { pop$ "" }
878 { "\abtype{2}{" swap$ * "}" * } %H2B
879 if$
880 }
881
882 FUNCTION {capitalize}
883 { duplicate$ empty$
884 { pop$ "" }
885 { "\abtype{0}{" swap$ * "}" * } %H2B
886 if$
887 }
888
889 FUNCTION {boldface}
890 { duplicate$ empty$
891 { pop$ "" }
892 { "\abtype{3}{" swap$ * "}" * } %H2B
893 if$
894 }
895
896 FUNCTION {quote}
897 { duplicate$ empty$
898 { pop$ "" }
899 { "\abtype{1}{" swap$ * "}" * } %H2B
900 if$
901 }
902
903 FUNCTION {parentheses}
904 { duplicate$ empty$
905 { pop$ "" }
906 { "\abtype{5}{" swap$ * "}" * } %H2B
907 if$
908 }
909
910 INTEGERS { nameptr namesleft numnames }
911
912 FUNCTION {format.names}
913 { 's :=
914 #1 'nameptr :=
915 s num.names$ 'numnames :=
916 numnames 'namesleft :=
917 { namesleft #0 > }
918 #if NAME_FULL
919 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
920 #else
921 { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
922 #endif NAME_FULL
923 nameptr #1 >
924 { namesleft #1 >
925 { ", " * t * }
926 { numnames #2 >
927 { "\abphrase{1}" * } %H2B
928 'skip$
929 if$
930 t "others" =
931 { "\abphrase{2}" * } %H2B
932 { "\abphrase{0}" * t * } %H2B
933 if$
934 }
935 if$
936 }
937 't
938 if$
939 nameptr #1 + 'nameptr :=
940 namesleft #1 - 'namesleft :=
941 }
942 while$
943 }
944
945 FUNCTION {format.authors}
946 { author empty$
947 { "" }
948 { author format.names capitalize }
949 if$
950 }
951
952 FUNCTION {format.editors}
953 { editor empty$
954 { "" }
955 { editor format.names capitalize
956 editor num.names$ #1 >
957 { "\abphrase{3}" * } %H2B
958 { "\abphrase{4}" * } %H2B
959 if$
960 }
961 if$
962 }
963
964 % The format.title function is used for non-book-like titles.
965 % For most styles we convert to lowercase (except for the very first letter,
966 % and except for the first one after a colon (followed by whitespace)),
967 % and hope the user has brace-surrounded words that need to stay capitilized;
968 % for some styles, however, we leave it as it is in the database.
969
970 FUNCTION {format.title}
971 { title empty$
972 { "" }
973 #if ATIT_LOWER
974 { title "t" change.case$ }
975 #else
976 'title
977 #endif ATIT_LOWER
978 if$
979 }
980
981 % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
982 % constant glob_str_size, the maximum length of a global string variable.
983 % Analogously, BibTeX sets the global integer variable entry.max$ to
984 % ent_str_size, the maximum length of an entry string variable.
985 % The style designer may change these if necessary (but this is unlikely)
986
987 % The n.dashify function makes each single `-' in a string a double `--'
988 % if it's not already
989 %
990 % pseudoVAR: pageresult: STRING (it's what's accumulated on the stack)
991 %
992 % n.dashify(s) ==
993 % BEGIN
994 % t := s
995 % pageresult := ""
996 % while (not empty$(t))
997 % do
998 % if (first character of t = "-")
999 % then
1000 % if (next character isn't)
1001 % then
1002 % pageresult := pageresult * "--"
1003 % t := t with the "-" removed
1004 % else
1005 % while (first character of t = "-")
1006 % do
1007 % pageresult := pageresult * "-"
1008 % t := t with the "-" removed
1009 % od
1010 % fi
1011 % else
1012 % pageresult := pageresult * the first character
1013 % t := t with the first character removed
1014 % fi
1015 % od
1016 % return pageresult
1017 % END
1018
1019 FUNCTION {n.dashify}
1020 { 't :=
1021 ""
1022 { t empty$ not }
1023 { t #1 #1 substring$ "-" =
1024 { t #1 #2 substring$ "--" = not
1025 { "--" *
1026 t #2 global.max$ substring$ 't :=
1027 }
1028 { { t #1 #1 substring$ "-" = }
1029 { "-" *
1030 t #2 global.max$ substring$ 't :=
1031 }
1032 while$
1033 }
1034 if$
1035 }
1036 { t #1 #1 substring$ *
1037 t #2 global.max$ substring$ 't :=
1038 }
1039 if$
1040 }
1041 while$
1042 }
1043
1044 % The format.date function is for the month and year, but we give a warning if
1045 % there's an empty year but the month is there, and we return the empty string
1046 % if they're both empty.
1047 % The resulting string is enclosed in parentheses (H2B).
1048
1049 FUNCTION {format.date}
1050 { year empty$
1051 { month empty$
1052 { "" }
1053 { "there's a month but no year in " cite$ * warning$
1054 month parentheses
1055 }
1056 if$
1057 }
1058 { month empty$
1059 { year parentheses }
1060 { month " " * year * parentheses }
1061 if$
1062 }
1063 if$
1064 }
1065
1066 % The format.btitle is for formatting the title field when it is a book-like
1067 % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
1068 % The emphasis will be done by quotation marks (H2B).
1069
1070 FUNCTION {format.btitle}
1071 { title quote
1072 }
1073
1074 % For several functions we'll need to connect two strings with a
1075 % tie (~) if the second one isn't very long (fewer than 3 characters).
1076 % The tie.or.space.connect function does that. It concatenates the two
1077 % strings on top of the stack, along with either a tie or space between
1078 % them, and puts this concatenation back onto the stack:
1079 %
1080 % tie.or.space.connect(str1,str2) ==
1081 % BEGIN
1082 % if text.length$(str2) < 3
1083 % then return the concatenation of str1, "~", and str2
1084 % else return the concatenation of str1, " ", and str2
1085 % END
1086
1087 FUNCTION {tie.or.space.connect}
1088 { duplicate$ text.length$ #3 <
1089 { "~" }
1090 { " " }
1091 if$
1092 swap$ * *
1093 }
1094
1095 % The either.or.check function complains if both fields or an either-or pair
1096 % are nonempty.
1097 %
1098 % either.or.check(t,s) ==
1099 % BEGIN
1100 % if empty$(s) then
1101 % warning$(can't use both " * t * " fields in " * cite$)
1102 % fi
1103 % END
1104
1105 FUNCTION {either.or.check}
1106 { empty$
1107 'pop$
1108 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
1109 if$
1110 }
1111
1112 % The format.bvolume function is for formatting the volume and perhaps
1113 % series name of a multivolume work. If both a volume and a series field
1114 % are there, we assume the series field is the title of the whole multivolume
1115 % work (the title field should be the title of the thing being referred to),
1116 % and we add an "of <series>". This function is called in mid-sentence.
1117 % The emphasis will be done by quotation marks (H2B).
1118
1119 FUNCTION {format.bvolume}
1120 { volume empty$
1121 { "" }
1122 { "\abphrase{8}" volume tie.or.space.connect %H2B
1123 series empty$
1124 'skip$
1125 { "\abphrase{5}" * series quote * } %H2B
1126 if$
1127 "volume and number" number either.or.check
1128 }
1129 if$
1130 }
1131
1132 % The format.number.series function is for formatting the series name
1133 % and perhaps number of a work in a series. This function is similar to
1134 % format.bvolume, although for this one the series must exist (and the
1135 % volume must not exist). If the number field is empty we output either
1136 % the series field unchanged if it exists or else the null string.
1137 % If both the number and series fields are there we assume the series field
1138 % gives the name of the whole series (the title field should be the title
1139 % of the work being one referred to), and we add an "in <series>".
1140 % We capitilize Number when this function is used at the beginning of a block.
1141 % The latter applies if output.state is mid.sentence or continue.sentence
1142 % (H2B).
1143
1144 FUNCTION {format.number.series}
1145 { volume empty$
1146 { number empty$
1147 { series field.or.null }
1148 { output.state mid.sentence = output.state continue.sentence = or
1149 { "\abphrase{10}" } %H2B
1150 { "\abphrase{11}" } %H2B
1151 if$
1152 number tie.or.space.connect
1153 series empty$
1154 { "there's a number but no series in " cite$ * warning$ }
1155 { "\abphrase{6}" * series * } %H2B
1156 if$
1157 }
1158 if$
1159 }
1160 { "" }
1161 if$
1162 }
1163
1164 % The format.edition function appends " edition" to the edition, if present.
1165 % We lowercase the edition (it should be something like "Third"), because
1166 % this doesn't start a sentence.
1167 % The latter applies if output.state is mid.sentence or continue.sentence
1168 % (H2B).
1169
1170 FUNCTION {format.edition}
1171 { edition empty$
1172 { "" }
1173 { output.state mid.sentence = output.state continue.sentence = or
1174 { edition "l" change.case$ "\abphrase{12}" * } %H2B
1175 { edition "t" change.case$ "\abphrase{12}" * } %H2B
1176 if$
1177 }
1178 if$
1179 }
1180
1181 % The format.pages function is used for formatting a page range in a book
1182 % (and in rare circumstances, an article).
1183 %
1184 % The multi.page.check function examines the page field for a "-" or "," or "+"
1185 % so that format.pages can use "page" instead of "pages" if none exists.
1186 % Note: global.max$ here means "take the rest of the string"
1187 %
1188 % VAR: multiresult: INTEGER (actually, a boolean)
1189 %
1190 % multi.page.check(s) ==
1191 % BEGIN
1192 % t := s
1193 % multiresult := false
1194 % while ((not multiresult) and (not empty$(t)))
1195 % do
1196 % if (first character of t = "-" or "," or "+")
1197 % then multiresult := true
1198 % else t := t with the first character removed
1199 % fi
1200 % od
1201 % return multiresult
1202 % END
1203
1204 INTEGERS { multiresult }
1205
1206 FUNCTION {multi.page.check}
1207 { 't :=
1208 #0 'multiresult :=
1209 { multiresult not
1210 t empty$ not
1211 and
1212 }
1213 { t #1 #1 substring$
1214 duplicate$ "-" =
1215 swap$ duplicate$ "," =
1216 swap$ "+" =
1217 or or
1218 { #1 'multiresult := }
1219 { t #2 global.max$ substring$ 't := }
1220 if$
1221 }
1222 while$
1223 multiresult
1224 }
1225
1226 % This function doesn't begin a sentence so "pages" isn't capitalized.
1227 % Other functions that use this should keep that in mind.
1228
1229 FUNCTION {format.pages}
1230 { pages empty$
1231 { "" }
1232 { pages multi.page.check
1233 { "\abphrase{13}" pages n.dashify tie.or.space.connect } %H2B
1234 { "\abphrase{14}" pages tie.or.space.connect } %H2B
1235 if$
1236 }
1237 if$
1238 }
1239
1240 % The format.vol.num.pages function is for the volume, number, and page range
1241 % of a journal article. We use the format: vol(number):pages, with some
1242 % variations for empty fields. This doesn't begin a sentence.
1243 % The format was changed to `vol(number), pages', where the `vol' comes out in
1244 % boldface, by H2B.
1245
1246 FUNCTION {format.vol.num.pages}
1247 { volume field.or.null boldface
1248 number empty$
1249 'skip$
1250 { "\abtype{4}{" number * "}" * * %H2B
1251 volume empty$
1252 { "there's a number but no volume in " cite$ * warning$ }
1253 'skip$
1254 if$
1255 }
1256 if$
1257 pages empty$
1258 'skip$
1259 { duplicate$ empty$
1260 { pop$ format.pages }
1261 { ", " * pages n.dashify * }
1262 if$
1263 }
1264 if$
1265 }
1266
1267
1268 % The format.chapter.pages, if the chapter is present, puts whatever is in the
1269 % type field (or else "chapter" if type is empty) in front of a chapter number.
1270 % It then appends the pages, if present. This doesn't begin a sentence.
1271
1272 FUNCTION {format.chapter.pages}
1273 { chapter empty$
1274 'format.pages
1275 { type empty$
1276 { "\abphrase{15}" } %H2B
1277 { type "l" change.case$ }
1278 if$
1279 chapter tie.or.space.connect
1280 pages empty$
1281 'skip$
1282 { ", " * format.pages * }
1283 if$
1284 }
1285 if$
1286 }
1287
1288 % The format.in.ed.booktitle function is used for starting out a sentence
1289 % that begins "In <booktitle>", putting an editor before the title if one
1290 % exists.
1291 % The emphasis will be done by quotation marks (H2B).
1292
1293 FUNCTION {format.in.ed.booktitle}
1294 { booktitle empty$
1295 { "" }
1296 { editor empty$
1297 { "\abphrase{7}" booktitle quote * } %H2B
1298 { "\abphrase{7}" format.editors * ", " * booktitle quote * } %H2B
1299 if$
1300 }
1301 if$
1302 }
1303
1304 % The function empty.misc.check complains if all six fields are empty, and
1305 % if there's been no sorting or alphabetic-label complaint.
1306
1307 FUNCTION {empty.misc.check}
1308 { author empty$ title empty$ howpublished empty$
1309 month empty$ year empty$ note empty$
1310 and and and and and
1311 #if SORTED
1312 key empty$ not and
1313 #else !SORTED
1314 #if LAB_ALPH
1315 key empty$ not and
1316 #endif LAB_ALPH
1317 #endif SORTED
1318 { "all relevant fields are empty in " cite$ * warning$ }
1319 'skip$
1320 if$
1321 }
1322
1323 % The function format.thesis.type returns either the (case-changed) type field,
1324 % if it is defined, or else the default string already on the stack
1325 % (like "Master's thesis" or "PhD thesis").
1326
1327 FUNCTION {format.thesis.type}
1328 { type empty$
1329 'skip$
1330 { pop$
1331 type "t" change.case$
1332 }
1333 if$
1334 }
1335
1336 % The function format.tr.number makes a string starting with "Technical Report"
1337 % (or type, if that field is defined), followed by the number if there is one;
1338 % it returns the starting part (with a case change) even if there is no number.
1339 % This is used at the beginning of a sentence.
1340
1341 FUNCTION {format.tr.number}
1342 { type empty$
1343 { "\abphrase{16}" } %H2B
1344 'type
1345 if$
1346 number empty$
1347 { "t" change.case$ }
1348 { number tie.or.space.connect }
1349 if$
1350 }
1351
1352 % Now come the cross-referencing functions (these are invoked because
1353 % one entry in the database file(s) cross-references another, by giving
1354 % the other entry's database key in a `crossref' field). This feature
1355 % allows one or more titled things that are part of a larger titled
1356 % thing to cross-reference the larger thing. These styles allow for
1357 % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
1358 % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
1359 % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
1360 % Each of these is explained in more detail later.
1361 %
1362 % An ARTICLE entry type may cross reference another ARTICLE (this is
1363 % intended for when an entire journal is devoted to a single topic---
1364 % but since there is no JOURNAL entry type, the journal, too, should be
1365 % classified as an ARTICLE but without the author and title fields).
1366 % This will result in two warning messages for the journal's entry
1367 % if it's included in the reference list, but such is life.
1368 % In the original true function the emphasis with italic correction had been
1369 % made by inserting the necessary TeX control sequences directly; this is
1370 % substituted by a call to emphasize (H2B).
1371 %
1372 % format.article.crossref ==
1373 % BEGIN
1374 % if empty$(key) then
1375 % if empty$(journal) then
1376 % warning$("need key or journal for " * cite$ *
1377 % " to crossref " * crossref)
1378 % return(" \cite{" * crossref * "}")
1379 % else
1380 % return("In " * emphazise.correct (journal) *
1381 % " \cite{" * crossref * "}")
1382 % fi
1383 % else
1384 % return("In " * key * " \cite{" * crossref * "}")
1385 % fi
1386 % END
1387 %
1388 % The other cross-referencing functions are similar, so no "comment version"
1389 % will be given for them.
1390
1391 FUNCTION {format.article.crossref}
1392 { key empty$
1393 { journal empty$
1394 { "need key or journal for " cite$ * " to crossref " * crossref *
1395 warning$
1396 ""
1397 }
1398 { "\abphrase{7}" journal emphasize * } %H2B
1399 if$
1400 }
1401 { "\abphrase{7}" key * } %H2B
1402 if$
1403 " \cite{" * crossref * "}" *
1404 }
1405
1406 % We use just the last names of editors for a cross reference: either
1407 % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
1408 % whether there are one, or two, or more than two editors.
1409
1410 FUNCTION {format.crossref.editor}
1411 { editor #1 "{vv~}{ll}" format.name$
1412 editor num.names$ duplicate$
1413 #2 >
1414 { pop$ "\abphrase{2}" * } %H2B
1415 { #2 <
1416 'skip$
1417 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1418 { "\abphrase{2}" * } %H2B
1419 { "\abphrase{0}" * editor #2 "{vv~}{ll}" format.name$ * } %H2B
1420 if$
1421 }
1422 if$
1423 }
1424 if$
1425 }
1426
1427 % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
1428 % multivolume work) may cross reference another BOOK (the entire multivolume).
1429 % Usually there will be an editor, in which case we use that to construct the
1430 % cross reference; otherwise we use a nonempty key field or else the series
1431 % field (since the series gives the title of the multivolume work).
1432 % The series title is enclosed in quotes rather than emphasized (H2B).
1433
1434 FUNCTION {format.book.crossref}
1435 { volume empty$
1436 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
1437 "\abphrase{7}" %H2B
1438 }
1439 { "\abphrase{9}" volume tie.or.space.connect %H2B
1440 "\abphrase{5}" * %H2B
1441 }
1442 if$
1443 editor empty$
1444 editor field.or.null author field.or.null =
1445 or
1446 { key empty$
1447 { series empty$
1448 { "need editor, key, or series for " cite$ * " to crossref " *
1449 crossref * warning$
1450 "" *
1451 }
1452 { series quote * }
1453 if$
1454 }
1455 { key * }
1456 if$
1457 }
1458 { format.crossref.editor * }
1459 if$
1460 " \cite{" * crossref * "}" *
1461 }
1462
1463 % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
1464 % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
1465 % Often there will be an editor, in which case we use that to construct
1466 % the cross reference; otherwise we use a nonempty key field or else
1467 % the booktitle field (which gives the cross-referenced work's title).
1468 % The booktitle is enclosed in quotes rather than emphasized (H2B).
1469
1470 FUNCTION {format.incoll.inproc.crossref}
1471 { editor empty$
1472 editor field.or.null author field.or.null =
1473 or
1474 { key empty$
1475 { booktitle empty$
1476 { "need editor, key, or booktitle for " cite$ * " to crossref " *
1477 crossref * warning$
1478 ""
1479 }
1480 { "\abphrase{7}" booktitle quote * } %H2B
1481 if$
1482 }
1483 { "\abphrase{7}" key * } %H2B
1484 if$
1485 }
1486 { "\abphrase{7}" format.crossref.editor * } %H2B
1487 if$
1488 " \cite{" * crossref * "}" *
1489 }
1490
1491 % Now we define the type functions for all entry types that may appear
1492 % in the .BIB file---e.g., functions like `article' and `book'. These
1493 % are the routines that actually generate the .BBL-file output for
1494 % the entry. These must all precede the READ command. In addition, the
1495 % style designer should have a function `default.type' for unknown types.
1496 % Note: The fields (within each list) are listed in order of appearance,
1497 % except as described for an `inbook' or a `proceedings'.
1498 %
1499 % The article function is for an article in a journal. An article may
1500 % CROSSREF another article.
1501 % Required fields: author, title, journal, year
1502 % Optional fields: volume, number, pages, month, note
1503 %
1504 % article ==
1505 % BEGIN
1506 % output.bibitem
1507 % output.check(format.authors,"author")
1508 % new.block
1509 % output.check(format.title,"title") % omitted if NO_TITLE (H2B)
1510 % new.block % dto.
1511 % if missing$(crossref) then
1512 % output.check(emphasize(journal),"journal")
1513 % % italic correction added (H2B)
1514 % output(format.vol.num.pages)
1515 % output.check(format.date,"year")
1516 % else
1517 % output.nonnull(format.article.crossref)
1518 % new.clause % added by H2B
1519 % output(format.pages)
1520 % fi
1521 % new.block
1522 % output(note)
1523 % fin.entry
1524 % END
1525 %
1526 % The book function is for a whole book. A book may CROSSREF another book.
1527 % Required fields: author or editor, title, publisher, year
1528 % Optional fields: volume or number, series, address, edition, month,
1529 % note
1530 %
1531 % book ==
1532 % BEGIN
1533 % if empty$(author) then output.check(format.editors,"author and editor")
1534 % else output.check(format.authors,"author")
1535 % if missing$(crossref) then
1536 % either.or.check("author and editor",editor)
1537 % fi
1538 % fi
1539 % new.block
1540 % output.check(format.btitle,"title")
1541 % if missing$(crossref) then
1542 % new.clause % added by H2B
1543 % output(format.bvolume)
1544 % new.block
1545 % output(format.number.series)
1546 % new.sentence
1547 % output.check(publisher,"publisher")
1548 % new.clause.checka(address) % added by H2B
1549 % output(address)
1550 % else
1551 % new.block
1552 % output.nonnull(format.book.crossref)
1553 % fi
1554 % edition new.clause.checka % added by H2B
1555 % output(format.edition)
1556 % output.check(format.date,"year")
1557 % new.block
1558 % output(note)
1559 % fin.entry
1560 % END
1561 %
1562 % The other entry functions are all quite similar, so no "comment version"
1563 % will be given for them.
1564
1565 FUNCTION {article}
1566 { output.bibitem
1567 format.authors "author" output.check
1568 new.block
1569 #if !NO_TITLE
1570 format.title "title" output.check
1571 new.block
1572 #endif
1573 crossref missing$
1574 { journal emphasize "journal" output.check
1575 format.vol.num.pages output
1576 format.date "year" output.check
1577 }
1578 { format.article.crossref output.nonnull
1579 new.clause
1580 format.pages output
1581 }
1582 if$
1583 new.block
1584 note output
1585 fin.entry
1586 }
1587
1588 FUNCTION {book}
1589 { output.bibitem
1590 author empty$
1591 { format.editors "author and editor" output.check }
1592 { format.authors output.nonnull
1593 crossref missing$
1594 { "author and editor" editor either.or.check }
1595 'skip$
1596 if$
1597 }
1598 if$
1599 new.block
1600 format.btitle "title" output.check
1601 crossref missing$
1602 { new.clause
1603 format.bvolume output
1604 new.block
1605 format.number.series output
1606 new.sentence
1607 publisher "publisher" output.check
1608 address new.clause.checka
1609 address output
1610 }
1611 { new.block
1612 format.book.crossref output.nonnull
1613 }
1614 if$
1615 edition new.clause.checka
1616 format.edition output
1617 format.date "year" output.check
1618 new.block
1619 note output
1620 fin.entry
1621 }
1622
1623 % A booklet is a bound thing without a publisher or sponsoring institution.
1624 % Required: title
1625 % Optional: author, howpublished, address, month, year, note
1626
1627 FUNCTION {booklet}
1628 { output.bibitem
1629 format.authors output
1630 new.block
1631 format.title "title" output.check
1632 howpublished address new.block.checkb
1633 howpublished output
1634 address new.clause.checka
1635 address output
1636 format.date output
1637 new.block
1638 note output
1639 fin.entry
1640 }
1641
1642 % For the conference entry type, see inproceedings.
1643
1644 % An inbook is a piece of a book: either a chapter and/or a page range.
1645 % It may CROSSREF a book. If there's no volume field, the type field
1646 % will come before number and series.
1647 % Required: author or editor, title, chapter and/or pages, publisher,year
1648 % Optional: volume or number, series, type, address, edition, month, note
1649
1650 FUNCTION {inbook}
1651 { output.bibitem
1652 author empty$
1653 { format.editors "author and editor" output.check }
1654 { format.authors output.nonnull
1655 crossref missing$
1656 { "author and editor" editor either.or.check }
1657 'skip$
1658 if$
1659 }
1660 if$
1661 new.block
1662 format.btitle "title" output.check
1663 new.clause
1664 crossref missing$
1665 { format.bvolume output
1666 new.clause
1667 format.chapter.pages "chapter and pages" output.check
1668 new.block
1669 format.number.series output
1670 new.sentence
1671 publisher "publisher" output.check
1672 address new.clause.checka
1673 address output
1674 }
1675 { format.chapter.pages "chapter and pages" output.check
1676 new.block
1677 format.book.crossref output.nonnull
1678 }
1679 if$
1680 edition new.clause.checka
1681 format.edition output
1682 format.date "year" output.check
1683 new.block
1684 note output
1685 fin.entry
1686 }
1687
1688 % An incollection is like inbook, but where there is a separate title
1689 % for the referenced thing (and perhaps an editor for the whole).
1690 % An incollection may CROSSREF a book.
1691 % Required: author, title, booktitle, publisher, year
1692 % Optional: editor, volume or number, series, type, chapter, pages,
1693 % address, edition, month, note
1694 % For the NO_TITLE option the title is suppressed, if the chapter or the pages
1695 % field is nonempty (H2B).
1696
1697 FUNCTION {incollection}
1698 { output.bibitem
1699 format.authors "author" output.check
1700 new.block
1701 #if NO_TITLE
1702 chapter empty$ pages empty$ and
1703 {
1704 #endif
1705 format.title "title" output.check
1706 new.block
1707 #if NO_TITLE
1708 }
1709 'skip$
1710 if$
1711 #endif
1712 crossref missing$
1713 { format.in.ed.booktitle "booktitle" output.check
1714 new.clause
1715 format.bvolume output
1716 new.clause
1717 format.number.series output
1718 new.clause
1719 format.chapter.pages output
1720 new.sentence
1721 publisher "publisher" output.check
1722 address new.clause.checka
1723 address output
1724 edition new.clause.checka
1725 format.edition output
1726 format.date "year" output.check
1727 }
1728 { format.incoll.inproc.crossref output.nonnull
1729 new.clause
1730 format.chapter.pages output
1731 }
1732 if$
1733 new.block
1734 note output
1735 fin.entry
1736 }
1737
1738 % An inproceedings is an article in a conference proceedings, and it may
1739 % CROSSREF a proceedings. If there's no address field, the month (& year)
1740 % will appear just before note.
1741 % Required: author, title, booktitle, year
1742 % Optional: editor, volume or number, series, pages, address, month,
1743 % organization, publisher, note
1744 % For the NO_TITLE option the title is suppressed, if the pages field is
1745 % nonempty (H2B).
1746
1747 FUNCTION {inproceedings}
1748 { output.bibitem
1749 format.authors "author" output.check
1750 new.block
1751 #if NO_TITLE
1752 pages empty$
1753 {
1754 #endif
1755 format.title "title" output.check
1756 new.block
1757 #if NO_TITLE
1758 }
1759 'skip$
1760 if$
1761 #endif
1762 crossref missing$
1763 { format.in.ed.booktitle "booktitle" output.check
1764 volume new.clause.checka
1765 format.bvolume output
1766 number series new.clause.checkb
1767 format.number.series output
1768 pages new.clause.checka
1769 format.pages output
1770 address empty$
1771 { organization publisher new.sentence.checkb
1772 organization output
1773 publisher new.clause.checka
1774 publisher output
1775 format.date "year" output.check
1776 }
1777 { new.clause
1778 address output.nonnull
1779 format.date "year" output.check
1780 new.sentence
1781 organization output
1782 new.clause
1783 publisher output
1784 }
1785 if$
1786 }
1787 { format.incoll.inproc.crossref output.nonnull
1788 new.clause
1789 format.pages output
1790 }
1791 if$
1792 new.block
1793 note output
1794 fin.entry
1795 }
1796
1797 % The conference function is included for Scribe compatibility.
1798
1799 FUNCTION {conference} { inproceedings }
1800
1801 % A manual is technical documentation.
1802 % Required: title
1803 % Optional: author, organization, address, edition, month, year, note
1804
1805 FUNCTION {manual}
1806 { output.bibitem
1807 author empty$
1808 { organization empty$
1809 'skip$
1810 { organization output.nonnull
1811 new.clause
1812 address output
1813 }
1814 if$
1815 }
1816 { format.authors output.nonnull }
1817 if$
1818 new.block
1819 format.btitle "title" output.check
1820 author empty$
1821 { organization empty$
1822 { address new.block.checka
1823 address output
1824 }
1825 'skip$
1826 if$
1827 }
1828 { organization address new.block.checkb
1829 organization output
1830 address new.clause.checka
1831 address output
1832 }
1833 if$
1834 edition new.clause.checka
1835 format.edition output
1836 format.date output
1837 new.block
1838 note output
1839 fin.entry
1840 }
1841
1842 % A mastersthesis is a Master's thesis.
1843 % Required: author, title, school, year
1844 % Optional: type, address, month, note
1845
1846 FUNCTION {mastersthesis}
1847 { output.bibitem
1848 format.authors "author" output.check
1849 new.block
1850 format.title "title" output.check
1851 new.block
1852 "\abphrase{17}" format.thesis.type output.nonnull %H2B
1853 new.clause
1854 school "school" output.check
1855 address new.clause.checka
1856 address output
1857 format.date "year" output.check
1858 new.block
1859 note output
1860 fin.entry
1861 }
1862
1863 % A misc is something that doesn't fit elsewhere.
1864 % Required: at least one of the `optional' fields
1865 % Optional: author, title, howpublished, month, year, note
1866
1867 FUNCTION {misc}
1868 { output.bibitem
1869 format.authors output
1870 title howpublished new.block.checkb
1871 format.title output
1872 howpublished new.block.checka
1873 howpublished output
1874 format.date output
1875 new.block
1876 note output
1877 fin.entry
1878 empty.misc.check
1879 }
1880
1881 % A phdthesis is like a mastersthesis.
1882 % Required: author, title, school, year
1883 % Optional: type, address, month, note
1884
1885 FUNCTION {phdthesis}
1886 { output.bibitem
1887 format.authors "author" output.check
1888 new.block
1889 format.btitle "title" output.check
1890 new.block
1891 "\abphrase{18}" format.thesis.type output.nonnull %H2B
1892 new.clause
1893 school "school" output.check
1894 address new.clause.checka
1895 address output
1896 format.date "year" output.check
1897 new.block
1898 note output
1899 fin.entry
1900 }
1901
1902 % A proceedings is a conference proceedings.
1903 % If there is an organization but no editor field, the organization will
1904 % appear as the first optional field (we try to make the first block nonempty);
1905 % if there's no address field, the month (& year) will appear just before note.
1906 % Required: title, year
1907 % Optional: editor, volume or number, series, address, month,
1908 % organization, publisher, note
1909
1910 FUNCTION {proceedings}
1911 { output.bibitem
1912 editor empty$
1913 { organization output }
1914 { format.editors output.nonnull }
1915 if$
1916 new.block
1917 format.btitle "title" output.check
1918 volume new.clause.checka
1919 format.bvolume output
1920 number series new.clause.checkb
1921 format.number.series output
1922 address empty$
1923 { editor empty$
1924 { publisher new.sentence.checka }
1925 { organization publisher new.sentence.checkb
1926 organization output
1927 publisher new.clause.checka
1928 }
1929 if$
1930 publisher output
1931 format.date "year" output.check
1932 }
1933 { new.clause
1934 address output.nonnull
1935 format.date "year" output.check
1936 new.sentence
1937 editor empty$
1938 'skip$
1939 { organization output
1940 new.clause
1941 }
1942 if$
1943 publisher output
1944 }
1945 if$
1946 new.block
1947 note output
1948 fin.entry
1949 }
1950
1951 % A techreport is a technical report.
1952 % Required: author, title, institution, year
1953 % Optional: type, number, address, month, note
1954 % For the NO_TITLE option the title is suppressed, if the number field is
1955 % nonempty (H2B).
1956
1957 FUNCTION {techreport}
1958 { output.bibitem
1959 format.authors "author" output.check
1960 new.block
1961 #if NO_TITLE
1962 number empty$
1963 {
1964 #endif
1965 format.title "title" output.check
1966 new.block
1967 #if NO_TITLE
1968 }
1969 'skip$
1970 if$
1971 #endif
1972 format.tr.number output.nonnull
1973 new.clause
1974 institution "institution" output.check
1975 address new.clause.checka
1976 address output
1977 format.date "year" output.check
1978 new.block
1979 note output
1980 fin.entry
1981 }
1982
1983 % An unpublished is something that hasn't been published.
1984 % Required: author, title, note
1985 % Optional: month, year
1986
1987 FUNCTION {unpublished}
1988 { output.bibitem
1989 format.authors "author" output.check
1990 new.block
1991 format.title "title" output.check
1992 new.block
1993 note "note" output.check
1994 format.date output
1995 fin.entry
1996 }
1997
1998 % We use entry type `misc' for an unknown type; BibTeX gives a warning.
1999
2000 FUNCTION {default.type} { misc }
2001
2002 % Here are macros for common things that may vary from style to style.
2003 % Users are encouraged to use these macros.
2004 %
2005 % Months are either written out in full or abbreviated
2006 %
2007 % The macros for the month names now expand to TeX macros, so they are
2008 % adaptable too. Thus no conditional MONTH_FULL is needed anymore (H2B).
2009 %
2010 % The \abmonth macro should be defined by the user as something like:
2011 % \def\abmonth#1{\ifcase#1\or January\or February\or March\or April\or May\or
2012 % June\or July\or August\or September\or October\or November\or December\fi}
2013
2014 MACRO {jan} {"\abmonth{1}"}
2015
2016 MACRO {feb} {"\abmonth{2}"}
2017
2018 MACRO {mar} {"\abmonth{3}"}
2019
2020 MACRO {apr} {"\abmonth{4}"}
2021
2022 MACRO {may} {"\abmonth{5}"}
2023
2024 MACRO {jun} {"\abmonth{6}"}
2025
2026 MACRO {jul} {"\abmonth{7}"}
2027
2028 MACRO {aug} {"\abmonth{8}"}
2029
2030 MACRO {sep} {"\abmonth{9}"}
2031
2032 MACRO {oct} {"\abmonth{10}"}
2033
2034 MACRO {nov} {"\abmonth{11}"}
2035
2036 MACRO {dec} {"\abmonth{12}"}
2037
2038 % The next ten macros are provided for edition numbers. For higher numbers the
2039 % \abedition command should be extended by the user and called directly or---
2040 % better---via @STRING declarations in the BIB files. The \abedition command
2041 % to be defined by the user is, e.g.:
2042 % \def\abedition#1{\ifcase#1\or First\or Second\or Third\or Fourth\or Fifth\or
2043 % Sixth\or Seventh\or Eighth\or Ninth\or Tenth\else?\fi}
2044
2045 MACRO {first} {"\abedition{1}"}
2046
2047 MACRO {second} {"\abedition{2}"}
2048
2049 MACRO {third} {"\abedition{3}"}
2050
2051 MACRO {fourth} {"\abedition{4}"}
2052
2053 MACRO {fifth} {"\abedition{5}"}
2054
2055 MACRO {sixth} {"\abedition{6}"}
2056
2057 MACRO {seventh} {"\abedition{7}"}
2058
2059 MACRO {eighth} {"\abedition{8}"}
2060
2061 MACRO {ninth} {"\abedition{9}"}
2062
2063 MACRO {tenth} {"\abedition{10}"}
2064
2065 % Finally, some macros are defined to re-dedicate the CHAPTER field via the
2066 % TYPE field. An appropriate \abchapter command were:
2067 % \def\abchapter#1{\ifcase#1Section\or Paragraph\or Appendix\or Part\fi}
2068
2069 MACRO {section} {"\abchapter{0}"}
2070
2071 MACRO {paragraph} {"\abchapter{1}"}
2072
2073 MACRO {appendix} {"\abchapter{2}"}
2074
2075 MACRO {part} {"\abchapter{3}"}
2076
2077 % Journals are either written out in full or abbreviated;
2078 % the abbreviations are like those found in ACM publications.
2079 %
2080 % To get a completely different set of abbreviations, it may be best to make
2081 % a separate .bib file with nothing but those abbreviations; users could then
2082 % include that file name as the first argument to the \bibliography command.
2083 %
2084 % All journal macros were commented off, because the set applies only to a
2085 % very special field of sciences; so the hint in the previous paragraph
2086 % becomes mandatory (H2B).
2087
2088 % #if JOUR_FULL
2089 %
2090 % MACRO {acmcs} {"ACM Computing Surveys"}
2091 %
2092 % MACRO {acta} {"Acta Informatica"}
2093 %
2094 % MACRO {cacm} {"Communications of the ACM"}
2095 %
2096 % MACRO {ibmjrd} {"IBM Journal of Research and Development"}
2097 %
2098 % MACRO {ibmsj} {"IBM Systems Journal"}
2099 %
2100 % MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
2101 %
2102 % MACRO {ieeetc} {"IEEE Transactions on Computers"}
2103 %
2104 % MACRO {ieeetcad}
2105 % {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
2106 %
2107 % MACRO {ipl} {"Information Processing Letters"}
2108 %
2109 % MACRO {jacm} {"Journal of the ACM"}
2110 %
2111 % MACRO {jcss} {"Journal of Computer and System Sciences"}
2112 %
2113 % MACRO {scp} {"Science of Computer Programming"}
2114 %
2115 % MACRO {sicomp} {"SIAM Journal on Computing"}
2116 %
2117 % MACRO {tocs} {"ACM Transactions on Computer Systems"}
2118 %
2119 % MACRO {tods} {"ACM Transactions on Database Systems"}
2120 %
2121 % MACRO {tog} {"ACM Transactions on Graphics"}
2122 %
2123 % MACRO {toms} {"ACM Transactions on Mathematical Software"}
2124 %
2125 % MACRO {toois} {"ACM Transactions on Office Information Systems"}
2126 %
2127 % MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
2128 %
2129 % MACRO {tcs} {"Theoretical Computer Science"}
2130 %
2131 % #else !JOUR_FULL
2132 %
2133 % MACRO {acmcs} {"ACM Comput. Surv."}
2134 %
2135 % MACRO {acta} {"Acta Inf."}
2136 %
2137 % MACRO {cacm} {"Commun. ACM"}
2138 %
2139 % MACRO {ibmjrd} {"IBM J. Res. Dev."}
2140 %
2141 % MACRO {ibmsj} {"IBM Syst.~J."}
2142 %
2143 % MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
2144 %
2145 % MACRO {ieeetc} {"IEEE Trans. Comput."}
2146 %
2147 % MACRO {ieeetcad}
2148 % {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
2149 %
2150 % MACRO {ipl} {"Inf. Process. Lett."}
2151 %
2152 % MACRO {jacm} {"J.~ACM"}
2153 %
2154 % MACRO {jcss} {"J.~Comput. Syst. Sci."}
2155 %
2156 % MACRO {scp} {"Sci. Comput. Programming"}
2157 %
2158 % MACRO {sicomp} {"SIAM J. Comput."}
2159 %
2160 % MACRO {tocs} {"ACM Trans. Comput. Syst."}
2161 %
2162 % MACRO {tods} {"ACM Trans. Database Syst."}
2163 %
2164 % MACRO {tog} {"ACM Trans. Gr."}
2165 %
2166 % MACRO {toms} {"ACM Trans. Math. Softw."}
2167 %
2168 % MACRO {toois} {"ACM Trans. Office Inf. Syst."}
2169 %
2170 % MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
2171 %
2172 % MACRO {tcs} {"Theoretical Comput. Sci."}
2173 %
2174 % #endif JOUR_FULL
2175
2176 % Now we read in the .BIB entries.
2177
2178 READ
2179
2180 % The sortify function converts to lower case after purify$ing; it's
2181 % used in sorting and in computing alphabetic labels after sorting
2182 %
2183 % The chop.word(w,len,s) function returns either s or, if the first len
2184 % letters of s equals w (this comparison is done in the third line of the
2185 % function's definition), it returns that part of s after w.
2186
2187 #if SORTED
2188
2189 FUNCTION {sortify}
2190 { purify$
2191 "l" change.case$
2192 }
2193
2194 INTEGERS { len }
2195
2196 FUNCTION {chop.word}
2197 { 's :=
2198 'len :=
2199 s #1 len substring$ =
2200 { s len #1 + global.max$ substring$ }
2201 's
2202 if$
2203 }
2204
2205 #else !SORTED
2206 #if LAB_ALPH
2207
2208 % We need the chop.word stuff for the dubious unsorted-list-with-labels case.
2209
2210 INTEGERS { len }
2211
2212 FUNCTION {chop.word}
2213 { 's :=
2214 'len :=
2215 s #1 len substring$ =
2216 { s len #1 + global.max$ substring$ }
2217 's
2218 if$
2219 }
2220
2221 #endif LAB_ALPH
2222 #endif SORTED
2223
2224 % This long comment applies only to alphabetic labels
2225 %
2226 % The format.lab.names function makes a short label by using the initials of
2227 % the von and Last parts of the names (but if there are more than four names,
2228 % (i.e., people) it truncates after three and adds a superscripted "+";
2229 % it also adds such a "+" if the last of multiple authors is "others").
2230 % If there is only one name, and its von and Last parts combined have just
2231 % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
2232 % we take the first three letters of the last name. The boolean
2233 % et.al.char.used tells whether we've used a superscripted "+", so that we
2234 % know whether to include a LaTeX macro for it.
2235 %
2236 % format.lab.names(s) ==
2237 % BEGIN
2238 % numnames := num.names$(s)
2239 % if numnames > 1 then
2240 % if numnames > 4 then
2241 % namesleft := 3
2242 % else
2243 % namesleft := numnames
2244 % nameptr := 1
2245 % nameresult := ""
2246 % while namesleft > 0
2247 % do
2248 % if (name_ptr = numnames) and
2249 % format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
2250 % then nameresult := nameresult * "{\etalchar{+}}"
2251 % et.al.char.used := true
2252 % else nameresult := nameresult *
2253 % format.name$(s, nameptr, "{v{}}{l{}}")
2254 % nameptr := nameptr + 1
2255 % namesleft := namesleft - 1
2256 % od
2257 % if numnames > 4 then
2258 % nameresult := nameresult * "{\etalchar{+}}"
2259 % et.al.char.used := true
2260 % else
2261 % t := format.name$(s, 1, "{v{}}{l{}}")
2262 % if text.length$(t) < 2 then % there's just one name-token
2263 % nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
2264 % else
2265 % nameresult := t
2266 % fi
2267 % fi
2268 % return nameresult
2269 % END
2270 %
2271 % Exactly what fields we look at in constructing the primary part of the label
2272 % depends on the entry type; this selectivity (as opposed to, say, always
2273 % looking at author, then editor, then key) helps ensure that "ignored" fields,
2274 % as described in the LaTeX book, really are ignored. Note that MISC is part
2275 % of the deepest `else' clause in the nested part of calc.label; thus, any
2276 % unrecognized entry type in the database is handled correctly.
2277 %
2278 % There is one auxiliary function for each of the four different sequences of
2279 % fields we use. The first of these functions looks at the author field, and
2280 % then, if necessary, the key field. The other three functions, which might
2281 % look at two fields and the key field, are similar, except that the key field
2282 % takes precedence over the organization field (for labels---not for sorting).
2283 %
2284 % The calc.label function calculates the preliminary label of an entry, which
2285 % is formed by taking three letters of information from the author or editor or
2286 % key or organization field (depending on the entry type and on what's empty,
2287 % but ignoring a leading "The " in the organization), and appending the last
2288 % two characters (digits) of the year. It is an error if the appropriate fields
2289 % among author, editor, organization, and key are missing, and we use
2290 % the first three letters of the cite$ in desperation when this happens.
2291 % The resulting label has the year part, but not the name part, purify$ed
2292 % (purify$ing the year allows some sorting shenanigans by the user).
2293 %
2294 % This function also calculates the version of the label to be used in sorting.
2295 %
2296 % The final label may need a trailing 'a', 'b', etc., to distinguish it from
2297 % otherwise identical labels, but we can't calculated those "extra.label"s
2298 % until after sorting.
2299 %
2300 % calc.label ==
2301 % BEGIN
2302 % if type$ = "book" or "inbook" then
2303 % author.editor.key.label
2304 % else if type$ = "proceedings" then
2305 % editor.key.organization.label
2306 % else if type$ = "manual" then
2307 % author.key.organization.label
2308 % else
2309 % author.key.label
2310 % fi fi fi
2311 % label := label * substring$(purify$(field.or.null(year)), -1, 2)
2312 % % assuming we will also sort, we calculate a sort.label
2313 % sort.label := sortify(label), but use the last four, not two, digits
2314 % END
2315
2316 #if LAB_ALPH
2317
2318 INTEGERS { et.al.char.used }
2319
2320 FUNCTION {initialize.et.al.char.used}
2321 { #0 'et.al.char.used :=
2322 }
2323
2324 EXECUTE {initialize.et.al.char.used}
2325
2326 FUNCTION {format.lab.names}
2327 { 's :=
2328 s num.names$ 'numnames :=
2329 numnames #1 >
2330 { numnames #4 >
2331 { #3 'namesleft := }
2332 { numnames 'namesleft := }
2333 if$
2334 #1 'nameptr :=
2335 ""
2336 { namesleft #0 > }
2337 { nameptr numnames =
2338 { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
2339 { "{\etalchar{+}}" *
2340 #1 'et.al.char.used :=
2341 }
2342 { s nameptr "{v{}}{l{}}" format.name$ * }
2343 if$
2344 }
2345 { s nameptr "{v{}}{l{}}" format.name$ * }
2346 if$
2347 nameptr #1 + 'nameptr :=
2348 namesleft #1 - 'namesleft :=
2349 }
2350 while$
2351 numnames #4 >
2352 { "{\etalchar{+}}" *
2353 #1 'et.al.char.used :=
2354 }
2355 'skip$
2356 if$
2357 }
2358 { s #1 "{v{}}{l{}}" format.name$
2359 duplicate$ text.length$ #2 <
2360 { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
2361 'skip$
2362 if$
2363 }
2364 if$
2365 }
2366
2367 FUNCTION {author.key.label}
2368 { author empty$
2369 { key empty$
2370 #if SORTED
2371 { cite$ #1 #3 substring$ }
2372 #else !SORTED % need warning here because we won't give it later
2373 { "for label, need author or key in " cite$ * warning$
2374 cite$ #1 #3 substring$
2375 }
2376 #endif SORTED
2377 { key #3 text.prefix$ }
2378 if$
2379 }
2380 { author format.lab.names }
2381 if$
2382 }
2383
2384 FUNCTION {author.editor.key.label}
2385 { author empty$
2386 { editor empty$
2387 { key empty$
2388 #if SORTED
2389 { cite$ #1 #3 substring$ }
2390 #else !SORTED % need warning here because we won't give it later
2391 { "for label, need author, editor, or key in " cite$ * warning$
2392 cite$ #1 #3 substring$
2393 }
2394 #endif SORTED
2395 { key #3 text.prefix$ }
2396 if$
2397 }
2398 { editor format.lab.names }
2399 if$
2400 }
2401 { author format.lab.names }
2402 if$
2403 }
2404
2405 FUNCTION {author.key.organization.label}
2406 { author empty$
2407 { key empty$
2408 { organization empty$
2409 #if SORTED
2410 { cite$ #1 #3 substring$ }
2411 #else !SORTED % need warning here because we won't give it later
2412 { "for label, need author, key, or organization in " cite$ *
2413 warning$
2414 cite$ #1 #3 substring$
2415 }
2416 #endif SORTED
2417 { "The " #4 organization chop.word #3 text.prefix$ }
2418 if$
2419 }
2420 { key #3 text.prefix$ }
2421 if$
2422 }
2423 { author format.lab.names }
2424 if$
2425 }
2426
2427 FUNCTION {editor.key.organization.label}
2428 { editor empty$
2429 { key empty$
2430 { organization empty$
2431 #if SORTED
2432 { cite$ #1 #3 substring$ }
2433 #else !SORTED % need warning here because we won't give it later
2434 { "for label, need editor, key, or organization in " cite$ *
2435 warning$
2436 cite$ #1 #3 substring$
2437 }
2438 #endif SORTED
2439 { "The " #4 organization chop.word #3 text.prefix$ }
2440 if$
2441 }
2442 { key #3 text.prefix$ }
2443 if$
2444 }
2445 { editor format.lab.names }
2446 if$
2447 }
2448
2449 FUNCTION {calc.label}
2450 { type$ "book" =
2451 type$ "inbook" =
2452 or
2453 'author.editor.key.label
2454 { type$ "proceedings" =
2455 'editor.key.organization.label
2456 { type$ "manual" =
2457 'author.key.organization.label
2458 'author.key.label
2459 if$
2460 }
2461 if$
2462 }
2463 if$
2464 duplicate$
2465 year field.or.null purify$ #-1 #2 substring$
2466 *
2467 'label :=
2468 year field.or.null purify$ #-1 #4 substring$
2469 *
2470 sortify 'sort.label :=
2471 }
2472
2473 % It doesn't seem like a particularly good idea to use an order-of-citation
2474 % reference list when using alphabetic labels, but we need to have a
2475 % special pass to calculate labels when this happens.
2476
2477 #if !SORTED
2478
2479 ITERATE {calc.label}
2480
2481 #endif !SORTED
2482
2483 #endif LAB_ALPH
2484
2485 % When sorting, we compute the sortkey by executing "presort" on each entry.
2486 % The presort key contains a number of "sortify"ed strings, concatenated
2487 % with multiple blanks between them. This makes things like "brinch per"
2488 % come before "brinch hansen per".
2489 %
2490 % The fields used here are: the sort.label for alphabetic labels (as set by
2491 % calc.label), followed by the author names (or editor names or organization
2492 % (with a leading "The " removed) or key field, depending on entry type and on
2493 % what's empty), followed by year, followed by the first bit of the title
2494 % (chopping off a leading "The ", "A ", or "An ").
2495 % Names are formatted: Von Last First Junior.
2496 % The names within a part will be separated by a single blank
2497 % (such as "brinch hansen"), two will separate the name parts themselves
2498 % (except the von and last), three will separate the names,
2499 % four will separate the names from year (and from label, if alphabetic),
2500 % and four will separate year from title.
2501 %
2502 % The sort.format.names function takes an argument that should be in
2503 % BibTeX name format, and returns a string containing " "-separated
2504 % names in the format described above. The function is almost the same
2505 % as format.names.
2506
2507 #if SORTED
2508
2509 FUNCTION {sort.format.names}
2510 { 's :=
2511 #1 'nameptr :=
2512 ""
2513 s num.names$ 'numnames :=
2514 numnames 'namesleft :=
2515 { namesleft #0 > }
2516 { nameptr #1 >
2517 { " " * }
2518 'skip$
2519 if$
2520 #if NAME_FULL
2521 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
2522 #else
2523 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't :=
2524 #endif NAME_FULL
2525 nameptr numnames = t "others" = and
2526 { "et al" * }
2527 { t sortify * }
2528 if$
2529 nameptr #1 + 'nameptr :=
2530 namesleft #1 - 'namesleft :=
2531 }
2532 while$
2533 }
2534
2535 % The sort.format.title function returns the argument,
2536 % but first any leading "A "'s, "An "'s, or "The "'s are removed.
2537 % The chop.word function uses s, so we need another string variable, t
2538
2539 FUNCTION {sort.format.title}
2540 { 't :=
2541 "A " #2
2542 "An " #3
2543 "The " #4 t chop.word
2544 chop.word
2545 chop.word
2546 sortify
2547 #1 global.max$ substring$
2548 }
2549
2550 % The auxiliary functions here, for the presort function, are analogous to
2551 % the ones for calc.label; the same comments apply, except that the
2552 % organization field takes precedence here over the key field. For sorting
2553 % purposes, we still remove a leading "The " from the organization field.
2554
2555 FUNCTION {author.sort}
2556 { author empty$
2557 { key empty$
2558 { "to sort, need author or key in " cite$ * warning$
2559 ""
2560 }
2561 { key sortify }
2562 if$
2563 }
2564 { author sort.format.names }
2565 if$
2566 }
2567
2568 FUNCTION {author.editor.sort}
2569 { author empty$
2570 { editor empty$
2571 { key empty$
2572 { "to sort, need author, editor, or key in " cite$ * warning$
2573 ""
2574 }
2575 { key sortify }
2576 if$
2577 }
2578 { editor sort.format.names }
2579 if$
2580 }
2581 { author sort.format.names }
2582 if$
2583 }
2584
2585 FUNCTION {author.organization.sort}
2586 { author empty$
2587 { organization empty$
2588 { key empty$
2589 { "to sort, need author, organization, or key in " cite$ * warning$
2590 ""
2591 }
2592 { key sortify }
2593 if$
2594 }
2595 { "The " #4 organization chop.word sortify }
2596 if$
2597 }
2598 { author sort.format.names }
2599 if$
2600 }
2601
2602 FUNCTION {editor.organization.sort}
2603 { editor empty$
2604 { organization empty$
2605 { key empty$
2606 { "to sort, need editor, organization, or key in " cite$ * warning$
2607 ""
2608 }
2609 { key sortify }
2610 if$
2611 }
2612 { "The " #4 organization chop.word sortify }
2613 if$
2614 }
2615 { editor sort.format.names }
2616 if$
2617 }
2618
2619 % There is a limit, entry.max$, on the length of an entry string variable
2620 % (which is what its sort.key$ is), so we take at most that many characters
2621 % of the constructed key, and hope there aren't many references that match
2622 % to that many characters!
2623
2624 FUNCTION {presort}
2625 #if LAB_ALPH
2626 { calc.label
2627 sort.label
2628 " "
2629 *
2630 type$ "book" =
2631 #else !LAB_ALPH
2632 { type$ "book" =
2633 #endif LAB_ALPH
2634 type$ "inbook" =
2635 or
2636 'author.editor.sort
2637 { type$ "proceedings" =
2638 'editor.organization.sort
2639 { type$ "manual" =
2640 'author.organization.sort
2641 'author.sort
2642 if$
2643 }
2644 if$
2645 }
2646 if$
2647 #if LAB_ALPH
2648 *
2649 #endif LAB_ALPH
2650 " "
2651 *
2652 year field.or.null sortify
2653 *
2654 " "
2655 *
2656 title field.or.null
2657 sort.format.title
2658 *
2659 #1 entry.max$ substring$
2660 'sort.key$ :=
2661 }
2662
2663 ITERATE {presort}
2664
2665 % And now we can sort
2666
2667 SORT
2668
2669 #endif SORTED
2670
2671 % This long comment applies only to alphabetic labels, when sorted
2672 %
2673 % Now comes the final computation for alphabetic labels, putting in the 'a's
2674 % and 'b's and so forth if required. This involves two passes: a forward
2675 % pass to put in the 'b's, 'c's and so on, and a backwards pass
2676 % to put in the 'a's (we don't want to put in 'a's unless we know there
2677 % are 'b's).
2678 % We have to keep track of the longest (in width$ terms) label, for use
2679 % by the "thebibliography" environment.
2680 %
2681 % VAR: longest.label, last.sort.label, next.extra: string
2682 % longest.label.width, last.extra.num: integer
2683 %
2684 % initialize.longest.label ==
2685 % BEGIN
2686 % longest.label := ""
2687 % last.sort.label := int.to.chr$(0)
2688 % next.extra := ""
2689 % longest.label.width := 0
2690 % last.extra.num := 0
2691 % END
2692 %
2693 % forward.pass ==
2694 % BEGIN
2695 % if last.sort.label = sort.label then
2696 % last.extra.num := last.extra.num + 1
2697 % extra.label := int.to.chr$(last.extra.num)
2698 % else
2699 % last.extra.num := chr.to.int$("a")
2700 % extra.label := ""
2701 % last.sort.label := sort.label
2702 % fi
2703 % END
2704 %
2705 % reverse.pass ==
2706 % BEGIN
2707 % if next.extra = "b" then
2708 % extra.label := "a"
2709 % fi
2710 % label := label * extra.label
2711 % if width$(label) > longest.label.width then
2712 % longest.label := label
2713 % longest.label.width := width$(label)
2714 % fi
2715 % next.extra := extra.label
2716 % END
2717
2718 #if LAB_ALPH
2719
2720 #if SORTED
2721
2722 STRINGS { longest.label last.sort.label next.extra }
2723
2724 INTEGERS { longest.label.width last.extra.num }
2725
2726 FUNCTION {initialize.longest.label}
2727 { "" 'longest.label :=
2728 #0 int.to.chr$ 'last.sort.label :=
2729 "" 'next.extra :=
2730 #0 'longest.label.width :=
2731 #0 'last.extra.num :=
2732 }
2733
2734 FUNCTION {forward.pass}
2735 { last.sort.label sort.label =
2736 { last.extra.num #1 + 'last.extra.num :=
2737 last.extra.num int.to.chr$ 'extra.label :=
2738 }
2739 { "a" chr.to.int$ 'last.extra.num :=
2740 "" 'extra.label :=
2741 sort.label 'last.sort.label :=
2742 }
2743 if$
2744 }
2745
2746 FUNCTION {reverse.pass}
2747 { next.extra "b" =
2748 { "a" 'extra.label := }
2749 'skip$
2750 if$
2751 label extra.label * 'label :=
2752 label width$ longest.label.width >
2753 { label 'longest.label :=
2754 label width$ 'longest.label.width :=
2755 }
2756 'skip$
2757 if$
2758 extra.label 'next.extra :=
2759 }
2760
2761 EXECUTE {initialize.longest.label}
2762
2763 ITERATE {forward.pass}
2764
2765 REVERSE {reverse.pass}
2766
2767 #else !SORTED
2768
2769 % It still doesn't seem like a good idea to use an order-of-citation
2770 % reference list when using alphabetic labels, but when this happens we
2771 % must compute the longest label
2772
2773 STRINGS { longest.label }
2774
2775 INTEGERS { longest.label.width }
2776
2777 FUNCTION {initialize.longest.label}
2778 { "" 'longest.label :=
2779 #0 'longest.label.width :=
2780 }
2781
2782 FUNCTION {longest.label.pass}
2783 { label width$ longest.label.width >
2784 { label 'longest.label :=
2785 label width$ 'longest.label.width :=
2786 }
2787 'skip$
2788 if$
2789 }
2790
2791 EXECUTE {initialize.longest.label}
2792
2793 ITERATE {longest.label.pass}
2794
2795 #endif SORTED
2796
2797 #else !LAB_ALPH
2798
2799 % Now comes the computation for numeric labels.
2800 % We use either the sorted order or original order.
2801 % We still have to keep track of the longest (in width$ terms) label, for use
2802 % by the "thebibliography" environment.
2803
2804 STRINGS { longest.label }
2805
2806 INTEGERS { number.label longest.label.width }
2807
2808 FUNCTION {initialize.longest.label}
2809 { "" 'longest.label :=
2810 #1 'number.label :=
2811 #0 'longest.label.width :=
2812 }
2813
2814 FUNCTION {longest.label.pass}
2815 { number.label int.to.str$ 'label :=
2816 number.label #1 + 'number.label :=
2817 label width$ longest.label.width >
2818 { label 'longest.label :=
2819 label width$ 'longest.label.width :=
2820 }
2821 'skip$
2822 if$
2823 }
2824
2825 EXECUTE {initialize.longest.label}
2826
2827 ITERATE {longest.label.pass}
2828
2829 #endif LAB_ALPH
2830
2831 % Now we're ready to start writing the .BBL file.
2832 % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
2833 % label; next comes stuff from the `preamble' command in the database files.
2834 % Then we give an incantation containing the command
2835 % \begin{thebibliography}{...}
2836 % where the `...' is the longest label.
2837 %
2838 % We also call init.state.consts, for use by the output routines.
2839 %
2840 % At first a TeX definition is output, that makes user commands able to
2841 % distinguish between a ``full'' and an ``abbreviated'' style (H2B).
2842
2843 FUNCTION {begin.bib}
2844 {
2845 #if MONTH_FULL
2846 "\newif\ifabfull\abfulltrue" write$ newline$
2847 #else
2848 "\newif\ifabfull\abfullfalse" write$ newline$
2849 #endif
2850 #if LAB_ALPH
2851 et.al.char.used
2852 { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
2853 'skip$
2854 if$
2855 #endif LAB_ALPH
2856 preamble$ empty$
2857 'skip$
2858 { preamble$ write$ newline$ }
2859 if$
2860 "\begin{thebibliography}{" longest.label * "}" * write$ newline$
2861 }
2862
2863 EXECUTE {begin.bib}
2864
2865 EXECUTE {init.state.consts}
2866
2867 % Now we produce the output for all the entries
2868
2869 ITERATE {call.type$}
2870
2871 % Finally, we finish up by writing the `\end{thebibliography}' command.
2872
2873 FUNCTION {end.bib}
2874 { newline$
2875 "\end{thebibliography}" write$ newline$
2876 }
2877
2878 EXECUTE {end.bib}