1%%% ====================================================================
2%%%  @BibTeX-style-file{
3%%%     author          = "Glenn Paulley",
4%%%     version         = "4",
5%%%     date            = "28 August 1992",
6%%%     time            = "10:23:39 199",
7%%%     filename        = "chicago.bst",
8%%%     address         = "Data Structuring Group
9%%%                        Department of Computer Science
10%%%                        University of Waterloo
11%%%                        Waterloo, Ontario, Canada
12%%%                        N2L 3G1",
13%%%     telephone       = "(519) 885-1211",
14%%%     FAX             = "(519) 885-1208",
15%%%     checksum        = "26323 1654 5143 37417",
16%%%     email           = "gnpaulle@bluebox.uwaterloo.ca",
17%%%     codetable       = "ISO/ASCII",
18%%%     keywords        = "",
19%%%     supported       = "yes",
20%%%     abstract        = "A BibTeX bibliography style that follows the
21%%%                        `B' reference style of the 13th Edition of
22%%%                        the Chicago Manual of Style. A detailed
23%%%                        feature list is given below.",
24%%%     docstring       = "The checksum field above contains a CRC-16
25%%%                        checksum as the first value, followed by the
26%%%                        equivalent of the standard UNIX wc (word
27%%%                        count) utility output of lines, words, and
28%%%                        characters.  This is produced by Robert
29%%%                        Solovay's checksum utility.",
30%%%  }
31%%% ====================================================================
32%
33% "Chicago" BibTeX style, chicago.bst
34% ===================================
35%
36% BibTeX `chicago' style file for BibTeX version 0.99c, LaTeX version 2.09
37% Place it in a file called chicago.bst in the BibTeX search path.
38% You need to include chicago.sty as a \documentstyle option.
39% (Placing it in the same directory as the LaTeX document should also work.)
40% This "chicago" style is based on newapa.bst (American Psych. Assoc.)
41% found at ymir.claremont.edu.
42%
43%   Citation format: (author-last-name year)
44%             (author-last-name and author-last-name year)
45%             (author-last-name, author-last-name, and author-last-name year)
46%             (author-last-name et al. year)
47%             (author-last-name)
48%             author-last-name (year)
49%             (author-last-name and author-last-name)
50%             (author-last-name et al.)
51%             (year) or (year,year)
52%             year or year,year
53%
54%   Reference list ordering: alphabetical by author or whatever passes
55%    for author in the absence of one.
56%
57% This BibTeX style has support for abbreviated author lists and for
58%    year-only citations.  This is done by having the citations
59%    actually look like
60%
61%    \citeauthoryear{full-author-info}{abbrev-author-info}{year}
62%
63% The LaTeX style has to have the following (or similar)
64%
65%     \let\@internalcite\cite
66%     \def\fullcite{\def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
67%     \def\fullciteA{\def\citeauthoryear##1##2##3{##1}\@internalcite}
68%     \def\shortcite{\def\citeauthoryear##1##2##3{##2, ##3}\@internalcite}
69%     \def\shortciteA{\def\citeauthoryear##1##2##3{##2}\@internalcite}
70%     \def\citeyear{\def\citeauthoryear##1##2##3{##3}\@internalcite}
71%
72% These TeX macro definitions are found in chicago.sty. Additional
73% commands to manipulate different components of a citation can be defined
74% so that, for example, you can list author's names without parentheses
75% if using a citation as a noun or object in a sentence.
76%
77% This file was originally copied from newapa.bst at ymir.claremont.edu.
78%
79% Features of chicago.bst:
80% =======================
81%
82% - full names used in citations, but abbreviated citations are available
83%   (see above)
84% - if an entry has a "month", then the month and year are also printed
85%   as part of that bibitem.
86% - all conjunctions use "and" instead of "\&"
87% - major modification from Chicago Manual of Style (13th ed.) is that
88%   only the first author in a reference appears last name first-
89%   additional authors appear as J. Q. Public.
90% - pages are listed as "pp. xx-xx" in all entry types except
91%   article entries.
92% - book, inbook, and manual use "location: publisher" (or organization)
93%   for address and publisher. All other types list publishers separately.
94% - "pp." are used to identify page numbers for all entry types except
95%   articles.
96% - organization is used as a citation label if neither author nor editor
97%   is present (for manuals).
98% - "et al." is used for long author and editor lists, or when "others"
99%   is used.
100%
101% Modifications and bug fixes from newapa.bst:
102% ===========================================
103%
104%   - added month, year to bib entries if month is present
105%   - fixed bug with In proceedings, added necessary comma after title
106%   - all conjunctions changed to "and" from "\&"
107%   - fixed bug with author labels in my.full.label: "et al." now is
108%        generated when "others" is an author name
109%   - major modification from Chicago Manual of Style (13th ed.) is that
110%     only the first author in a reference appears last name first-
111%     additional authors appear as J. Q. Public.
112%   - pages are listed as "pp. xx-xx" in all entry types except
113%     article entries. Unnecessary (IMHO) "()" around page numbers
114%     were removed, and page numbers now don't end with a period.
115%   - created chicago.sty for use with this bibstyle (required).
116%   - fixed bugs in FUNCTION {format.vol.num.pages} for missing volume,
117%     number, and /or pages. Renamed to format.jour.vol.
118%   - fixed bug in formatting booktitles: additional period an error if
119%     book has a volume.
120%   - fixed bug: editors usually given redundant period before next clause
121%     (format.editors.dot) removed.
122%   - added label support for organizations, if both author and editor
123%     are missing (from alpha.bst). If organization is too long, then
124%     the key field is used for abbreviated citations.
125%   - In proceedings or books of several volumes, no comma was written
126%     between the "Volume x" and the page numbers (this was intentional
127%     in newapa.bst). Fixed.
128%   - Some journals may not have volumes/numbers, only month/year (eg.
129%     IEEE Computer). Fixed bug in article style that assumed volume/number
130%     was always present.
131%
132% Original documentation for newapa.sty:
133% =====================================
134%
135% This version was made by modifying the master file made by
136% Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU), and the 'named' BibTeX
137% style of Peter F. Patel-Schneider.
138%
139% Copyright (C) 1985, all rights reserved.
140% Copying of this file is authorized only if either
141% (1) you make absolutely no changes to your copy, including name, or
142% (2) if you do make changes, you name it something other than 'newapa.bst'.
143% There are undoubtably bugs in this style.  If you make bug fixes,
144% improvements, etc.  please let me know.  My e-mail address is:
145%    spencer@cgrg.ohio.state.edu or 71160.3141@compuserve.com
146%
147% This style was made from 'plain.bst', 'named.bst', and 'apalike.bst',
148% with lots of tweaking to make it look like APA style, along with tips
149% from Young Ryu and Brian Reiser's modifications of 'apalike.bst'.
150
151ENTRY
152  { address
153    author
154    booktitle
155    chapter
156    edition
157    editor
158    fjournal
159    howpublished
160    institution
161    journal
162    key
163    month
164    note
165    number
166    organization
167    pages
168    publisher
169    school
170    series
171    title
172    type
173    volume
174    year
175  }
176  {}
177  { label.year extra.label sort.year sort.label }
178
179INTEGERS { output.state before.all mid.sentence after.sentence after.block }
180
181FUNCTION {init.state.consts}
182{ #0 'before.all :=
183  #1 'mid.sentence :=
184  #2 'after.sentence :=
185  #3 'after.block :=
186}
187
188STRINGS { s t u }
189
190FUNCTION {output.nonnull}
191{ 's :=
192  output.state mid.sentence =
193    { ", " * write$ }
194    { output.state after.block =
195    { add.period$ write$
196      newline$
197      "\newblock " write$
198    }
199    { output.state before.all =
200        'write$
201        { add.period$ " " * write$ }
202      if$
203    }
204      if$
205      mid.sentence 'output.state :=
206    }
207  if$
208  s
209}
210
211% Use a colon to separate output. Used only for address/publisher
212% combination in book/inbook types, address/institution for manuals,
213% and organization:publisher for proceedings (inproceedings).
214%
215FUNCTION {output.nonnull.colon}
216{ 's :=
217  output.state mid.sentence =
218    { ": " * write$ }
219    { output.state after.block =
220    { add.period$ write$
221      newline$
222      "\newblock " write$
223    }
224    { output.state before.all =
225        'write$
226        { add.period$ " " * write$ }
227      if$
228    }
229      if$
230      mid.sentence 'output.state :=
231    }
232  if$
233  s
234}
235
236FUNCTION {output}
237{ duplicate$ empty$
238    'pop$
239    'output.nonnull
240  if$
241}
242
243FUNCTION {output.colon}
244{ duplicate$ empty$
245    'pop$
246    'output.nonnull.colon
247  if$
248}
249
250FUNCTION {output.check}
251{ 't :=
252  duplicate$ empty$
253    { pop$ "empty " t * " in " * cite$ * warning$ }
254    'output.nonnull
255  if$
256}
257
258FUNCTION {output.check.colon}
259{ 't :=
260  duplicate$ empty$
261    { pop$ "empty " t * " in " * cite$ * warning$ }
262    'output.nonnull.colon
263  if$
264}
265
266FUNCTION {output.year.check}
267{ year empty$
268     { "empty year in " cite$ * warning$ }
269     { write$
270        " (" year * extra.label *
271       month empty$
272          { ")" * }
273          { ", " * month * ")" * }
274       if$
275       mid.sentence 'output.state :=
276     }
277  if$
278}
279
280
281FUNCTION {fin.entry}
282{ add.period$
283  write$
284  newline$
285}
286
287FUNCTION {new.block}
288{ output.state before.all =
289    'skip$
290    { after.block 'output.state := }
291  if$
292}
293
294FUNCTION {new.sentence}
295{ output.state after.block =
296    'skip$
297    { output.state before.all =
298    'skip$
299    { after.sentence 'output.state := }
300      if$
301    }
302  if$
303}
304
305FUNCTION {not}
306{   { #0 }
307    { #1 }
308  if$
309}
310
311FUNCTION {and}
312{   'skip$
313    { pop$ #0 }
314  if$
315}
316
317FUNCTION {or}
318{   { pop$ #1 }
319    'skip$
320  if$
321}
322
323FUNCTION {new.block.checka}
324{ empty$
325    'skip$
326    'new.block
327  if$
328}
329
330FUNCTION {new.block.checkb}
331{ empty$
332  swap$ empty$
333  and
334    'skip$
335    'new.block
336  if$
337}
338
339FUNCTION {new.sentence.checka}
340{ empty$
341    'skip$
342    'new.sentence
343  if$
344}
345
346FUNCTION {new.sentence.checkb}
347{ empty$
348  swap$ empty$
349  and
350    'skip$
351    'new.sentence
352  if$
353}
354
355FUNCTION {field.or.null}
356{ duplicate$ empty$
357    { pop$ "" }
358    'skip$
359  if$
360}
361
362%
363% Emphasize the top string on the stack.
364%
365FUNCTION {emphasize}
366{ duplicate$ empty$
367    { pop$ "" }
368    { "{\em " swap$ * "}" * }
369  if$
370}
371
372%
373% Emphasize the top string on the stack, but add a trailing space.
374%
375FUNCTION {emphasize.space}
376{ duplicate$ empty$
377    { pop$ "" }
378    { "{\em " swap$ * "\/}" * }
379  if$
380}
381
382INTEGERS { nameptr namesleft numnames }
383%
384% Format bibliographical entries with the first author last name first,
385% and subsequent authors with initials followed by last name.
386% All names are formatted in this routine.
387%
388FUNCTION {format.names}
389{ 's :=
390  #1 'nameptr :=               % nameptr = 1;
391  s num.names$ 'numnames :=    % numnames = num.name$(s);
392  numnames 'namesleft :=
393    { namesleft #0 > }
394
395    { nameptr #1 =
396        {s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := }
397        {s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't := }
398      if$
399      nameptr #1 >
400        { namesleft #1 >
401              { ", " * t * }
402              { numnames #2 >
403                  { "," * }
404                  'skip$
405                if$
406                t "others" =
407                    { " et~al." * }
408                    { " and " * t * } % from Chicago Manual of Style
409                  if$
410               }
411               if$
412             }
413            't
414        if$
415        s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := 
416	"\protect \index {" * t * "|hyperemph}" *
417        nameptr #1 + 'nameptr :=          % nameptr += 1;
418        namesleft #1 - 'namesleft :=      % namesleft =- 1;
419    }
420  while$
421}
422
423FUNCTION {my.full.label}
424{ 's :=
425  #1 'nameptr :=               % nameptr = 1;
426  s num.names$ 'numnames :=    % numnames = num.name$(s);
427  numnames 'namesleft :=
428    { namesleft #0 > }
429
430    { s nameptr "{vv~}{ll}" format.name$ 't :=  % get the next name
431      nameptr #1 >
432        { namesleft #1 >
433              { ", " * t * }
434              { numnames #2 >
435                  { "," * }
436                  'skip$
437                if$
438                t "others" =
439                    { " et~al." * }
440                    { " and " * t * } % from Chicago Manual of Style
441                  if$
442               }
443               if$
444             }
445            't
446        if$
447        s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := 
448	"\protect \index {" * t * "|bold}" *
449        nameptr #1 + 'nameptr :=          % nameptr += 1;
450        namesleft #1 - 'namesleft :=      % namesleft =- 1;
451    }
452  while$
453
454}
455
456FUNCTION {format.names.fml}
457%
458% Format names in "familiar" format, with first initial followed by
459% last name. Like format.names, ALL names are formatted.
460%
461{ 's :=
462  #1 'nameptr :=               % nameptr = 1;
463  s num.names$ 'numnames :=    % numnames = num.name$(s);
464  numnames 'namesleft :=
465    { namesleft #0 > }
466
467    { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
468
469      nameptr #1 >
470        { namesleft #1 >
471              { ", " * t * }
472               { numnames #2 >
473                    { "," * }
474                    'skip$
475                  if$
476                  t "others" =
477                        { " et~al." * }
478                        { " and " * t * }
479%                       { " \& " * t * }
480                      if$
481                }
482               if$
483             }
484            't
485        if$
486        nameptr #1 + 'nameptr :=          % nameptr += 1;
487        namesleft #1 - 'namesleft :=      % namesleft =- 1;
488    }
489  while$
490}
491
492FUNCTION {format.authors}
493{ author empty$
494    { "" }
495    { author format.names }
496  if$
497}
498
499FUNCTION {format.key}
500{ empty$
501    { key field.or.null }
502    { "" }
503  if$
504}
505
506%
507% Format editor names for use in the "in" types: inbook, incollection,
508% inproceedings: first initial, then last names. When editors are the
509% LABEL for an entry, then format.editor is used which lists editors
510% by last name first.
511%
512FUNCTION {format.editors.fml}
513{ editor empty$
514    { "" }
515    { editor format.names.fml
516      editor num.names$ #1 >
517    { " (Eds.)" * }
518    { " (Ed.)" * }
519      if$
520    }
521  if$
522}
523
524%
525% Format editor names for use in labels, last names first.
526%
527FUNCTION {format.editors}
528{ editor empty$
529    { "" }
530    { editor format.names
531      editor num.names$ #1 >
532    { " (Eds.)" * }
533    { " (Ed.)" * }
534      if$
535    }
536  if$
537}
538
539FUNCTION {format.title}
540{ title empty$
541    { "" }
542    { title "t" change.case$ }
543  if$
544}
545
546% Note that the APA style requres case changes
547% in article titles. The following does not
548% change cases. If you perfer it, uncomment the
549% following and comment out the above.
550
551%FUNCTION {format.title}
552%{ title empty$
553%    { "" }
554%    { title }
555%  if$
556%}
557
558FUNCTION {n.dashify}
559{ 't :=
560  ""
561    { t empty$ not }
562    { t #1 #1 substring$ "-" =
563    { t #1 #2 substring$ "--" = not
564        { "--" *
565          t #2 global.max$ substring$ 't :=
566        }
567        {   { t #1 #1 substring$ "-" = }
568        { "-" *
569          t #2 global.max$ substring$ 't :=
570        }
571          while$
572        }
573      if$
574    }
575    { t #1 #1 substring$ *
576      t #2 global.max$ substring$ 't :=
577    }
578      if$
579    }
580  while$
581}
582
583FUNCTION {format.btitle}
584{ edition empty$
585  { title emphasize }
586  { title empty$
587    { title emphasize }
588    { volume empty$     % gnp - check for volume, then don't need period
589       { "{\em " title * "\/} (" * edition * " ed.)" * "." * }
590       { "{\em " title * "\/} (" * edition * " ed.)" * }
591      if$
592    }
593    if$
594  }
595  if$
596}
597
598FUNCTION {format.emphasize.booktitle}
599{ edition empty$
600  { booktitle emphasize }
601  { booktitle empty$
602    { booktitle emphasize }
603    { volume empty$    % gnp - extra period an error if book has a volume
604        { "{\em " booktitle * "\/} (" * edition * " ed.)" * "." *}
605        { "{\em " booktitle * "\/} (" * edition * " ed.)" * }
606      if$
607      }
608    if$
609    }
610  if$
611  }
612
613
614FUNCTION {tie.or.space.connect}
615{ duplicate$ text.length$ #3 <
616    { "~" }
617    { " " }
618  if$
619  swap$ * *
620}
621
622FUNCTION {either.or.check}
623{ empty$
624    'pop$
625    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
626  if$
627}
628
629FUNCTION {format.bvolume}
630{ volume empty$
631    { "" }
632    { "Volume" volume tie.or.space.connect % gnp - changed to mixed case
633      series empty$
634        'skip$
635        { " of " * series emphasize * }
636      if$
637      "volume and number" number either.or.check
638    }
639  if$
640}
641
642FUNCTION {format.number.series}
643{ volume empty$
644    { number empty$
645    { series field.or.null }
646    { output.state mid.sentence =
647        { "Number" } % gnp - changed to mixed case always
648        { "Number" }
649      if$
650      number tie.or.space.connect
651      series empty$
652        { "there's a number but no series in " cite$ * warning$ }
653        { " in " * series * }
654      if$
655    }
656      if$
657    }
658    { "" }
659  if$
660}
661
662INTEGERS { multiresult }
663
664FUNCTION {multi.page.check}
665{ 't :=
666  #0 'multiresult :=
667    { multiresult not
668      t empty$ not
669      and
670    }
671    { t #1 #1 substring$
672      duplicate$ "-" =
673      swap$ duplicate$ "," =
674      swap$ "+" =
675      or or
676    { #1 'multiresult := }
677    { t #2 global.max$ substring$ 't := }
678      if$
679    }
680  while$
681  multiresult
682}
683
684FUNCTION {format.pages}
685{ pages empty$
686  { "" }
687  { pages multi.page.check
688	{ "pp.\ " pages n.dashify tie.or.space.connect } % gnp - removed ()
689	{ "pp.\ " pages tie.or.space.connect }
690    if$
691  }
692  if$
693}
694
695% By Young (and Spencer)
696% GNP - fixed bugs with missing volume, number, and/or pages
697%
698% Format journal, volume, number, pages for article types.
699%
700FUNCTION {format.jour.vol}
701{ fjournal empty$
702    { journal empty$
703	{ "no journal in " cite$ * warning$
704	  "" }
705	{ journal emphasize.space }
706	if$
707    } 
708    { fjournal emphasize.space }
709    if$
710  number empty$
711    { volume empty$
712       { "no number and no volume in " cite$ * warning$
713         "" * }
714       { "~{\em " * Volume * "}" * }
715      if$
716    }
717    { volume empty$
718      {"no volume for " cite$ * warning$
719       "~(" * number * ")" * }
720      { "~" *
721        volume emphasize.space
722        "(" * number * ")" * * }
723      if$
724    }
725  if$
726  pages empty$
727    {"page numbers missing in " cite$ * warning$
728     "" * } % gnp - place a null string on the stack for output
729    { duplicate$ empty$
730      { pop$ format.pages }
731      { ", " *  pages n.dashify * } % gnp - removed pp. for articles
732      if$
733    }
734  if$
735}
736
737FUNCTION {format.chapter.pages}
738{ chapter empty$
739    'format.pages
740    { type empty$
741        { "Chapter" } % gnp - changed to mixed case
742        { type "t" change.case$ }
743      if$
744      chapter tie.or.space.connect
745      pages empty$
746        {"page numbers missing in " cite$ * warning$} % gnp - added check
747        { ", " * format.pages * }
748      if$
749    }
750  if$
751}
752
753FUNCTION {format.in.ed.booktitle}
754{ booktitle empty$
755  { "" }
756  { editor empty$
757    { "In " format.emphasize.booktitle * }
758    { "In " format.editors.fml * ", " * format.emphasize.booktitle * }
759    if$
760  }
761  if$
762}
763
764FUNCTION {format.thesis.type}
765{ type empty$
766    'skip$
767    { pop$
768      type "t" change.case$
769    }
770  if$
771}
772
773FUNCTION {format.tr.number}
774{ type empty$
775    { "Technical Report" }
776    'type
777  if$
778  number empty$
779    { "t" change.case$ }
780    { number tie.or.space.connect }
781  if$
782}
783
784FUNCTION {format.article.crossref}
785{ "See"
786  "\citeN{" * crossref * "}" *
787}
788
789FUNCTION {format.crossref.editor}
790{ editor #1 "{vv~}{ll}" format.name$
791  editor num.names$ duplicate$
792  #2 >
793    { pop$ " et~al." * }
794    { #2 <
795    'skip$
796    { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
797        { " et~al." * }
798        { " and " * editor #2 "{vv~}{ll}" format.name$ * }
799      if$
800    }
801      if$
802    }
803  if$
804}
805
806FUNCTION {format.book.crossref}
807{ volume empty$
808    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
809      "In "
810    }
811    { "Volume" volume tie.or.space.connect % gnp - changed to mixed case
812      " of " *
813    }
814  if$
815  editor empty$
816  editor field.or.null author field.or.null =
817  or
818    { key empty$
819    { series empty$
820        { "need editor, key, or series for " cite$ * " to crossref " *
821          crossref * warning$
822          "" *
823        }
824        { "{\em " * series * "\/}" * }
825      if$
826    }
827    { key * }
828      if$
829    }
830    { format.crossref.editor * }
831  if$
832  " \citeN{" * crossref * "}" *
833}
834
835FUNCTION {format.incoll.inproc.crossref}
836{ "See"
837  " \citeN{" * crossref * "}" *
838}
839
840% format.lab.names:
841%
842% determines "short" names for the abbreviated author information.
843% "Long" labels are created in calc.label, using the routine my.full.label
844% to format author and editor fields.
845%
846% There are 4 cases for labels.   (n=3 in the example)
847% a) one author             Foo
848% b) one to n               Foo, Bar and Baz
849% c) use of "and others"    Foo, Bar et al.
850% d) more than n            Foo et al.
851%
852FUNCTION {format.lab.names}
853{ 's :=
854  s num.names$ 'numnames :=
855  numnames #2 >    % change number to number of others allowed before
856		   % forcing "et al".
857    { s #1 "{vv~}{ll}" format.name$ 
858      "\protect \index {" * 
859      s #1 "{vv~}{ll}{, jj}{, f.}" format.name$ *
860      "}" *
861	"\protect\chicagoetal/" * }
862    {
863      numnames #1 - 'namesleft :=
864      #2 'nameptr :=
865      s #1 "{vv~}{ll}" format.name$
866      "\protect \index {" * 
867      s #1 "{vv~}{ll}{, jj}{, f.}" format.name$ *
868      "}" *
869	{ namesleft #0 > }
870	{ nameptr numnames =
871	    { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
872		{ "\protect\chicagoetal/" * }
873		{ "\protect\chicagoand/" * s nameptr "{vv~}{ll}" format.name$ * 
874		  "\protect \index {" * 
875		  s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ *
876		  "}" *
877                }
878	      if$
879	    }
880	    { ", " * s nameptr "{vv~}{ll}" format.name$ * }
881	  if$
882	  nameptr #1 + 'nameptr :=
883	  namesleft #1 - 'namesleft :=
884	}
885      while$
886    }
887  if$
888}
889
890FUNCTION {author.key.label}
891{ author empty$
892    { key empty$
893          { "no key, author in " cite$ * warning$
894            cite$ #1 #3 substring$ }
895         'key
896      if$
897    }
898    { author format.lab.names }
899  if$
900}
901
902FUNCTION {editor.key.label}
903{ editor empty$
904    { key empty$
905          { "no key, editor in " cite$ * warning$
906            cite$ #1 #3 substring$ }
907          'key
908        if$
909     }
910     { editor format.lab.names }
911  if$
912}
913
914FUNCTION {author.key.organization.label}
915%
916% added - gnp. Provide label formatting by organization if author is null.
917%
918{ author empty$
919    { organization empty$
920	{ key empty$
921	    { "no key, author or organization in " cite$ * warning$
922              cite$ #1 #3 substring$ }
923	    'key
924	  if$
925	}
926        { organization }
927      if$
928    }
929    { author format.lab.names }
930  if$
931}
932
933FUNCTION {editor.key.organization.label}
934%
935% added - gnp. Provide label formatting by organization if editor is null.
936%
937{ editor empty$
938    { organization empty$
939	{ key empty$
940	    { "no key, editor or organization in " cite$ * warning$
941              cite$ #1 #3 substring$ }
942	    'key
943	  if$
944	}
945        { organization }
946      if$
947    }
948    { editor format.lab.names }
949  if$
950}
951
952FUNCTION {author.editor.key.label}
953{ author empty$
954    { editor empty$
955          { key empty$
956               { "no key, author, or editor in " cite$ * warning$
957                 cite$ #1 #3 substring$ }
958             'key
959           if$
960         }
961          { editor format.lab.names }
962      if$
963    }
964    { author format.lab.names }
965  if$
966}
967
968FUNCTION {calc.label.orig}
969%
970% Changed - GNP. See also author.organization.sort, editor.organization.sort
971% Form label for BibTeX entry. The classification of which fields are used
972% for which type of entry (book, inbook, etc.) are taken from alpha.bst.
973% The change here from newapa is to also include organization as a
974% citation label if author or editor is missing.
975%
976{ type$ "book" =
977  type$ "inbook" =
978  or
979    'author.editor.key.label
980    { type$ "proceedings" =
981	'editor.key.organization.label
982	{ type$ "manual" =
983	    'author.key.organization.label
984	    'author.key.label
985	  if$
986	}
987      if$
988    }
989  if$
990
991  author empty$  % generate the full label citation information.
992    { editor empty$
993        { organization empty$
994           { "no author, editor, or organization in " cite$ * warning$
995             "??" }
996           { organization }
997           if$
998        }
999        { editor my.full.label }
1000        if$
1001    }
1002    { author.key.label }
1003  if$
1004
1005% leave label on the stack, to be popped when required.
1006
1007  "}{" * swap$ *
1008%  year field.or.null purify$ #-1 #4 substring$ *
1009%
1010% save the year for sort processing afterwards (adding a, b, c, etc.)
1011%
1012  year field.or.null purify$ #-1 #4 substring$
1013  'label.year :=
1014}
1015
1016FUNCTION {calc.label}
1017%
1018% Changed - GNP. See also author.organization.sort, editor.organization.sort
1019% Form label for BibTeX entry. The classification of which fields are used
1020% for which type of entry (book, inbook, etc.) are taken from alpha.bst.
1021% The change here from newapa is to also include organization as a
1022% citation label if author or editor is missing.
1023%
1024{ type$ "book" =
1025  type$ "inbook" =
1026  or
1027    'author.editor.key.label
1028    { type$ "proceedings" =
1029	'editor.key.organization.label
1030	{ type$ "manual" =
1031	    'author.key.organization.label
1032	    'author.key.label
1033	  if$
1034	}
1035      if$
1036    }
1037  if$
1038
1039  author empty$  % generate the full label citation information.
1040    { editor empty$
1041        { organization empty$
1042           { "no author, editor, or organization in " cite$ * warning$
1043             "??" }
1044           { organization }
1045           if$
1046        }
1047        { editor my.full.label }
1048        if$
1049    }
1050    { author my.full.label }
1051  if$
1052
1053% leave label on the stack, to be popped when required.
1054
1055  "}{" * swap$ * "}{" * title * "}{" *
1056%  year field.or.null purify$ #-1 #4 substring$ *
1057%
1058% save the year for sort processing afterwards (adding a, b, c, etc.)
1059%
1060  year field.or.null purify$ #-1 #4 substring$
1061  'label.year :=
1062}
1063
1064FUNCTION {output.bibitem}
1065{ newline$
1066
1067  "\bibitem[\protect\citeauthortitleyear{" write$
1068  calc.label write$
1069  sort.year write$
1070  "}]{" write$
1071
1072  cite$ write$
1073  "}" write$
1074  newline$
1075  ""
1076  before.all 'output.state :=
1077}
1078
1079FUNCTION {article}
1080{ output.bibitem
1081  format.authors
1082  "author" output.check
1083  author format.key output          % added
1084  output.year.check                 % added
1085  new.block
1086  format.title
1087  "title" output.check
1088  new.block
1089  crossref missing$
1090    { format.jour.vol output
1091    }
1092    { format.article.crossref output.nonnull
1093      format.pages output
1094    }
1095  if$
1096  new.block
1097  note output
1098  fin.entry
1099}
1100
1101FUNCTION {book}
1102{ output.bibitem
1103  author empty$
1104    { format.editors
1105	  "author and editor" output.check }
1106    { format.authors
1107	  output.nonnull
1108      crossref missing$
1109    	{ "author and editor" editor either.or.check }
1110    	'skip$
1111      if$
1112    }
1113  if$
1114  output.year.check       % added
1115  new.block
1116  format.btitle
1117  "title" output.check
1118  crossref missing$
1119    { format.bvolume output
1120      new.block
1121      format.number.series output
1122      new.sentence
1123      address output
1124      publisher "publisher" output.check.colon
1125    }
1126    { new.block
1127      format.book.crossref output.nonnull
1128    }
1129  if$
1130  new.block
1131  note output
1132  fin.entry
1133}
1134
1135FUNCTION {booklet}
1136{ output.bibitem
1137  format.authors output
1138  author format.key output          % added
1139  output.year.check                 % added
1140  new.block
1141  format.title
1142  "title" output.check
1143  new.block
1144  howpublished output
1145  address output
1146  new.block
1147  note output
1148  fin.entry
1149}
1150
1151FUNCTION {inbook}
1152{ output.bibitem
1153  author empty$
1154    { format.editors
1155      "author and editor" output.check
1156    }
1157    { format.authors output.nonnull
1158      crossref missing$
1159    { "author and editor" editor either.or.check }
1160    'skip$
1161      if$
1162    }
1163  if$
1164  output.year.check                 % added
1165  new.block
1166  format.btitle
1167  "title" output.check
1168  crossref missing$
1169    { format.bvolume output
1170      format.chapter.pages
1171      "chapter and pages" output.check
1172      new.block
1173      format.number.series output
1174      new.sentence
1175      address output
1176      publisher
1177      "publisher" output.check.colon
1178    }
1179    { format.chapter.pages "chapter and pages" output.check
1180      new.block
1181      format.book.crossref output.nonnull
1182    }
1183  if$
1184  new.block
1185  note output
1186  fin.entry
1187}
1188
1189FUNCTION {incollection}
1190{ output.bibitem
1191  format.authors
1192  "author" output.check
1193  author format.key output       % added
1194  output.year.check              % added
1195  new.block
1196  format.title
1197  "title" output.check
1198  new.block
1199  crossref missing$
1200  { format.in.ed.booktitle
1201    "booktitle" output.check
1202    format.bvolume output
1203    format.number.series output
1204    format.chapter.pages output % gnp - was special.output.nonnull
1205%                                 left out comma before page numbers
1206    new.sentence
1207    address output
1208    publisher "publisher" output.check.colon
1209  }
1210  { format.incoll.inproc.crossref
1211	output.nonnull
1212    format.chapter.pages output
1213  }
1214  if$
1215  new.block
1216  note output
1217  fin.entry
1218}
1219
1220FUNCTION {inproceedings}
1221{ output.bibitem
1222  format.authors
1223  "author" output.check
1224  author format.key output            % added
1225  output.year.check                   % added
1226  new.block
1227  format.title
1228  "title" output.check
1229  new.block
1230  crossref missing$
1231    { format.in.ed.booktitle
1232	  "booktitle" output.check
1233      format.bvolume output
1234      format.number.series output
1235      address output
1236      format.pages output
1237      new.sentence
1238      organization output
1239      publisher output.colon
1240      }
1241    { format.incoll.inproc.crossref output.nonnull
1242      format.pages output
1243    }
1244  if$
1245  new.block
1246  note output
1247  fin.entry
1248}
1249
1250FUNCTION {conference} { inproceedings }
1251
1252FUNCTION {manual}
1253{ output.bibitem
1254  author empty$
1255    { editor empty$
1256      { organization "organization" output.check
1257        organization format.key output }  % if all else fails, use key
1258      { format.editors "author and editor" output.check }
1259      if$
1260    }
1261    { format.authors output.nonnull }
1262    if$
1263  output.year.check                 % added
1264  new.block
1265  format.btitle
1266  "title" output.check
1267  organization address new.block.checkb
1268% Reversed the order of "address" and "organization", added the ":".
1269  address output
1270  organization "organization" output.check.colon
1271%  address output
1272%  ":" output
1273%  organization output
1274  new.block
1275  note output
1276  fin.entry
1277}
1278
1279FUNCTION {mastersthesis}
1280{ output.bibitem
1281  format.authors
1282  "author" output.check
1283  author format.key output          % added
1284  output.year.check                 % added
1285  new.block
1286  format.title
1287  "title" output.check
1288  new.block
1289  "Master's thesis" format.thesis.type output.nonnull
1290  school "school" output.check
1291  address output
1292  new.block
1293  note output
1294  fin.entry
1295}
1296
1297FUNCTION {misc}
1298{ output.bibitem
1299  format.authors output
1300  author format.key output            % added
1301  output.year.check                   % added
1302  title howpublished new.block.checkb
1303  format.title output
1304  new.block
1305  howpublished output
1306  new.block
1307  note output
1308  fin.entry
1309}
1310
1311FUNCTION {phdthesis}
1312{ output.bibitem
1313  format.authors
1314  "author" output.check
1315  author format.key output            % added
1316  output.year.check                   % added
1317  new.block
1318  format.btitle
1319  "title" output.check
1320  new.block
1321  "Ph.\ D. thesis" format.thesis.type output.nonnull
1322  school "school" output.check
1323  address output
1324  new.block
1325  note output
1326  fin.entry
1327}
1328
1329FUNCTION {proceedings}
1330{ output.bibitem
1331  editor empty$
1332    { organization output
1333      organization format.key output }  % gnp - changed from author format.key
1334    { format.editors output.nonnull }
1335  if$
1336% author format.key output             % gnp - removed (should be either
1337%                                        editor or organization
1338  output.year.check                    % added (newapa)
1339  new.block
1340  format.btitle
1341  "title" output.check
1342  format.bvolume output
1343  format.number.series output
1344  address output
1345  new.sentence
1346  organization output
1347  publisher output.colon
1348  new.block
1349  note output
1350  fin.entry
1351}
1352
1353FUNCTION {techreport}
1354{ output.bibitem
1355  format.authors
1356  "author" output.check
1357  author format.key output             % added
1358  output.year.check                    % added
1359  new.block
1360  format.title
1361  "title" output.check
1362  new.block
1363  format.tr.number output.nonnull
1364  institution
1365  "institution" output.check
1366  address output
1367  new.block
1368  note output
1369  fin.entry
1370}
1371
1372FUNCTION {unpublished}
1373{ output.bibitem
1374  format.authors
1375  "author" output.check
1376  author format.key output              % added
1377  output.year.check                      % added
1378  new.block
1379  format.title
1380  "title" output.check
1381  new.block
1382  note "note" output.check
1383  fin.entry
1384}
1385
1386FUNCTION {default.type} { misc }
1387
1388MACRO {jan} {"January"}
1389
1390MACRO {feb} {"February"}
1391
1392MACRO {mar} {"March"}
1393
1394MACRO {apr} {"April"}
1395
1396MACRO {may} {"May"}
1397
1398MACRO {jun} {"June"}
1399
1400MACRO {jul} {"July"}
1401
1402MACRO {aug} {"August"}
1403
1404MACRO {sep} {"September"}
1405
1406MACRO {oct} {"October"}
1407
1408MACRO {nov} {"November"}
1409
1410MACRO {dec} {"December"}
1411
1412MACRO {acmcs} {"ACM Computing Surveys"}
1413
1414MACRO {acta} {"Acta Informatica"}
1415
1416MACRO {ai} {"Artificial Intelligence"}
1417
1418MACRO {cacm} {"Communications of the ACM"}
1419
1420MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1421
1422MACRO {ibmsj} {"IBM Systems Journal"}
1423
1424MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1425
1426MACRO {ieeetc} {"IEEE Transactions on Computers"}
1427
1428MACRO {ieeetcad}
1429 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1430
1431MACRO {ipl} {"Information Processing Letters"}
1432
1433MACRO {jacm} {"Journal of the ACM"}
1434
1435MACRO {jcss} {"Journal of Computer and System Sciences"}
1436
1437MACRO {scp} {"Science of Computer Programming"}
1438
1439MACRO {sicomp} {"SIAM Journal on Computing"}
1440
1441MACRO {tocs} {"ACM Transactions on Computer Systems"}
1442
1443MACRO {tods} {"ACM Transactions on Database Systems"}
1444
1445MACRO {tog} {"ACM Transactions on Graphics"}
1446
1447MACRO {toms} {"ACM Transactions on Mathematical Software"}
1448
1449MACRO {toois} {"ACM Transactions on Office Information Systems"}
1450
1451MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1452
1453MACRO {tcs} {"Theoretical Computer Science"}
1454
1455READ
1456
1457FUNCTION {sortify}
1458{ purify$
1459  "l" change.case$
1460}
1461
1462INTEGERS { len }
1463
1464FUNCTION {chop.word}
1465{ 's :=
1466  'len :=
1467  s #1 len substring$ =
1468    { s len #1 + global.max$ substring$ }
1469    's
1470  if$
1471}
1472
1473
1474
1475FUNCTION {sort.format.names}
1476{ 's :=
1477  #1 'nameptr :=
1478  ""
1479  s num.names$ 'numnames :=
1480  numnames 'namesleft :=
1481    { namesleft #0 > }
1482    { nameptr #2 =
1483	{ year field.or.null purify$ #-1 #4 substring$ * }
1484	'skip$
1485      if$
1486      nameptr #1 >
1487          { "   " * }
1488         'skip$
1489      if$
1490      s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
1491      nameptr numnames = t "others" = and
1492          { " et~al" * }
1493          { t sortify * }
1494      if$
1495      nameptr #1 + 'nameptr :=
1496      namesleft #1 - 'namesleft :=
1497    }
1498  while$
1499}
1500
1501FUNCTION {sort.format.title}
1502{ 't :=
1503  "A " #2
1504    "An " #3
1505      "The " #4 t chop.word
1506    chop.word
1507  chop.word
1508  sortify
1509  #1 global.max$ substring$
1510}
1511
1512FUNCTION {author.sort}
1513{ author empty$
1514    { key empty$
1515         { "to sort, need author or key in " cite$ * warning$
1516           "" }
1517         { key sortify }
1518      if$
1519    }
1520    { author sort.format.names }
1521  if$
1522}
1523
1524FUNCTION {editor.sort}
1525{ editor empty$
1526    { key empty$
1527         { "to sort, need editor or key in " cite$ * warning$
1528           ""
1529         }
1530         { key sortify }
1531      if$
1532    }
1533    { editor sort.format.names }
1534  if$
1535}
1536
1537FUNCTION {author.editor.sort}
1538{ author empty$
1539    { "missing author in " cite$ * warning$
1540      editor empty$
1541         { key empty$
1542             { "to sort, need author, editor, or key in " cite$ * warning$
1543               ""
1544             }
1545             { key sortify }
1546           if$
1547         }
1548         { editor sort.format.names }
1549      if$
1550    }
1551    { author sort.format.names }
1552  if$
1553}
1554
1555FUNCTION {author.organization.sort}
1556%
1557% added - GNP. Stack author or organization for sorting (from alpha.bst).
1558% Unlike alpha.bst, we need entire names, not abbreviations
1559%
1560{ author empty$
1561    { organization empty$
1562	{ key empty$
1563	    { "to sort, need author, organization, or key in " cite$ * warning$
1564	      ""
1565	    }
1566	    { key sortify }
1567	  if$
1568	}
1569	{ organization sortify }
1570      if$
1571    }
1572    { author sort.format.names }
1573  if$
1574}
1575
1576FUNCTION {editor.organization.sort}
1577%
1578% added - GNP. Stack editor or organization for sorting (from alpha.bst).
1579% Unlike alpha.bst, we need entire names, not abbreviations
1580%
1581{ editor empty$
1582    { organization empty$
1583	{ key empty$
1584	    { "to sort, need editor, organization, or key in " cite$ * warning$
1585	      ""
1586	    }
1587	    { key sortify }
1588	  if$
1589	}
1590	{ organization sortify }
1591      if$
1592    }
1593    { editor sort.format.names }
1594  if$
1595}
1596
1597FUNCTION {presort}
1598%
1599% Presort creates the bibentry's label via a call to calc.label, and then
1600% sorts the entries based on entry type. Chicago.bst adds support for
1601% including organizations as the sort key; the following is stolen from
1602% alpha.bst.
1603%
1604{ %calc.label sortify % recalculate bibitem label
1605  %year field.or.null purify$ #-1 #4 substring$ * % add year
1606  %duplicate$ warning$
1607  %"    "
1608  %*
1609  type$ "book" =
1610  type$ "inbook" =
1611  or
1612    'author.editor.sort
1613    { type$ "proceedings" =
1614	'editor.organization.sort
1615	{ type$ "manual" =
1616	    'author.organization.sort
1617	    'author.sort
1618	  if$
1619	}
1620      if$
1621    }
1622  if$
1623  #1 entry.max$ substring$        % added for newapa
1624  'sort.label :=                  % added for newapa
1625  sort.label                      % added for newapa
1626  %*
1627  "    "
1628  *
1629  title field.or.null
1630  sort.format.title
1631  *
1632  #1 entry.max$ substring$
1633  'sort.key$ :=
1634}
1635
1636ITERATE {presort}
1637
1638SORT             % by label, year, author/editor, title
1639
1640STRINGS { last.label next.extra }
1641
1642INTEGERS { last.extra.num }
1643
1644FUNCTION {initialize.extra.label.stuff}
1645{ #0 int.to.chr$ 'last.label :=
1646  "" 'next.extra :=
1647  #0 'last.extra.num :=
1648}
1649
1650FUNCTION {forward.pass}
1651%
1652% Pass through all entries, comparing current entry to last one.
1653% Need to concatenate year to the stack (done by calc.label) to determine
1654% if two entries are the same (see presort)
1655%
1656{ last.label
1657  calc.label.orig year field.or.null purify$ #-1 #4 substring$ * % add year
1658  #1 entry.max$ substring$ =     % are they equal?
1659     { last.extra.num #1 + 'last.extra.num :=
1660       last.extra.num int.to.chr$ 'extra.label :=
1661     }
1662     { "a" chr.to.int$ 'last.extra.num :=
1663       "" 'extra.label :=
1664       calc.label.orig year field.or.null purify$ #-1 #4 substring$ * % add year
1665       #1 entry.max$ substring$ 'last.label := % assign to last.label
1666     }
1667  if$
1668}
1669
1670FUNCTION {reverse.pass}
1671{ next.extra "b" =
1672    { "a" 'extra.label := }
1673     'skip$
1674  if$
1675  label.year extra.label * 'sort.year :=
1676  extra.label 'next.extra :=
1677}
1678
1679EXECUTE {initialize.extra.label.stuff}
1680
1681ITERATE {forward.pass}
1682
1683REVERSE {reverse.pass}
1684
1685FUNCTION {bib.sort.order}
1686{ sort.label
1687  "    "
1688  *
1689  year field.or.null sortify
1690  *
1691  "    "
1692  *
1693  title field.or.null
1694  sort.format.title
1695  *
1696  #1 entry.max$ substring$
1697  'sort.key$ :=
1698}
1699
1700ITERATE {bib.sort.order}
1701
1702SORT             % by sort.label, year, title --- giving final bib. order.
1703
1704FUNCTION {begin.bib}
1705
1706{ preamble$ empty$
1707    'skip$
1708    { preamble$ write$ newline$ }
1709  if$
1710  "\begin{thebibliography}{}" write$ newline$
1711}
1712
1713
1714EXECUTE {begin.bib}
1715
1716EXECUTE {init.state.consts}
1717
1718ITERATE {call.type$}
1719
1720FUNCTION {end.bib}
1721{ newline$
1722  "\end{thebibliography}" write$ newline$
1723}
1724
1725EXECUTE {end.bib}
1726
1727