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}
132 before.all 'output.state :=
142 { output.state before.all =
144 { after.block 'output.state := }
148 FUNCTION {new.sentence}
149 { output.state after.block =
151 { output.state before.all =
153 { after.sentence 'output.state := }
177 FUNCTION {new.block.checkb}
186 FUNCTION {field.or.null}
196 { "{\bf " swap$ * "}" * }
203 { "{\em " swap$ * "}" * }
207 INTEGERS { nameptr namesleft numnames }
209 FUNCTION {format.names}
212 s num.names$ 'numnames :=
213 numnames 'namesleft :=
216 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
217 { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := }
235 nameptr #1 + 'nameptr :=
236 namesleft #1 - 'namesleft :=
241 FUNCTION {format.ed.names}
244 s num.names$ 'numnames :=
245 numnames 'namesleft :=
248 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
249 { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't := }
267 nameptr #1 + 'nameptr :=
268 namesleft #1 - 'namesleft :=
273 FUNCTION {format.authors}
276 { author format.names }
280 FUNCTION {format.key}
282 { key field.or.null }
287 FUNCTION {format.editors}
290 { editor format.names
291 editor num.names$ #1 >
299 FUNCTION {format.editors.extra}
302 { editor format.ed.names
303 editor num.names$ #1 >
311 FUNCTION {format.title}
314 { "`" title "'" * * }
322 { t #1 #1 substring$ "-" =
323 { t #1 #2 substring$ "--" = not
325 t #2 global.max$ substring$ 't :=
327 { { t #1 #1 substring$ "-" = }
329 t #2 global.max$ substring$ 't :=
335 { t #1 #1 substring$ *
336 t #2 global.max$ substring$ 't :=
343 FUNCTION {first.page.number}
348 { t #1 #1 substring$ "-" = not }
351 { t #1 #1 substring$ *
352 t #2 global.max$ substring$ 't :=
357 FUNCTION {format.btitle}
361 FUNCTION {tie.or.space.connect}
362 { duplicate$ text.length$ #3 <
369 FUNCTION {either.or.check}
372 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
376 FUNCTION {format.bvolume}
379 { "Vol." volume tie.or.space.connect
382 { " of " * series emphasize * }
384 "volume and number" number either.or.check
389 FUNCTION {format.number.series}
392 { series field.or.null }
393 { output.state mid.sentence =
397 number tie.or.space.connect
399 { "there's a number but no series in " cite$ * warning$ }
400 { " in " * series * }
409 FUNCTION {format.edition}
412 { output.state mid.sentence =
413 { edition "l" change.case$ " edition" * }
414 { edition "t" change.case$ " edition" * }
420 INTEGERS { multiresult }
422 FUNCTION {multi.page.check}
431 swap$ duplicate$ "," =
434 { #1 'multiresult := }
435 { t #2 global.max$ substring$ 't := }
442 FUNCTION {format.pages}
445 { pages multi.page.check
446 { "pp." pages n.dashify tie.or.space.connect }
447 { "p." pages tie.or.space.connect }
453 FUNCTION {format.page}
456 { "p.~" pages first.page.number * }
460 FUNCTION {format.vol.num.pages}
461 { volume field.or.null
468 { "(" number * ")" * *
470 { "there's a number but no volume in " cite$ * warning$ }
478 { pop$ format.pages }
479 { ", " * pages n.dashify * }
485 FUNCTION {format.vol.num.page}
486 { volume field.or.null
493 { "(" number * ")" * *
495 { "there's a number but no volume in " cite$ * warning$ }
503 { pop$ format.pages }
504 { ", " * pages first.page.number * }
510 FUNCTION {format.chapter.pages}
515 { type "l" change.case$ }
517 chapter tie.or.space.connect
520 { ", " * format.pages * }
526 FUNCTION {format.in.ed.booktitle}
530 { "In: " booktitle emphasize * }
531 { "In: " format.editors.extra * ": " * booktitle emphasize * }
537 FUNCTION {format.in.booktitle.or.series}
541 { "In: " series emphasize * }
545 { "In: " booktitle emphasize * }
546 { "In: " format.editors.extra * ": " * booktitle emphasize * }
552 FUNCTION {format.thesis.type}
556 type "t" change.case$
561 FUNCTION {format.tr.number}
563 { "Technical Report" }
568 { number tie.or.space.connect }
572 FUNCTION {format.article.crossref}
574 " \cite{" * crossref * "}" *
577 FUNCTION {format.book.crossref}
579 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
582 { "Vol." volume tie.or.space.connect
586 "\cite{" * crossref * "}" *
589 FUNCTION {format.incoll.inproc.crossref}
591 " \cite{" * crossref * "}" *
596 format.authors "author" output.check
597 author format.key output
599 format.title "title" output.check
602 { journal emphasize "journal" output.check.extra
603 format.vol.num.pages output.extra
605 { format.article.crossref output.nonnull
617 { format.editors "author and editor" output.check
618 editor format.key output
620 { format.authors output.nonnull
622 { "author and editor" editor either.or.check }
628 format.btitle "title" output.check
630 { format.bvolume output
631 format.number.series output
635 { address ":" * output }
637 publisher "publisher" output.check.extra
640 format.book.crossref output.nonnull
643 format.edition output
651 format.authors output
652 author format.key output
654 format.btitle "title" output.check
666 { format.editors "author and editor" output.check
667 editor format.key output
669 { format.authors output.nonnull
671 { "author and editor" editor either.or.check }
677 format.btitle "title" output.check
679 { format.bvolume output
680 format.chapter.pages "chapter and pages" output.check
681 format.number.series output
685 { address ":" * output }
687 publisher "publisher" output.check.extra
689 { format.chapter.pages "chapter and pages" output.check
691 format.book.crossref output.nonnull
694 format.edition output
700 FUNCTION {incollection}
702 format.authors "author" output.check
703 author format.key output
705 format.title "title" output.check
708 { format.in.ed.booktitle "booktitle" output.check
709 format.bvolume output
710 format.number.series output
714 { address ":" * output }
716 publisher "publisher" output.check.extra
717 format.edition output
718 format.chapter.pages output
720 { format.incoll.inproc.crossref output.nonnull
721 format.chapter.pages output
729 FUNCTION {inproceedings}
731 format.authors "author" output.check
732 author format.key output
734 format.title "title" output.check
737 { format.in.booktitle.or.series "booktitle or series" output.check
738 format.bvolume output
743 { format.incoll.inproc.crossref output.nonnull
752 FUNCTION {conference} { inproceedings }
756 format.authors output
757 author format.key output
759 format.title "title" output.check
763 format.edition output
769 FUNCTION {mastersthesis}
771 format.authors "author" output.check
772 author format.key output
774 format.title "title" output.check
776 "Master's thesis" format.thesis.type output.nonnull
777 school "school" output.check
786 format.authors output
787 author format.key output
799 format.authors "author" output.check
800 author format.key output
802 format.title "title" output.check
804 "Ph.D. thesis" format.thesis.type output.nonnull
805 school "school" output.check
812 FUNCTION {proceedings}
814 format.editors output
815 editor format.key output
817 format.title "title" output.check
818 format.bvolume output
819 format.number.series output
823 { address ":" * output }
825 organization output.extra
832 FUNCTION {techreport}
834 format.authors "author" output.check
835 author format.key output
837 format.title "title" output.check
839 format.tr.number output.nonnull
840 institution "institution" output.check
847 FUNCTION {unpublished}
849 format.authors "author" output.check
850 author format.key output
852 format.title "title" output.check
854 note "note" output.check
858 FUNCTION {default.type} { misc }
876 MACRO {sep} {"Sept."}
896 s #1 len substring$ =
897 { s len #1 + global.max$ substring$ }
902 FUNCTION {format.lab.names}
904 s #1 "{vv~}{ll}" format.name$
905 s num.names$ duplicate$
910 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
912 { " and " * s #2 "{vv~}{ll}" format.name$ * }
920 FUNCTION {author.key.label}
923 { cite$ #1 #3 substring$ }
927 { author format.lab.names }
931 FUNCTION {author.editor.key.label}
935 { cite$ #1 #3 substring$ }
939 { editor format.lab.names }
942 { author format.lab.names }
946 FUNCTION {editor.key.label}
949 { cite$ #1 #3 substring$ }
953 { editor format.lab.names }
957 FUNCTION {calc.label}
961 'author.editor.key.label
962 { type$ "proceedings" =
970 year field.or.null purify$ #-1 #4 substring$
975 FUNCTION {sort.format.names}
979 s num.names$ 'numnames :=
980 numnames 'namesleft :=
986 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't :=
987 nameptr numnames = t "others" = and
991 nameptr #1 + 'nameptr :=
992 namesleft #1 - 'namesleft :=
997 FUNCTION {sort.format.title}
1001 "The " #4 t chop.word
1005 #1 global.max$ substring$
1008 FUNCTION {author.sort}
1011 { "to sort, need author or key in " cite$ * warning$
1017 { author sort.format.names }
1021 FUNCTION {author.editor.sort}
1025 { "to sort, need author, editor, or key in " cite$ * warning$
1031 { editor sort.format.names }
1034 { author sort.format.names }
1038 FUNCTION {editor.sort}
1041 { "to sort, need editor or key in " cite$ * warning$
1047 { editor sort.format.names }
1060 { type$ "proceedings" =
1066 #1 entry.max$ substring$
1075 #1 entry.max$ substring$
1081 SORT % by label, sort.label, title---for final label calculation
1083 STRINGS { last.label next.extra }
1085 INTEGERS { last.extra.num }
1087 FUNCTION {initialize.extra.label.stuff}
1088 { #0 int.to.chr$ 'last.label :=
1090 #0 'last.extra.num :=
1093 FUNCTION {forward.pass}
1094 { last.label label =
1095 { last.extra.num #1 + 'last.extra.num :=
1096 last.extra.num int.to.chr$ 'extra.label :=
1098 { "a" chr.to.int$ 'last.extra.num :=
1100 label 'last.label :=
1105 FUNCTION {reverse.pass}
1107 { "a" 'extra.label := }
1110 label extra.label * "}" * 'label :=
1111 extra.label 'next.extra :=
1114 EXECUTE {initialize.extra.label.stuff}
1116 ITERATE {forward.pass}
1118 REVERSE {reverse.pass}
1120 FUNCTION {bib.sort.order}
1124 year field.or.null sortify
1131 #1 entry.max$ substring$
1135 ITERATE {bib.sort.order}
1137 SORT % by sort.label, year, title---giving final bibliography order
1139 FUNCTION {begin.bib}
1142 { preamble$ write$ newline$ }
1144 "\begin{thebibliography}{00}" write$ newline$
1149 EXECUTE {init.state.consts}
1151 ITERATE {call.type$}
1155 "\end{thebibliography}" write$ newline$