2 % BibTeX `apalike' bibliography style (24-Jan-88 version)
3 % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
4 % Copyright (C) 1988, all rights reserved.
5 % Copying of this file is allowed, provided that if you make any changes at all
6 % you name it something other than `apalike.bst'.
7 % This restriction helps ensure that all copies are identical.
8 % Differences between this style and `alpha' are generally heralded by a `%'.
9 % The file btxbst.doc has the documentation for alpha.bst.
11 % This style should be used with the `apalike' LaTeX style (apalike.sty).
12 % \cite's come out like "(Jones, 1986)" in the text but there are no labels
13 % in the bibliography, and something like "(1986)" comes out immediately
14 % after the author. Author (and editor) names appear as last name, comma,
15 % initials. A `year' field is required for every entry, and so is either
16 % an author (or in some cases, an editor) field or a key field.
19 % Many journals require a style like `apalike', but I strongly, strongly,
20 % strongly recommend that you not use it if you have a choice---use something
21 % like `plain' instead. Mary-Claire van Leunen (A Handbook for Scholars,
22 % Knopf, 1979) argues convincingly that a style like `plain' encourages better
23 % writing than one like `apalike'. Furthermore the strongest arguments for
24 % using an author-date style like `apalike'---that it's "the most practical"
25 % (The Chicago Manual of Style, University of Chicago Press, thirteenth
26 % edition, 1982, pages 400--401)---fall flat on their face with the new
27 % computer-typesetting technology. For instance page 401 anachronistically
28 % states "The chief disadvantage of [a style like `plain'] is that additions
29 % or deletions cannot be made after the manuscript is typed without changing
30 % numbers in both text references and list." LaTeX sidesteps the disadvantage.
33 % 15-sep-86 (SK,OP) Original version, by Susan King and Oren Patashnik.
34 % 10-nov-86 (OP) Truncated the sort.key$ string to the correct length
35 % in bib.sort.order to eliminate error message.
36 % 24-jan-88 (OP) Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
37 % apalike now sorts by author, then year, then title;
38 % THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
51 % month not used in apalike
65 { label extra.label sort.label }
67 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
69 FUNCTION {init.state.consts}
78 FUNCTION {output.nonnull}
80 output.state mid.sentence =
82 { output.state after.block =
87 { output.state before.all =
89 { add.period$ " " * write$ }
93 mid.sentence 'output.state :=
106 FUNCTION {output.check}
109 { pop$ "empty " t * " in " * cite$ * warning$ }
114 % apalike needs this function because
115 % the year has special punctuation;
116 % apalike ignores the month
117 FUNCTION {output.year.check}
119 { "empty year in " cite$ * warning$ }
121 " (" year * extra.label * ")" *
122 mid.sentence 'output.state :=
127 FUNCTION {output.bibitem}
136 before.all 'output.state :=
146 { output.state before.all =
148 { after.block 'output.state := }
152 FUNCTION {new.sentence}
153 { output.state after.block =
155 { output.state before.all =
157 { after.sentence 'output.state := }
181 FUNCTION {new.block.checkb}
190 FUNCTION {field.or.null}
200 { "{\em " swap$ * "}" * }
204 INTEGERS { nameptr namesleft numnames }
206 FUNCTION {format.names}
209 s num.names$ 'numnames :=
210 numnames 'namesleft :=
212 { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := % last name first
229 nameptr #1 + 'nameptr :=
230 namesleft #1 - 'namesleft :=
235 FUNCTION {format.authors}
238 { author format.names }
242 FUNCTION {format.key} % this function is just for apalike
244 { key field.or.null }
249 FUNCTION {format.editors}
252 { editor format.names
253 editor num.names$ #1 >
261 FUNCTION {format.title}
264 { title "t" change.case$ }
272 { t #1 #1 substring$ "-" =
273 { t #1 #2 substring$ "--" = not
275 t #2 global.max$ substring$ 't :=
277 { { t #1 #1 substring$ "-" = }
279 t #2 global.max$ substring$ 't :=
285 { t #1 #1 substring$ *
286 t #2 global.max$ substring$ 't :=
293 FUNCTION {format.btitle}
297 FUNCTION {tie.or.space.connect}
298 { duplicate$ text.length$ #3 <
305 FUNCTION {either.or.check}
308 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
312 FUNCTION {format.bvolume}
315 { "volume" volume tie.or.space.connect
318 { " of " * series emphasize * }
320 "volume and number" number either.or.check
325 FUNCTION {format.number.series}
328 { series field.or.null }
329 { output.state mid.sentence =
333 number tie.or.space.connect
335 { "there's a number but no series in " cite$ * warning$ }
336 { " in " * series * }
345 FUNCTION {format.edition}
348 { output.state mid.sentence =
349 { edition "l" change.case$ " edition" * }
350 { edition "t" change.case$ " edition" * }
356 INTEGERS { multiresult }
358 FUNCTION {multi.page.check}
367 swap$ duplicate$ "," =
370 { #1 'multiresult := }
371 { t #2 global.max$ substring$ 't := }
378 FUNCTION {format.pages}
381 { pages multi.page.check
382 { "pages" pages n.dashify tie.or.space.connect }
383 { "page" pages tie.or.space.connect }
389 FUNCTION {format.vol.num.pages}
390 { volume field.or.null
393 { "(" number * ")" * *
395 { "there's a number but no volume in " cite$ * warning$ }
403 { pop$ format.pages }
404 { ":" * pages n.dashify * }
410 FUNCTION {format.chapter.pages}
415 { type "l" change.case$ }
417 chapter tie.or.space.connect
420 { ", " * format.pages * }
426 FUNCTION {format.in.ed.booktitle}
430 { "In " booktitle emphasize * }
431 { "In " format.editors * ", " * booktitle emphasize * }
437 FUNCTION {format.thesis.type}
441 type "t" change.case$
446 FUNCTION {format.tr.number}
448 { "Technical Report" }
453 { number tie.or.space.connect }
457 FUNCTION {format.article.crossref}
458 { "In" % this is for apalike
459 " \cite{" * crossref * "}" *
462 FUNCTION {format.book.crossref}
464 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
467 { "Volume" volume tie.or.space.connect
471 "\cite{" * crossref * "}" * % this is for apalike
474 FUNCTION {format.incoll.inproc.crossref}
475 { "In" % this is for apalike
476 " \cite{" * crossref * "}" *
481 format.authors "author" output.check
482 author format.key output % special for
483 output.year.check % apalike
485 format.title "title" output.check
488 { journal emphasize "journal" output.check
489 format.vol.num.pages output
491 { format.article.crossref output.nonnull
503 { format.editors "author and editor" output.check
504 editor format.key output
506 { format.authors output.nonnull
508 { "author and editor" editor either.or.check }
513 output.year.check % special for apalike
515 format.btitle "title" output.check
517 { format.bvolume output
519 format.number.series output
521 publisher "publisher" output.check
525 format.book.crossref output.nonnull
528 format.edition output
536 format.authors output
537 author format.key output % special for
538 output.year.check % apalike
540 format.title "title" output.check
552 { format.editors "author and editor" output.check
553 editor format.key output
555 { format.authors output.nonnull
557 { "author and editor" editor either.or.check }
562 output.year.check % special for apalike
564 format.btitle "title" output.check
566 { format.bvolume output
567 format.chapter.pages "chapter and pages" output.check
569 format.number.series output
571 publisher "publisher" output.check
574 { format.chapter.pages "chapter and pages" output.check
576 format.book.crossref output.nonnull
579 format.edition output
585 FUNCTION {incollection}
587 format.authors "author" output.check
588 author format.key output % special for
589 output.year.check % apalike
591 format.title "title" output.check
594 { format.in.ed.booktitle "booktitle" output.check
595 format.bvolume output
596 format.number.series output
597 format.chapter.pages output
599 publisher "publisher" output.check
601 format.edition output
603 { format.incoll.inproc.crossref output.nonnull
604 format.chapter.pages output
612 FUNCTION {inproceedings}
614 format.authors "author" output.check
615 author format.key output % special for
616 output.year.check % apalike
618 format.title "title" output.check
621 { format.in.ed.booktitle "booktitle" output.check
622 format.bvolume output
623 format.number.series output
625 address output % for apalike
626 new.sentence % there's no year
627 organization output % here so things
628 publisher output % are simpler
630 { format.incoll.inproc.crossref output.nonnull
639 FUNCTION {conference} { inproceedings }
643 format.authors output
644 author format.key output % special for
645 output.year.check % apalike
647 format.btitle "title" output.check
648 organization address new.block.checkb
651 format.edition output
657 FUNCTION {mastersthesis}
659 format.authors "author" output.check
660 author format.key output % special for
661 output.year.check % apalike
663 format.title "title" output.check
665 "Master's thesis" format.thesis.type output.nonnull
666 school "school" output.check
675 format.authors output
676 author format.key output % special for
677 output.year.check % apalike
689 format.authors "author" output.check
690 author format.key output % special for
691 output.year.check % apalike
693 format.btitle "title" output.check
695 "PhD thesis" format.thesis.type output.nonnull
696 school "school" output.check
703 FUNCTION {proceedings}
705 format.editors output
706 editor format.key output % special for
707 output.year.check % apalike
709 format.btitle "title" output.check
710 format.bvolume output
711 format.number.series output
712 address output % for apalike
713 new.sentence % we always output
714 organization output % a nonempty organization
715 publisher output % here
721 FUNCTION {techreport}
723 format.authors "author" output.check
724 author format.key output % special for
725 output.year.check % apalike
727 format.title "title" output.check
729 format.tr.number output.nonnull
730 institution "institution" output.check
737 FUNCTION {unpublished}
739 format.authors "author" output.check
740 author format.key output % special for
741 output.year.check % apalike
743 format.title "title" output.check
745 note "note" output.check
749 FUNCTION {default.type} { misc }
751 MACRO {jan} {"January"}
753 MACRO {feb} {"February"}
755 MACRO {mar} {"March"}
757 MACRO {apr} {"April"}
765 MACRO {aug} {"August"}
767 MACRO {sep} {"September"}
769 MACRO {oct} {"October"}
771 MACRO {nov} {"November"}
773 MACRO {dec} {"December"}
775 MACRO {acmcs} {"ACM Computing Surveys"}
777 MACRO {acta} {"Acta Informatica"}
779 MACRO {cacm} {"Communications of the ACM"}
781 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
783 MACRO {ibmsj} {"IBM Systems Journal"}
785 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
787 MACRO {ieeetc} {"IEEE Transactions on Computers"}
790 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
792 MACRO {ipl} {"Information Processing Letters"}
794 MACRO {jacm} {"Journal of the ACM"}
796 MACRO {jcss} {"Journal of Computer and System Sciences"}
798 MACRO {scp} {"Science of Computer Programming"}
800 MACRO {sicomp} {"SIAM Journal on Computing"}
802 MACRO {tocs} {"ACM Transactions on Computer Systems"}
804 MACRO {tods} {"ACM Transactions on Database Systems"}
806 MACRO {tog} {"ACM Transactions on Graphics"}
808 MACRO {toms} {"ACM Transactions on Mathematical Software"}
810 MACRO {toois} {"ACM Transactions on Office Information Systems"}
812 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
814 MACRO {tcs} {"Theoretical Computer Science"}
828 s #1 len substring$ =
829 { s len #1 + global.max$ substring$ }
834 % There are three apalike cases: one person (Jones),
835 % two (Jones and de~Bruijn), and more (Jones et~al.).
836 % This function is much like format.crossref.editors.
838 FUNCTION {format.lab.names}
840 s #1 "{vv~}{ll}" format.name$
841 s num.names$ duplicate$
846 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
848 { " and " * s #2 "{vv~}{ll}" format.name$ * }
856 FUNCTION {author.key.label}
859 { cite$ #1 #3 substring$ }
860 'key % apalike uses the whole key
863 { author format.lab.names }
867 FUNCTION {author.editor.key.label}
871 { cite$ #1 #3 substring$ }
872 'key % apalike uses the whole key
875 { editor format.lab.names }
878 { author format.lab.names }
882 FUNCTION {editor.key.label}
885 { cite$ #1 #3 substring$ }
886 'key % apalike uses the whole key, no organization
889 { editor format.lab.names }
893 FUNCTION {calc.label}
897 'author.editor.key.label
898 { type$ "proceedings" =
899 'editor.key.label % apalike ignores organization
900 'author.key.label % for labeling and sorting
904 ", " % these three lines are
905 * % for apalike, which
906 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
911 FUNCTION {sort.format.names}
915 s num.names$ 'numnames :=
916 numnames 'namesleft :=
921 if$ % apalike uses initials
922 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
923 nameptr numnames = t "others" = and
927 nameptr #1 + 'nameptr :=
928 namesleft #1 - 'namesleft :=
933 FUNCTION {sort.format.title}
937 "The " #4 t chop.word
941 #1 global.max$ substring$
944 FUNCTION {author.sort}
947 { "to sort, need author or key in " cite$ * warning$
953 { author sort.format.names }
957 FUNCTION {author.editor.sort}
961 { "to sort, need author, editor, or key in " cite$ * warning$
967 { editor sort.format.names }
970 { author sort.format.names }
974 FUNCTION {editor.sort}
977 { "to sort, need editor or key in " cite$ * warning$
983 { editor sort.format.names }
987 % apalike uses two sorting passes; the first one sets the
988 % labels so that the `a's, `b's, etc. can be computed;
989 % the second pass puts the references in "correct" order.
990 % The presort function is for the first pass. It computes
991 % label, sort.label, and title, and then concatenates.
1001 { type$ "proceedings" =
1007 #1 entry.max$ substring$ % for
1008 'sort.label := % apalike
1016 #1 entry.max$ substring$
1022 SORT % by label, sort.label, title---for final label calculation
1024 STRINGS { last.label next.extra } % apalike labels are only for the text;
1026 INTEGERS { last.extra.num } % there are none in the bibliography
1028 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1029 { #0 int.to.chr$ 'last.label :=
1031 #0 'last.extra.num :=
1034 FUNCTION {forward.pass}
1035 { last.label label =
1036 { last.extra.num #1 + 'last.extra.num :=
1037 last.extra.num int.to.chr$ 'extra.label :=
1039 { "a" chr.to.int$ 'last.extra.num :=
1041 label 'last.label :=
1046 FUNCTION {reverse.pass}
1048 { "a" 'extra.label := }
1051 label extra.label * 'label :=
1052 extra.label 'next.extra :=
1055 EXECUTE {initialize.extra.label.stuff}
1057 ITERATE {forward.pass}
1059 REVERSE {reverse.pass}
1061 % Now that the label is right we sort for real,
1062 % on sort.label then year then title. This is
1063 % for the second sorting pass.
1064 FUNCTION {bib.sort.order}
1068 year field.or.null sortify
1075 #1 entry.max$ substring$
1079 ITERATE {bib.sort.order}
1081 SORT % by sort.label, year, title---giving final bibliography order
1083 FUNCTION {begin.bib}
1084 { preamble$ empty$ % no \etalchar in apalike
1086 { preamble$ write$ newline$ }
1088 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1093 EXECUTE {init.state.consts}
1095 ITERATE {call.type$}
1099 "\end{thebibliography}" write$ newline$