Debian Codegraph @

texmf-dist/bibtex/bst/zootaxa-bst/zootaxa.bst

raw
1 %% zootaxa.bst: BibTeX style file for the journal Zootaxa.
2 %
3 % Author: Gustavo A. Ballen
4 % Maintainer: Gustavo A. Ballen
5 % First-written: <2019-mar-25>
6 % Version: 1.0
7 % Keywords: TeX, BibTeX, bst, zootaxa
8 % URL: https://github.com/gaballench/zootaxa-bst
9
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % The file zootaxa.bst file is a fork of apa.bst with further modification.
12 % It is said to be further a modification of apalike.bst
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 % BibTeX `apalike' bibliography style (24-Jan-88 version)
17 % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
18 % Copyright (C) 1988, all rights reserved.
19 % Copying of this file is allowed, provided that if you make any changes at all
20 % you name it something other than `apalike.bst'.
21 % This restriction helps ensure that all copies are identical.
22 % Differences between this style and `alpha' are generally heralded by a `%'.
23 % The file btxbst.doc has the documentation for alpha.bst.
24 %
25 % This style should be used with the `apalike' LaTeX style (apalike.sty).
26 % \cite's come out like "(Jones, 1986)" in the text but there are no labels
27 % in the bibliography, and something like "(1986)" comes out immediately
28 % after the author. Author (and editor) names appear as last name, comma,
29 % initials. A `year' field is required for every entry, and so is either
30 % an author (or in some cases, an editor) field or a key field.
31 %
32 % Editorial note:
33 % Many journals require a style like `apalike', but I strongly, strongly,
34 % strongly recommend that you not use it if you have a choice---use something
35 % like `plain' instead. Mary-Claire van Leunen (A Handbook for Scholars,
36 % Knopf, 1979) argues convincingly that a style like `plain' encourages better
37 % writing than one like `apalike'. Furthermore the strongest arguments for
38 % using an author-date style like `apalike'---that it's "the most practical"
39 % (The Chicago Manual of Style, University of Chicago Press, thirteenth
40 % edition, 1982, pages 400--401)---fall flat on their face with the new
41 % computer-typesetting technology. For instance page 401 anachronistically
42 % states "The chief disadvantage of [a style like `plain'] is that additions
43 % or deletions cannot be made after the manuscript is typed without changing
44 % numbers in both text references and list." LaTeX sidesteps the disadvantage.
45 %
46 % History:
47 % 15-sep-86 (SK,OP) Original version, by Susan King and Oren Patashnik.
48 % 10-nov-86 (OP) Truncated the sort.key$ string to the correct length
49 % in bib.sort.order to eliminate error message.
50 % 24-jan-88 (OP) Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
51 % apalike now sorts by author, then year, then title;
52 % THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
53 % 25-mar-19 (GAB) Forked from texlive's apa.bst for fitting to zootaxa
54 % reference rules.
55
56 ENTRY
57 { address
58 author
59 booktitle
60 chapter
61 edition
62 editor
63 howpublished
64 institution
65 journal
66 key
67 note
68 number
69 organization
70 pages
71 publisher
72 school
73 series
74 title
75 type
76 url
77 urldate
78 volume
79 year
80 }
81 {}
82 { label extra.label sort.label }
83
84 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
85
86 FUNCTION {init.state.consts}
87 { #0 'before.all :=
88 #1 'mid.sentence :=
89 #2 'after.sentence :=
90 #3 'after.block :=
91 }
92
93 STRINGS { s t }
94
95 FUNCTION {output.nonnull}
96 { 's :=
97 output.state mid.sentence =
98 { ", " * write$ }
99 { output.state after.block =
100 { add.period$ write$
101 newline$
102 "\newblock " write$
103 }
104 { output.state before.all =
105 'write$
106 { add.period$ " " * write$ }
107 if$
108 }
109 if$
110 mid.sentence 'output.state :=
111 }
112 if$
113 s
114 }
115
116 FUNCTION {output}
117 { duplicate$ empty$
118 'pop$
119 'output.nonnull
120 if$
121 }
122
123 FUNCTION {output.check}
124 { 't :=
125 duplicate$ empty$
126 { pop$ "empty " t * " in " * cite$ * warning$ }
127 'output.nonnull
128 if$
129 }
130
131 % apalike needs this function because
132 % the year has special punctuation;
133 % apalike ignores the month
134 FUNCTION {output.year.check}
135 { year empty$
136 { "empty year in " cite$ * warning$ }
137 { write$
138 " (" year * extra.label * ")" *
139 mid.sentence 'output.state :=
140 }
141 if$
142 }
143
144 FUNCTION {output.url}
145 { year empty$
146 { "empty url in " cite$ * warning$ }
147 { write$
148 " \textit{Available from:} " url * extra.label *
149 mid.sentence 'output.state :=
150 }
151 if$
152 }
153
154 FUNCTION {output.urldate}
155 { year empty$
156 { "empty urldate in " cite$ * warning$ }
157 { write$
158 " (" urldate * extra.label * ")" *
159 mid.sentence 'output.state :=
160 }
161 if$
162 }
163
164 FUNCTION {output.bibitem}
165 { newline$
166 "\bibitem[" write$
167 label write$
168 "]{" write$
169 cite$ write$
170 "}" write$
171 newline$
172 ""
173 before.all 'output.state :=
174 }
175
176 FUNCTION {fin.entry}
177 { add.period$
178 write$
179 newline$
180 }
181
182 FUNCTION {new.block}
183 { output.state before.all =
184 'skip$
185 { after.block 'output.state := }
186 if$
187 }
188
189 FUNCTION {add.blank} % added this one from linquire2.bst
190 { " " * before.all 'output.state :=
191 }
192
193 FUNCTION {new.sentence}
194 { output.state after.block =
195 'skip$
196 { output.state before.all =
197 'skip$
198 { after.sentence 'output.state := }
199 if$
200 }
201 if$
202 }
203
204 FUNCTION {not}
205 { { #0 }
206 { #1 }
207 if$
208 }
209
210 FUNCTION {and}
211 { 'skip$
212 { pop$ #0 }
213 if$
214 }
215
216 FUNCTION {or}
217 { { pop$ #1 }
218 'skip$
219 if$
220 }
221
222 FUNCTION {new.block.checkb}
223 { empty$
224 swap$ empty$
225 and
226 'skip$
227 'new.block
228 if$
229 }
230
231 FUNCTION {field.or.null}
232 { duplicate$ empty$
233 { pop$ "" }
234 'skip$
235 if$
236 }
237
238 FUNCTION {emphasize}
239 { duplicate$ empty$
240 { pop$ "" }
241 { "{\em " swap$ * "}" * }
242 if$
243 }
244
245 INTEGERS { nameptr namesleft numnames }
246
247 FUNCTION {format.names}
248 { 's :=
249 #1 'nameptr :=
250 s num.names$ 'numnames :=
251 numnames 'namesleft :=
252 { namesleft #0 > }
253 { s nameptr "{vv~}{ll}{, jj}{, f{.}.}" format.name$ 't := % {, f. separates lastname and initial}
254 nameptr #1 >
255 { namesleft #1 >
256 { ", " * t * }
257 { numnames #2 >
258 { "," * }
259 'skip$
260 if$
261 t "others" =
262 { " \textit{et~al.}" * }
263 { " \& " * t * }
264 if$
265 }
266 if$
267 }
268 't
269 if$
270 nameptr #1 + 'nameptr :=
271 namesleft #1 - 'namesleft :=
272 }
273 while$
274 }
275
276 FUNCTION {format.authors}
277 { author empty$
278 { "" }
279 { author format.names }
280 if$
281 }
282
283 FUNCTION {format.key} % this function is just for apalike
284 { empty$
285 { key field.or.null }
286 { "" }
287 if$
288 }
289
290 FUNCTION {format.editors}
291 { editor empty$
292 { "" }
293 { editor format.names
294 editor num.names$ #1 >
295 { " (Eds)" * }
296 { " (Ed)" * }
297 if$
298 }
299 if$
300 }
301
302 FUNCTION {format.title}
303 { title empty$
304 { "" }
305 { title "t" change.case$ }
306 if$
307 }
308
309 FUNCTION {n.dashify}
310 { 't :=
311 ""
312 { t empty$ not }
313 { t #1 #1 substring$ "-" =
314 { t #1 #2 substring$ "--" = not
315 { "--" *
316 t #2 global.max$ substring$ 't :=
317 }
318 { { t #1 #1 substring$ "-" = }
319 { "-" *
320 t #2 global.max$ substring$ 't :=
321 }
322 while$
323 }
324 if$
325 }
326 { t #1 #1 substring$ *
327 t #2 global.max$ substring$ 't :=
328 }
329 if$
330 }
331 while$
332 }
333
334 FUNCTION {format.btitle}
335 { title emphasize
336 }
337
338 FUNCTION {tie.or.space.connect}
339 { duplicate$ text.length$ #3 <
340 { "~" }
341 { " " }
342 if$
343 swap$ * *
344 }
345
346 FUNCTION {either.or.check}
347 { empty$
348 'pop$
349 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
350 if$
351 }
352
353 FUNCTION {format.bvolume}
354 { volume empty$
355 { "" }
356 { "volume" volume tie.or.space.connect
357 series empty$
358 'skip$
359 { " of " * series emphasize * }
360 if$
361 "volume and number" number either.or.check
362 }
363 if$
364 }
365
366 FUNCTION {format.number.series}
367 { volume empty$
368 { number empty$
369 { series field.or.null }
370 { output.state mid.sentence =
371 { "number" }
372 { "Number" }
373 if$
374 number tie.or.space.connect
375 series empty$
376 { "there's a number but no series in " cite$ * warning$ }
377 { " in " * series * }
378 if$
379 }
380 if$
381 }
382 { "" }
383 if$
384 }
385
386 FUNCTION {format.edition}
387 { edition empty$
388 { "" }
389 { output.state mid.sentence =
390 { edition "l" change.case$ " edition" * }
391 { edition "t" change.case$ " edition" * }
392 if$
393 }
394 if$
395 }
396
397 INTEGERS { multiresult }
398
399 FUNCTION {multi.page.check}
400 { 't :=
401 #0 'multiresult :=
402 { multiresult not
403 t empty$ not
404 and
405 }
406 { t #1 #1 substring$
407 duplicate$ "-" =
408 swap$ duplicate$ "," =
409 swap$ "+" =
410 or or
411 { #1 'multiresult := }
412 { t #2 global.max$ substring$ 't := }
413 if$
414 }
415 while$
416 multiresult
417 }
418
419 FUNCTION {format.pages}
420 { pages empty$
421 { "" }
422 { pages multi.page.check
423 { "pp." pages n.dashify tie.or.space.connect }
424 { "p." pages tie.or.space.connect }
425 if$
426 }
427 if$
428 }
429
430 FUNCTION {format.vol.num.pages}
431 { volume field.or.null
432 number empty$
433 'skip$
434 { "(" number * ")" * *
435 volume empty$
436 { "there's a number but no volume in " cite$ * warning$ }
437 'skip$
438 if$
439 }
440 if$
441 pages empty$
442 'skip$
443 { duplicate$ empty$
444 { pop$ format.pages }
445 { ", " * pages n.dashify * } % change the comma to : back if needed
446 if$
447 }
448 if$
449 }
450
451 FUNCTION {format.chapter.pages}
452 { chapter empty$
453 'format.pages
454 { type empty$
455 { "chapter" }
456 { type "l" change.case$ }
457 if$
458 chapter tie.or.space.connect
459 pages empty$
460 'skip$
461 { ", " * format.pages * }
462 if$
463 }
464 if$
465 }
466
467 FUNCTION {format.in.ed.booktitle}
468 { booktitle empty$
469 { "" }
470 { editor empty$
471 { "\textit{In:} " booktitle emphasize * }
472 { "\textit{In:} " format.editors * ", " * booktitle emphasize * }
473 if$
474 }
475 if$
476 }
477
478 FUNCTION {format.thesis.type}
479 { type empty$
480 'skip$
481 { pop$
482 type "t" change.case$
483 }
484 if$
485 }
486
487 FUNCTION {format.tr.number}
488 { type empty$
489 { "Technical Report" }
490 'type
491 if$
492 number empty$
493 { "t" change.case$ }
494 { number tie.or.space.connect }
495 if$
496 }
497
498 FUNCTION {format.article.crossref}
499 { "In" % this is for apalike
500 " \cite{" * crossref * "}" *
501 }
502
503 FUNCTION {format.book.crossref}
504 { volume empty$
505 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
506 "(\textit{In:}) "
507 }
508 { "Volume" volume tie.or.space.connect
509 " of " *
510 }
511 if$
512 "\cite{" * crossref * "}" * % this is for apalike
513 }
514
515 FUNCTION {format.incoll.inproc.crossref}
516 { "\textit{In:}" % this is for apalike
517 " \cite{" * crossref * "}" *
518 }
519
520 FUNCTION {article}
521 { output.bibitem
522 format.authors "author" output.check
523 author format.key output % special for
524 output.year.check % apalike
525 add.blank % was new.block originally
526 format.title "title" output.check
527 new.block
528 crossref missing$
529 { journal emphasize "journal" output.check
530 format.vol.num.pages output
531 }
532 { format.article.crossref output.nonnull
533 format.pages output
534 }
535 if$
536 new.block
537 note output
538 fin.entry
539 }
540
541 FUNCTION {book}
542 { output.bibitem
543 author empty$
544 { format.editors "author and editor" output.check
545 editor format.key output
546 }
547 { format.authors output.nonnull
548 crossref missing$
549 { "author and editor" editor either.or.check }
550 'skip$
551 if$
552 }
553 if$
554 output.year.check % special for apalike
555 add.blank % was new.block originally
556 format.btitle "title" output.check
557 crossref missing$
558 { format.bvolume output
559 new.block
560 format.number.series output
561 new.sentence
562 publisher "publisher" output.check
563 address output
564 }
565 { new.block
566 format.book.crossref output.nonnull
567 }
568 if$
569 format.edition output
570 new.block
571 note output
572 fin.entry
573 }
574
575 FUNCTION {booklet}
576 { output.bibitem
577 format.authors output
578 author format.key output % special for
579 output.year.check % apalike
580 add.blank % was new.block originally
581 format.title "title" output.check
582 new.block
583 howpublished output
584 address output
585 new.block
586 note output
587 fin.entry
588 }
589
590 FUNCTION {inbook}
591 { output.bibitem
592 author empty$
593 { format.editors "author and editor" output.check
594 editor format.key output
595 }
596 { format.authors output.nonnull
597 crossref missing$
598 { "author and editor" editor either.or.check }
599 'skip$
600 if$
601 }
602 if$
603 output.year.check % special for apalike
604 add.blank % was new.block originally
605 format.btitle "title" output.check
606 crossref missing$
607 { format.bvolume output
608 new.block
609 format.number.series output
610 new.sentence
611 publisher "publisher" output.check
612 address output
613 format.chapter.pages "chapter and pages" output.check
614 }
615 { new.block
616 format.book.crossref output.nonnull
617 format.chapter.pages "chapter and pages" output.check
618 }
619 if$
620 format.edition output
621 new.block
622 note output
623 fin.entry
624 }
625
626 FUNCTION {incollection}
627 { output.bibitem
628 format.authors "author" output.check
629 author format.key output % special for
630 output.year.check % apalike
631 add.blank % was new.block originally
632 format.title "title" output.check
633 new.block
634 crossref missing$
635 { format.in.ed.booktitle "booktitle" output.check
636 format.bvolume output
637 format.number.series output
638 new.sentence
639 publisher "publisher" output.check
640 address output
641 format.edition output
642 format.chapter.pages output
643 }
644 { format.incoll.inproc.crossref output.nonnull
645 format.chapter.pages output
646 }
647 if$
648 new.block
649 note output
650 fin.entry
651 }
652
653 FUNCTION {inproceedings}
654 { output.bibitem
655 format.authors "author" output.check
656 author format.key output % special for
657 output.year.check % apalike
658 add.blank % was new.block originally
659 format.title "title" output.check
660 new.block
661 crossref missing$
662 { format.in.ed.booktitle "booktitle" output.check
663 format.bvolume output
664 format.number.series output
665 address output % for apalike
666 new.sentence % there's no year
667 organization output % here so things
668 publisher output % are simpler
669 format.pages output
670 }
671 { format.incoll.inproc.crossref output.nonnull
672 format.pages output
673 }
674 if$
675 new.block
676 note output
677 fin.entry
678 }
679
680 FUNCTION {conference} { inproceedings }
681
682 FUNCTION {manual}
683 { output.bibitem
684 format.authors output
685 author format.key output % special for
686 output.year.check % apalike
687 add.blank % was new.block originally
688 format.btitle "title" output.check
689 organization address new.block.checkb
690 organization output
691 address output
692 format.edition output
693 new.block
694 note output
695 fin.entry
696 }
697
698 FUNCTION {mastersthesis}
699 { output.bibitem
700 format.authors "author" output.check
701 author format.key output % special for
702 output.year.check % apalike
703 add.blank % was new.block originally
704 format.title "title" output.check
705 new.block
706 "Master's thesis" format.thesis.type output.nonnull
707 school "school" output.check
708 address output
709 new.block
710 note output
711 fin.entry
712 }
713
714 FUNCTION {misc}
715 { output.bibitem
716 format.authors output
717 author format.key output % special for
718 output.year.check % apalike
719 add.blank % was new.block originally
720 format.title output
721 new.block
722 howpublished output
723 new.block
724 output.url % this defines the url from the field in reference type misc
725 new.block
726 output.urldate
727 fin.entry
728 }
729
730 FUNCTION {phdthesis}
731 { output.bibitem
732 format.authors "author" output.check
733 author format.key output % special for
734 output.year.check % apalike
735 add.blank % was new.block originally
736 format.btitle "title" output.check
737 new.block
738 "PhD thesis" format.thesis.type output.nonnull
739 school "school" output.check
740 address output
741 new.block
742 note output
743 fin.entry
744 }
745
746 FUNCTION {proceedings}
747 { output.bibitem
748 format.editors output
749 editor format.key output % special for
750 output.year.check % apalike
751 add.blank % was new.block originally
752 format.btitle "title" output.check
753 format.bvolume output
754 format.number.series output
755 address output % for apalike
756 new.sentence % we always output
757 organization output % a nonempty organization
758 publisher output % here
759 new.block
760 note output
761 fin.entry
762 }
763
764 FUNCTION {techreport}
765 { output.bibitem
766 format.authors "author" output.check
767 author format.key output % special for
768 output.year.check % apalike
769 add.blank % was new.block originally
770 format.title "title" output.check
771 new.block
772 format.tr.number output.nonnull
773 institution "institution" output.check
774 address output
775 new.block
776 note output
777 fin.entry
778 }
779
780 FUNCTION {unpublished}
781 { output.bibitem
782 format.authors "author" output.check
783 author format.key output % special for
784 output.year.check % apalike
785 add.blank % was new.block originally
786 format.title "title" output.check
787 new.block
788 note "note" output.check
789 fin.entry
790 }
791
792 FUNCTION {default.type} { misc }
793
794 MACRO {jan} {"January"}
795
796 MACRO {feb} {"February"}
797
798 MACRO {mar} {"March"}
799
800 MACRO {apr} {"April"}
801
802 MACRO {may} {"May"}
803
804 MACRO {jun} {"June"}
805
806 MACRO {jul} {"July"}
807
808 MACRO {aug} {"August"}
809
810 MACRO {sep} {"September"}
811
812 MACRO {oct} {"October"}
813
814 MACRO {nov} {"November"}
815
816 MACRO {dec} {"December"}
817
818 MACRO {acmcs} {"ACM Computing Surveys"}
819
820 MACRO {acta} {"Acta Informatica"}
821
822 MACRO {cacm} {"Communications of the ACM"}
823
824 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
825
826 MACRO {ibmsj} {"IBM Systems Journal"}
827
828 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
829
830 MACRO {ieeetc} {"IEEE Transactions on Computers"}
831
832 MACRO {ieeetcad}
833 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
834
835 MACRO {ipl} {"Information Processing Letters"}
836
837 MACRO {jacm} {"Journal of the ACM"}
838
839 MACRO {jcss} {"Journal of Computer and System Sciences"}
840
841 MACRO {scp} {"Science of Computer Programming"}
842
843 MACRO {sicomp} {"SIAM Journal on Computing"}
844
845 MACRO {tocs} {"ACM Transactions on Computer Systems"}
846
847 MACRO {tods} {"ACM Transactions on Database Systems"}
848
849 MACRO {tog} {"ACM Transactions on Graphics"}
850
851 MACRO {toms} {"ACM Transactions on Mathematical Software"}
852
853 MACRO {toois} {"ACM Transactions on Office Information Systems"}
854
855 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
856
857 MACRO {tcs} {"Theoretical Computer Science"}
858
859 READ
860
861 FUNCTION {sortify}
862 { purify$
863 "l" change.case$
864 }
865
866 INTEGERS { len }
867
868 FUNCTION {chop.word}
869 { 's :=
870 'len :=
871 s #1 len substring$ =
872 { s len #1 + global.max$ substring$ }
873 's
874 if$
875 }
876
877 % There are three apalike cases: one person (Jones),
878 % two (Jones and de~Bruijn), and more (Jones et~al.).
879 % This function is much like format.crossref.editors.
880 %
881 FUNCTION {format.lab.names}
882 { 's :=
883 s #1 "{vv~}{ll}" format.name$
884 s num.names$ duplicate$
885 #2 >
886 { pop$ " \textit{et~al.}" * }
887 { #2 <
888 'skip$
889 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
890 { " \textit{et~al.}" * }
891 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
892 if$
893 }
894 if$
895 }
896 if$
897 }
898
899 FUNCTION {author.key.label}
900 { author empty$
901 { key empty$
902 { cite$ #1 #3 substring$ }
903 'key % apalike uses the whole key
904 if$
905 }
906 { author format.lab.names }
907 if$
908 }
909
910 FUNCTION {author.editor.key.label}
911 { author empty$
912 { editor empty$
913 { key empty$
914 { cite$ #1 #3 substring$ }
915 'key % apalike uses the whole key
916 if$
917 }
918 { editor format.lab.names }
919 if$
920 }
921 { author format.lab.names }
922 if$
923 }
924
925 FUNCTION {editor.key.label}
926 { editor empty$
927 { key empty$
928 { cite$ #1 #3 substring$ }
929 'key % apalike uses the whole key, no organization
930 if$
931 }
932 { editor format.lab.names }
933 if$
934 }
935
936 FUNCTION {calc.label} % this function came from ASTRON.BST (ARR)
937 { type$ "book" =
938 type$ "inbook" =
939 or
940 'author.editor.key.label
941 { type$ "proceedings" =
942 'editor.key.label % apalike ignores organization
943 'author.key.label % for labeling and sorting
944 if$
945 }
946 if$
947 "\protect\astroncite{" swap$ * "}{" % these three lines are
948 * % for apalike, which
949 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
950 * % the mathing closing "}" comes in at the reverse.pass
951 'label :=
952 }
953
954 FUNCTION {sort.format.names}
955 { 's :=
956 #1 'nameptr :=
957 ""
958 s num.names$ 'numnames :=
959 numnames 'namesleft :=
960 { namesleft #0 > }
961 { nameptr #1 >
962 { " " * }
963 'skip$
964 if$ % apalike uses initials
965 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
966 nameptr numnames = t "others" = and
967 { "\textit{et al.}" * }
968 { t sortify * }
969 if$
970 nameptr #1 + 'nameptr :=
971 namesleft #1 - 'namesleft :=
972 }
973 while$
974 }
975
976 FUNCTION {sort.format.title}
977 { 't :=
978 "A " #2
979 "An " #3
980 "The " #4 t chop.word
981 chop.word
982 chop.word
983 sortify
984 #1 global.max$ substring$
985 }
986
987 FUNCTION {author.sort}
988 { author empty$
989 { key empty$
990 { "to sort, need author or key in " cite$ * warning$
991 ""
992 }
993 { key sortify }
994 if$
995 }
996 { author sort.format.names }
997 if$
998 }
999
1000 FUNCTION {author.editor.sort}
1001 { author empty$
1002 { editor empty$
1003 { key empty$
1004 { "to sort, need author, editor, or key in " cite$ * warning$
1005 ""
1006 }
1007 { key sortify }
1008 if$
1009 }
1010 { editor sort.format.names }
1011 if$
1012 }
1013 { author sort.format.names }
1014 if$
1015 }
1016
1017 FUNCTION {editor.sort}
1018 { editor empty$
1019 { key empty$
1020 { "to sort, need editor or key in " cite$ * warning$
1021 ""
1022 }
1023 { key sortify }
1024 if$
1025 }
1026 { editor sort.format.names }
1027 if$
1028 }
1029
1030 % apalike uses two sorting passes; the first one sets the
1031 % labels so that the `a's, `b's, etc. can be computed;
1032 % the second pass puts the references in "correct" order.
1033 % The presort function is for the first pass. It computes
1034 % label, sort.label, and title, and then concatenates.
1035 FUNCTION {presort}
1036 { calc.label
1037 label sortify
1038 " "
1039 *
1040 type$ "book" =
1041 type$ "inbook" =
1042 or
1043 'author.editor.sort
1044 { type$ "proceedings" =
1045 'editor.sort
1046 'author.sort
1047 if$
1048 }
1049 if$
1050 #1 entry.max$ substring$ % for
1051 'sort.label := % apalike
1052 sort.label % style
1053 *
1054 " "
1055 *
1056 title field.or.null
1057 sort.format.title
1058 *
1059 #1 entry.max$ substring$
1060 'sort.key$ :=
1061 }
1062
1063 ITERATE {presort}
1064
1065 SORT % by label, sort.label, title---for final label calculation
1066
1067 STRINGS { last.label next.extra } % apalike labels are only for the text;
1068
1069 INTEGERS { last.extra.num } % there are none in the bibliography
1070
1071 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1072 { #0 int.to.chr$ 'last.label :=
1073 "" 'next.extra :=
1074 #0 'last.extra.num :=
1075 }
1076
1077 FUNCTION {forward.pass}
1078 { last.label label =
1079 { last.extra.num #1 + 'last.extra.num :=
1080 last.extra.num int.to.chr$ 'extra.label :=
1081 }
1082 { "a" chr.to.int$ 'last.extra.num :=
1083 "" 'extra.label :=
1084 label 'last.label :=
1085 }
1086 if$
1087 }
1088
1089 FUNCTION {reverse.pass} % this function came from ASTRON.BST (ARR)
1090 { next.extra "b" =
1091 { "a" 'extra.label := }
1092 'skip$
1093 if$
1094 label extra.label * "}" * 'label :=
1095 extra.label 'next.extra :=
1096 }
1097
1098 EXECUTE {initialize.extra.label.stuff}
1099
1100 ITERATE {forward.pass}
1101
1102 REVERSE {reverse.pass}
1103
1104 % Now that the label is right we sort for real,
1105 % on sort.label then year then title. This is
1106 % for the second sorting pass.
1107 FUNCTION {bib.sort.order}
1108 { sort.label
1109 " "
1110 *
1111 year field.or.null sortify
1112 *
1113 " "
1114 *
1115 title field.or.null
1116 sort.format.title
1117 *
1118 #1 entry.max$ substring$
1119 'sort.key$ :=
1120 }
1121
1122 ITERATE {bib.sort.order}
1123
1124 SORT % by sort.label, year, title---giving final bibliography order
1125
1126 FUNCTION {begin.bib}
1127 { preamble$ empty$ % no \etalchar in apalike
1128 'skip$
1129 { preamble$ write$ newline$ }
1130 if$
1131 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1132 }
1133
1134 EXECUTE {begin.bib}
1135
1136 EXECUTE {init.state.consts}
1137
1138 ITERATE {call.type$}
1139
1140 FUNCTION {end.bib}
1141 { newline$
1142 "\end{thebibliography}" write$ newline$
1143 }
1144
1145 EXECUTE {end.bib}