1 % This style produces citations in the `author-year' format.
2 % It supports two forms of citation: the \cite command produces: (Author, year)
3 % in the text; the \cite* command only: (year) .
30 { label extra.label sort.label }
32 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
34 FUNCTION {init.state.consts}
43 FUNCTION {output.nonnull}
45 output.state mid.sentence =
47 { output.state after.block =
52 { output.state before.all =
54 { add.period$ " " * write$ }
58 mid.sentence 'output.state :=
64 FUNCTION {output.nonnull.extra}
66 output.state mid.sentence =
68 { output.state after.block =
73 { output.state before.all =
75 { add.period$ " " * write$ }
79 mid.sentence 'output.state :=
92 FUNCTION {output.extra}
99 FUNCTION {output.check}
102 { pop$ "empty " t * " in " * cite$ * warning$ }
107 FUNCTION {output.check.extra}
110 { pop$ "empty " t * " in " * cite$ * warning$ }
111 'output.nonnull.extra
115 FUNCTION {output.year.check}
117 { "empty year in " cite$ * warning$ }
119 ": " year * extra.label *
120 mid.sentence 'output.state :=
125 FUNCTION {output.bibitem}
134 before.all 'output.state :=
144 { output.state before.all =
146 { after.block 'output.state := }
150 FUNCTION {new.sentence}
151 { output.state after.block =
153 { output.state before.all =
155 { after.sentence 'output.state := }
179 FUNCTION {new.block.checkb}
188 FUNCTION {field.or.null}
198 { "{\bf " swap$ * "}" * }
205 { "{\em " swap$ * "}" * }
209 INTEGERS { nameptr namesleft numnames }
211 FUNCTION {format.names}
214 s num.names$ 'numnames :=
215 numnames 'namesleft :=
218 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
219 { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := }
237 nameptr #1 + 'nameptr :=
238 namesleft #1 - 'namesleft :=
243 FUNCTION {format.ed.names}
246 s num.names$ 'numnames :=
247 numnames 'namesleft :=
250 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
251 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
269 nameptr #1 + 'nameptr :=
270 namesleft #1 - 'namesleft :=
275 FUNCTION {format.authors}
278 { author format.names }
282 FUNCTION {format.key}
284 { key field.or.null }
289 FUNCTION {format.editors}
292 { editor format.names
293 editor num.names$ #1 >
301 FUNCTION {format.editors.extra}
304 { editor format.ed.names
305 editor num.names$ #1 >
313 FUNCTION {format.title}
316 { "`" title "'" * * }
324 { t #1 #1 substring$ "-" =
325 { t #1 #2 substring$ "--" = not
327 t #2 global.max$ substring$ 't :=
329 { { t #1 #1 substring$ "-" = }
331 t #2 global.max$ substring$ 't :=
337 { t #1 #1 substring$ *
338 t #2 global.max$ substring$ 't :=
345 FUNCTION {first.page.number}
350 { t #1 #1 substring$ "-" = not }
353 { t #1 #1 substring$ *
354 t #2 global.max$ substring$ 't :=
359 FUNCTION {format.btitle}
363 FUNCTION {tie.or.space.connect}
364 { duplicate$ text.length$ #3 <
371 FUNCTION {either.or.check}
374 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
378 FUNCTION {format.bvolume}
381 { "Vol." volume tie.or.space.connect
384 { " of " * series emphasize * }
386 "volume and number" number either.or.check
391 FUNCTION {format.number.series}
394 { series field.or.null }
395 { output.state mid.sentence =
399 number tie.or.space.connect
401 { "there's a number but no series in " cite$ * warning$ }
402 { " in " * series * }
411 FUNCTION {format.edition}
414 { output.state mid.sentence =
415 { edition "l" change.case$ " edition" * }
416 { edition "t" change.case$ " edition" * }
422 INTEGERS { multiresult }
424 FUNCTION {multi.page.check}
433 swap$ duplicate$ "," =
436 { #1 'multiresult := }
437 { t #2 global.max$ substring$ 't := }
444 FUNCTION {format.pages}
447 { pages multi.page.check
448 { "pp." pages n.dashify tie.or.space.connect }
449 { "p." pages tie.or.space.connect }
455 FUNCTION {format.page}
458 { "p.~" pages first.page.number * }
462 FUNCTION {format.vol.num.pages}
463 { volume field.or.null
470 { "(" number * ")" * *
472 { "there's a number but no volume in " cite$ * warning$ }
480 { pop$ format.pages }
481 { ", " * pages n.dashify * }
487 FUNCTION {format.vol.num.page}
488 { volume field.or.null
495 { "(" number * ")" * *
497 { "there's a number but no volume in " cite$ * warning$ }
505 { pop$ format.pages }
506 { ", " * pages first.page.number * }
512 FUNCTION {format.chapter.pages}
517 { type "l" change.case$ }
519 chapter tie.or.space.connect
522 { ", " * format.pages * }
528 FUNCTION {format.in.ed.booktitle}
532 { "In: " booktitle emphasize * }
533 { "In: " format.editors.extra * ": " * booktitle emphasize * }
539 FUNCTION {format.in.booktitle.or.series}
543 { "In: " series emphasize * }
547 { "In: " booktitle emphasize * }
548 { "In: " format.editors.extra * ": " * booktitle emphasize * }
554 FUNCTION {format.thesis.type}
558 type "t" change.case$
563 FUNCTION {format.tr.number}
565 { "Technical Report" }
570 { number tie.or.space.connect }
574 FUNCTION {format.article.crossref}
576 " \cite{" * crossref * "}" *
579 FUNCTION {format.book.crossref}
581 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
584 { "Vol." volume tie.or.space.connect
588 "\cite{" * crossref * "}" *
591 FUNCTION {format.incoll.inproc.crossref}
593 " \cite{" * crossref * "}" *
598 format.authors "author" output.check
599 author format.key output
601 format.title "title" output.check
604 { journal emphasize "journal" output.check.extra
605 format.vol.num.pages output.extra
607 { format.article.crossref output.nonnull
619 { format.editors "author and editor" output.check
620 editor format.key output
622 { format.authors output.nonnull
624 { "author and editor" editor either.or.check }
630 format.btitle "title" output.check
632 { format.bvolume output
633 format.number.series output
637 { address ":" * output }
639 publisher "publisher" output.check.extra
642 format.book.crossref output.nonnull
645 format.edition output
653 format.authors output
654 author format.key output
656 format.btitle "title" output.check
668 { format.editors "author and editor" output.check
669 editor format.key output
671 { format.authors output.nonnull
673 { "author and editor" editor either.or.check }
679 format.btitle "title" output.check
681 { format.bvolume output
682 format.chapter.pages "chapter and pages" output.check
683 format.number.series output
687 { address ":" * output }
689 publisher "publisher" output.check.extra
691 { format.chapter.pages "chapter and pages" output.check
693 format.book.crossref output.nonnull
696 format.edition output
702 FUNCTION {incollection}
704 format.authors "author" output.check
705 author format.key output
707 format.title "title" output.check
710 { format.in.ed.booktitle "booktitle" output.check
711 format.bvolume output
712 format.number.series output
716 { address ":" * output }
718 publisher "publisher" output.check.extra
719 format.edition output
720 format.chapter.pages output
722 { format.incoll.inproc.crossref output.nonnull
723 format.chapter.pages output
731 FUNCTION {inproceedings}
733 format.authors "author" output.check
734 author format.key output
736 format.title "title" output.check
739 { format.in.booktitle.or.series "booktitle or series" output.check
740 format.bvolume output
745 { format.incoll.inproc.crossref output.nonnull
754 FUNCTION {conference} { inproceedings }
758 format.authors output
759 author format.key output
761 format.title "title" output.check
765 format.edition output
771 FUNCTION {mastersthesis}
773 format.authors "author" output.check
774 author format.key output
776 format.title "title" output.check
778 "Master's thesis" format.thesis.type output.nonnull
779 school "school" output.check
788 format.authors output
789 author format.key output
801 format.authors "author" output.check
802 author format.key output
804 format.title "title" output.check
806 "Ph.D. thesis" format.thesis.type output.nonnull
807 school "school" output.check
814 FUNCTION {proceedings}
816 format.editors output
817 editor format.key output
819 format.title "title" output.check
820 format.bvolume output
821 format.number.series output
825 { address ":" * output }
827 organization output.extra
834 FUNCTION {techreport}
836 format.authors "author" output.check
837 author format.key output
839 format.title "title" output.check
841 format.tr.number output.nonnull
842 institution "institution" output.check
849 FUNCTION {unpublished}
851 format.authors "author" output.check
852 author format.key output
854 format.title "title" output.check
856 note "note" output.check
860 FUNCTION {default.type} { misc }
878 MACRO {sep} {"Sept."}
898 s #1 len substring$ =
899 { s len #1 + global.max$ substring$ }
904 FUNCTION {format.lab.names}
906 s #1 "{vv~}{ll}" format.name$
907 s num.names$ duplicate$
912 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
914 { " and " * s #2 "{vv~}{ll}" format.name$ * }
922 FUNCTION {author.key.label}
925 { cite$ #1 #3 substring$ }
929 { author format.lab.names }
933 FUNCTION {author.editor.key.label}
937 { cite$ #1 #3 substring$ }
941 { editor format.lab.names }
944 { author format.lab.names }
948 FUNCTION {editor.key.label}
951 { cite$ #1 #3 substring$ }
955 { editor format.lab.names }
959 FUNCTION {calc.label}
963 'author.editor.key.label
964 { type$ "proceedings" =
970 "\protect\citeauthoryear{" swap$ * "}{"
972 year field.or.null purify$ #-1 #4 substring$
977 FUNCTION {sort.format.names}
981 s num.names$ 'numnames :=
982 numnames 'namesleft :=
988 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't :=
989 nameptr numnames = t "others" = and
993 nameptr #1 + 'nameptr :=
994 namesleft #1 - 'namesleft :=
999 FUNCTION {sort.format.title}
1003 "The " #4 t chop.word
1007 #1 global.max$ substring$
1010 FUNCTION {author.sort}
1013 { "to sort, need author or key in " cite$ * warning$
1019 { author sort.format.names }
1023 FUNCTION {author.editor.sort}
1027 { "to sort, need author, editor, or key in " cite$ * warning$
1033 { editor sort.format.names }
1036 { author sort.format.names }
1040 FUNCTION {editor.sort}
1043 { "to sort, need editor or key in " cite$ * warning$
1049 { editor sort.format.names }
1062 { type$ "proceedings" =
1068 #1 entry.max$ substring$
1077 #1 entry.max$ substring$
1083 SORT % by label, sort.label, title---for final label calculation
1085 STRINGS { last.label next.extra }
1087 INTEGERS { last.extra.num }
1089 FUNCTION {initialize.extra.label.stuff}
1090 { #0 int.to.chr$ 'last.label :=
1092 #0 'last.extra.num :=
1095 FUNCTION {forward.pass}
1096 { last.label label =
1097 { last.extra.num #1 + 'last.extra.num :=
1098 last.extra.num int.to.chr$ 'extra.label :=
1100 { "a" chr.to.int$ 'last.extra.num :=
1102 label 'last.label :=
1107 FUNCTION {reverse.pass}
1109 { "a" 'extra.label := }
1112 label extra.label * "}" * 'label :=
1113 extra.label 'next.extra :=
1116 EXECUTE {initialize.extra.label.stuff}
1118 ITERATE {forward.pass}
1120 REVERSE {reverse.pass}
1122 FUNCTION {bib.sort.order}
1126 year field.or.null sortify
1133 #1 entry.max$ substring$
1137 ITERATE {bib.sort.order}
1139 SORT % by sort.label, year, title---giving final bibliography order
1141 FUNCTION {begin.bib}
1144 { preamble$ write$ newline$ }
1146 "\begin{thebibliography}{}" write$ newline$
1151 EXECUTE {init.state.consts}
1153 ITERATE {call.type$}
1157 "\end{thebibliography}" write$ newline$