Debian Codegraph @

texmf-dist/bibtex/bst/base/apalike.bst

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