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.
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.
9 % Differences between this style and `alpha' are generally heralded by a `%'.
10 % The file btxbst.doc has the documentation for alpha.bst.
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.
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.
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 % 07/09/14 (SG) Adapted for PHD thesis.
43 % 29/04/15 (SG) Remove sorting.
56 % month not used in apalike
70 { label extra.label sort.label }
72 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
74 FUNCTION {init.state.consts}
83 FUNCTION {output.nonnull}
85 output.state mid.sentence =
87 { output.state after.block =
92 { output.state before.all =
94 { add.period$ " " * write$ }
98 mid.sentence 'output.state :=
111 FUNCTION {output.check}
114 { pop$ "empty " t * " in " * cite$ * warning$ }
119 % apalike needs this function because
120 % the year has special punctuation;
121 % apalike ignores the month
122 FUNCTION {output.year.check}
124 { "empty year in " cite$ * warning$ }
126 " (" year * extra.label * ")" *
127 mid.sentence 'output.state :=
132 FUNCTION {output.bibitem}
141 before.all 'output.state :=
151 { output.state before.all =
153 { after.block 'output.state := }
157 FUNCTION {new.sentence}
158 { output.state after.block =
160 { output.state before.all =
162 { after.sentence 'output.state := }
186 FUNCTION {new.block.checkb}
195 FUNCTION {field.or.null}
205 { "\phdthesisbibemph{" swap$ * "}" * }
209 INTEGERS { nameptr namesleft numnames sortcounter}
211 FUNCTION {format.names}
214 s num.names$ 'numnames :=
215 numnames 'namesleft :=
217 { s nameptr "{ll}" format.name$
218 purify$ "l" change.case$ 'nt :=
219 s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=
220 "\underlineifauthor{" nt * "}{" * t * "}" * 't :=
225 { ", \phdthesisbiband" * }
226 { ", \phdthesisbiband" * t * }
233 nameptr #1 + 'nameptr :=
234 namesleft #1 - 'namesleft :=
239 FUNCTION {format.authors}
242 { author format.names }
246 FUNCTION {format.key} % this function is just for apalike
248 { key field.or.null }
253 FUNCTION {format.editors}
256 { editor format.names
257 editor num.names$ #1 >
258 { ", \phdthesisbibeditors" * }
259 { ", \phdthesisbibeditor" * }
265 FUNCTION {format.title}
268 { "\phdthesisbibEmph{" title "t" change.case$ * "}" * }
276 { t #1 #1 substring$ "-" =
277 { t #1 #2 substring$ "--" = not
279 t #2 global.max$ substring$ 't :=
281 { { t #1 #1 substring$ "-" = }
283 t #2 global.max$ substring$ 't :=
289 { t #1 #1 substring$ *
290 t #2 global.max$ substring$ 't :=
297 FUNCTION {format.btitle}
298 { "\phdthesisbibEmph{" title * "}" *
301 FUNCTION {tie.or.space.connect}
302 { duplicate$ text.length$ #3 <
309 FUNCTION {either.or.check}
312 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
316 FUNCTION {format.bvolume}
319 { "\phdthesisbibvolume" volume tie.or.space.connect
322 { " \phdthesisbibof " * series emphasize * }
324 "\phdthesisbibvolumenumber" number either.or.check
329 FUNCTION {format.number.series}
332 { series field.or.null }
333 { output.state mid.sentence =
334 { "\phdthesisbibnumber" }
335 { "\phdthesisbibNumber" }
337 number tie.or.space.connect
339 { "there's a number but no series in " cite$ * warning$ }
340 { " \phdthesisbibin " * series * }
349 FUNCTION {format.edition}
352 { output.state mid.sentence =
353 { edition "l" change.case$ " \phdthesisbibedition" * }
354 { edition "t" change.case$ " \phdthesisbibedition" * }
360 INTEGERS { multiresult }
362 FUNCTION {multi.page.check}
371 swap$ duplicate$ "," =
374 { #1 'multiresult := }
375 { t #2 global.max$ substring$ 't := }
382 FUNCTION {format.pages}
385 { pages multi.page.check
386 { "\phdthesisbibpages" pages n.dashify tie.or.space.connect }
387 { "\phdthesisbibpage" pages tie.or.space.connect }
393 FUNCTION {format.vol.num.pages}
394 { volume field.or.null
397 { "(" number * ")" * *
399 { "there's a number but no volume in " cite$ * warning$ }
407 { pop$ format.pages }
408 { ":" * pages n.dashify * }
414 FUNCTION {format.chapter.pages}
418 { "\phdthesisbibchapter" }
419 { type "l" change.case$ }
421 chapter tie.or.space.connect
424 { ", " * format.pages * }
430 FUNCTION {format.in.ed.booktitle}
434 { "\phdthesisbibIn " booktitle emphasize * }
435 { "\phdthesisbibIn " format.editors * ", " * booktitle emphasize * }
441 FUNCTION {format.thesis.type}
445 type "t" change.case$
450 FUNCTION {format.tr.number}
452 { "\phdthesisbibtechnicalreport" }
457 { number tie.or.space.connect }
461 FUNCTION {format.article.crossref}
462 { "\phdthesisbibIn\ " % this is for apalike
463 " \cite{" * crossref * "}" *
466 FUNCTION {format.book.crossref}
468 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
471 { "\phdthesisbibVolume" volume tie.or.space.connect
472 " \phdthesisbibof\ " *
475 "\cite{" * crossref * "}" * % this is for apalike
478 FUNCTION {format.incoll.inproc.crossref}
479 { "\phdthesisbibIn" % this is for apalike
480 " \cite{" * crossref * "}" *
485 format.authors "author" output.check
486 author format.key output % special for
487 output.year.check % apalike
489 format.title "title" output.check
492 { journal emphasize "journal" output.check
493 format.vol.num.pages output
495 { format.article.crossref output.nonnull
507 { format.editors "author and editor" output.check
508 editor format.key output
510 { format.authors output.nonnull
512 { "author and editor" editor either.or.check }
517 output.year.check % special for apalike
519 format.btitle "title" output.check
521 { format.bvolume output
523 format.number.series output
525 publisher "publisher" output.check
529 format.book.crossref output.nonnull
532 format.edition output
540 format.authors output
541 author format.key output % special for
542 output.year.check % apalike
544 format.title "title" output.check
556 { format.editors "author and editor" output.check
557 editor format.key output
559 { format.authors output.nonnull
561 { "author and editor" editor either.or.check }
566 output.year.check % special for apalike
568 format.btitle "title" output.check
570 { format.bvolume output
571 format.chapter.pages "chapter and pages" output.check
573 format.number.series output
575 publisher "publisher" output.check
578 { format.chapter.pages "chapter and pages" output.check
580 format.book.crossref output.nonnull
583 format.edition output
589 FUNCTION {incollection}
591 format.authors "author" output.check
592 author format.key output % special for
593 output.year.check % apalike
595 format.title "title" output.check
598 { format.in.ed.booktitle "booktitle" output.check
599 format.bvolume output
600 format.number.series output
601 format.chapter.pages output
603 publisher "publisher" output.check
605 format.edition output
607 { format.incoll.inproc.crossref output.nonnull
608 format.chapter.pages output
616 FUNCTION {inproceedings}
618 format.authors "author" output.check
619 author format.key output % special for
620 output.year.check % apalike
622 format.title "title" output.check
625 { format.in.ed.booktitle "booktitle" output.check
626 format.bvolume output
627 format.number.series output
629 address output % for apalike
630 new.sentence % there's no year
631 organization output % here so things
632 publisher output % are simpler
634 { format.incoll.inproc.crossref output.nonnull
643 FUNCTION {conference} { inproceedings }
647 format.authors output
648 author format.key output % special for
649 output.year.check % apalike
651 format.btitle "title" output.check
652 organization address new.block.checkb
655 format.edition output
661 FUNCTION {mastersthesis}
663 format.authors "author" output.check
664 author format.key output % special for
665 output.year.check % apalike
667 format.title "title" output.check
669 "Master's thesis" format.thesis.type output.nonnull
670 school "school" output.check
679 format.authors output
680 author format.key output % special for
681 output.year.check % apalike
693 format.authors "author" output.check
694 author format.key output % special for
695 output.year.check % apalike
697 format.btitle "title" output.check
699 "PhD thesis" format.thesis.type output.nonnull
700 school "school" output.check
707 FUNCTION {proceedings}
709 format.editors output
710 editor format.key output % special for
711 output.year.check % apalike
713 format.btitle "title" output.check
714 format.bvolume output
715 format.number.series output
716 address output % for apalike
717 new.sentence % we always output
718 organization output % a nonempty organization
719 publisher output % here
725 FUNCTION {techreport}
727 format.authors "author" output.check
728 author format.key output % special for
729 output.year.check % apalike
731 format.title "title" output.check
733 format.tr.number output.nonnull
734 institution "institution" output.check
741 FUNCTION {unpublished}
743 format.authors "author" output.check
744 author format.key output % special for
745 output.year.check % apalike
747 format.title "title" output.check
749 note "note" output.check
753 FUNCTION {default.type} { misc }
755 MACRO {jan} {"\phdthesisbibJanuary"}
757 MACRO {feb} {"\phdthesisbibFebruary"}
759 MACRO {mar} {"\phdthesisbibMarch"}
761 MACRO {apr} {"\phdthesisbibApril"}
763 MACRO {may} {"\phdthesisbibMay"}
765 MACRO {jun} {"\phdthesisbibJune"}
767 MACRO {jul} {"\phdthesisbibJuly"}
769 MACRO {aug} {"\phdthesisbibAugust"}
771 MACRO {sep} {"\phdthesisbibSeptember"}
773 MACRO {oct} {"\phdthesisbibOctober"}
775 MACRO {nov} {"\phdthesisbibNovember"}
777 MACRO {dec} {"\phdthesisbibDecember"}
779 MACRO {acmcs} {"ACM Computing Surveys"}
781 MACRO {acta} {"Acta Informatica"}
783 MACRO {cacm} {"Communications of the ACM"}
785 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
787 MACRO {ibmsj} {"IBM Systems Journal"}
789 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
791 MACRO {ieeetc} {"IEEE Transactions on Computers"}
794 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
796 MACRO {ipl} {"Information Processing Letters"}
798 MACRO {jacm} {"Journal of the ACM"}
800 MACRO {jcss} {"Journal of Computer and System Sciences"}
802 MACRO {scp} {"Science of Computer Programming"}
804 MACRO {sicomp} {"SIAM Journal on Computing"}
806 MACRO {tocs} {"ACM Transactions on Computer Systems"}
808 MACRO {tods} {"ACM Transactions on Database Systems"}
810 MACRO {tog} {"ACM Transactions on Graphics"}
812 MACRO {toms} {"ACM Transactions on Mathematical Software"}
814 MACRO {toois} {"ACM Transactions on Office Information Systems"}
816 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
818 MACRO {tcs} {"Theoretical Computer Science"}
832 s #1 len substring$ =
833 { s len #1 + global.max$ substring$ }
838 % There are three apalike cases: one person (Jones),
839 % two (Jones and de~Bruijn), and more (Jones et~al.).
840 % This function is much like format.crossref.editors.
842 % Note that if more than one name exist, the "et al." is output
843 FUNCTION {format.lab.names}
845 s #1 "{vv~}{ll}" format.name$
846 s num.names$ duplicate$
851 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
852 { " \phdthesisbibetal" * }
853 { " \phdthesisbiband\ " * s #2 "{vv~}{ll}" format.name$ * }
861 FUNCTION {author.key.label}
864 { cite$ #1 #3 substring$ }
865 'key % apalike uses the whole key
868 { author format.lab.names }
872 FUNCTION {author.editor.key.label}
876 { cite$ #1 #3 substring$ }
877 'key % apalike uses the whole key
880 { editor format.lab.names }
883 { author format.lab.names }
887 FUNCTION {editor.key.label}
890 { cite$ #1 #3 substring$ }
891 'key % apalike uses the whole key, no organization
894 { editor format.lab.names }
898 FUNCTION {calc.label}
902 'author.editor.key.label
903 { type$ "proceedings" =
904 'editor.key.label % apalike ignores organization
905 'author.key.label % for labeling and sorting
909 ", " % these three lines are
910 * % for apalike, which
911 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
916 FUNCTION {sort.format.names}
920 s num.names$ 'numnames :=
921 numnames 'namesleft :=
926 if$ % apalike uses initials
927 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
928 nameptr numnames = t "others" = and
932 nameptr #1 + 'nameptr :=
933 namesleft #1 - 'namesleft :=
938 FUNCTION {sort.format.title}
942 "The " #4 t chop.word
946 #1 global.max$ substring$
949 FUNCTION {author.sort}
952 { "to sort, need author or key in " cite$ * warning$
958 { author sort.format.names }
962 FUNCTION {author.editor.sort}
966 { "to sort, need author, editor, or key in " cite$ * warning$
972 { editor sort.format.names }
975 { author sort.format.names }
979 FUNCTION {editor.sort}
982 { "to sort, need editor or key in " cite$ * warning$
988 { editor sort.format.names }
992 % apalike uses two sorting passes; the first one sets the
993 % labels so that the `a's, `b's, etc. can be computed;
994 % the second pass puts the references in "correct" order.
995 % The presort function is for the first pass. It computes
996 % label, sort.label, and title, and then concatenates.
1006 { type$ "proceedings" =
1012 #1 entry.max$ substring$ % for
1013 'sort.label := % apalike
1021 #1 entry.max$ substring$
1027 %SORT % by label, sort.label, title---for final label calculation
1029 STRINGS { last.label next.extra } % apalike labels are only for the text;
1031 INTEGERS { last.extra.num } % there are none in the bibliography
1033 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1034 { #0 int.to.chr$ 'last.label :=
1036 #0 'last.extra.num :=
1039 FUNCTION {forward.pass}
1040 { last.label label =
1041 { last.extra.num #1 + 'last.extra.num :=
1042 last.extra.num int.to.chr$ 'extra.label :=
1044 { "a" chr.to.int$ 'last.extra.num :=
1046 label 'last.label :=
1051 FUNCTION {reverse.pass}
1053 { "a" 'extra.label := }
1056 label extra.label * 'label :=
1057 extra.label 'next.extra :=
1060 EXECUTE {initialize.extra.label.stuff}
1062 ITERATE {forward.pass}
1064 REVERSE {reverse.pass}
1066 % Now that the label is right we sort for real,
1067 % on sort.label then year then title. This is
1068 % for the second sorting pass.
1069 FUNCTION {bib.sort.order}
1073 year field.or.null sortify
1080 #1 entry.max$ substring$
1084 ITERATE {bib.sort.order}
1086 %SORT % by sort.label, year, title---giving final bibliography order
1088 FUNCTION {begin.bib}
1089 { preamble$ empty$ % no \etalchar in apalike
1091 { preamble$ write$ newline$ }
1093 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1098 EXECUTE {init.state.consts}
1100 ITERATE {call.type$}
1104 "\end{thebibliography}" write$ newline$