Debian Codegraph @

texmf-dist/bibtex/bst/ascelike/ascelike.bst

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