Debian Codegraph @

texmf-dist/bibtex/bst/chicagolinks/chicagolinks.bst

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