comparison writeup/mlapa.bst @ 406:a11274742088

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