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