Debian Codegraph @

texmf-dist/doc/latex/mnras/LEGACY/mn2e.bst

raw
1 %%%%% MN.BST version 1.1b, 19/07/95
2 %%%%% John Sleath and Tim Jenness, MRAO, Cambridge
3 %%
4 %% Bibliography style file for MNRAS.
5 %%
6 %% Gives correct style for all entries (as far as known!). However,
7 %% the sorting of two- and three- author papers, with the same first
8 %% author does not (quite) conform to the correct style.
9 %%
10 %% Use \cite to give (Smith \& Jones 1995) or \shortcite to give the year
11 %% (in brackets) only. This file should be used in conjunction with
12 %% mn.sty (Blackwell Scientific).
13 %%
14 %% Extensively modified from astron.bst and apalike.bst
15
16
17
18 ENTRY
19 { address
20 author
21 booktitle
22 chapter
23 edition
24 editor
25 howpublished
26 institution
27 journal
28 key
29 % month not used in apalike
30 note
31 number
32 organization
33 pages
34 publisher
35 school
36 series
37 title
38 type
39 volume
40 year
41 url
42 }
43 {}
44 { label extra.label sort.label }
45
46 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
47
48 FUNCTION {init.state.consts}
49 { #0 'before.all :=
50 #1 'mid.sentence :=
51 #2 'after.sentence :=
52 #3 'after.block :=
53 }
54
55 STRINGS { s t }
56
57 FUNCTION {output.nonnull}
58 { 's :=
59 output.state mid.sentence =
60 { ", " * write$ }
61 { output.state after.block =
62 { ". " * write$
63 newline$
64 % "\newblock " write$
65 }
66 { output.state before.all =
67 'write$
68 { ", " * write$ }
69 if$
70 }
71 if$
72 mid.sentence 'output.state :=
73 }
74 if$
75 s
76 }
77
78 FUNCTION {output.nonnull.extra}
79 { 's :=
80 output.state mid.sentence =
81 { ", " * write$ }
82 { output.state after.block =
83 { ", " * write$
84 newline$
85 "\newblock " write$
86 }
87 { output.state before.all =
88 'write$
89 { ", " * write$ }
90 if$
91 }
92 if$
93 mid.sentence 'output.state :=
94 }
95 if$
96 s
97 }
98
99 FUNCTION {output}
100 { duplicate$ empty$
101 'pop$
102 'output.nonnull
103 if$
104 }
105
106 FUNCTION {output.extra}
107 { duplicate$ empty$
108 'pop$
109 'output.nonnull.extra
110 if$
111 }
112
113 FUNCTION {output.check}
114 { 't :=
115 duplicate$ empty$
116 { pop$ "empty " t * " in " * cite$ * warning$ }
117 'output.nonnull
118 if$
119 }
120
121 FUNCTION {output.check.extra}
122 { 't :=
123 duplicate$ empty$
124 { pop$ "empty " t * " in " * cite$ * warning$ }
125 'output.nonnull.extra
126 if$
127 }
128
129 FUNCTION {output.year.check}
130 { year empty$
131 { "empty year in " cite$ * warning$ }
132 { write$
133 " " year * extra.label *
134 mid.sentence 'output.state :=
135 }
136 if$
137 }
138
139 FUNCTION {output.year.misc.check}
140 { year empty$
141 { "empty year in " cite$ * warning$ }
142 { write$
143 output.state mid.sentence =
144 { "," write$ } {} if$
145 " " year * extra.label *
146 mid.sentence 'output.state :=
147 }
148 if$
149 }
150
151 FUNCTION {output.bibitem}
152 { newline$
153 "\bibitem[" write$
154 label write$
155 "]{" write$
156 cite$ write$
157 "}" write$
158 newline$
159 ""
160 before.all 'output.state :=
161 }
162
163 FUNCTION {fin.entry}
164 { write$
165 newline$
166 }
167
168 FUNCTION {new.block}
169 { output.state before.all =
170 'skip$
171 { after.block 'output.state := }
172 if$
173 }
174
175 FUNCTION {new.sentence}
176 { output.state after.block =
177 'skip$
178 { output.state before.all =
179 'skip$
180 { after.sentence 'output.state := }
181 if$
182 }
183 if$
184 }
185
186 FUNCTION {not}
187 { { #0 }
188 { #1 }
189 if$
190 }
191
192 FUNCTION {and}
193 { 'skip$
194 { pop$ #0 }
195 if$
196 }
197
198 FUNCTION {or}
199 { { pop$ #1 }
200 'skip$
201 if$
202 }
203
204 FUNCTION {new.block.checkb}
205 { empty$
206 swap$ empty$
207 and
208 'skip$
209 'new.block
210 if$
211 }
212
213 FUNCTION {field.or.null}
214 { duplicate$ empty$
215 { pop$ "" }
216 'skip$
217 if$
218 }
219
220 FUNCTION {boldface}
221 { duplicate$ empty$
222 { pop$ "" }
223 { "{ " swap$ * "}" * }
224 if$
225 }
226
227 FUNCTION {emphasize}
228 { duplicate$ empty$
229 { pop$ "" }
230 { "{ " swap$ * "}" * }
231 if$
232 }
233
234 INTEGERS { nameptr namesleft numnames }
235
236 FUNCTION {format.names}
237 { 's :=
238 #1 'nameptr :=
239 s num.names$ 'numnames :=
240 numnames 'namesleft :=
241 { namesleft #0 > }
242 { s nameptr "{vv }{ll}{ jj}{ f., }" format.name$ 't := % last name first
243 nameptr #1 >
244 { namesleft #1 >
245 { " " * t * }
246 { numnames #2 >
247 { " " * }
248 'skip$
249 if$
250 t "others" =
251 { " et~al.," * }
252 { " " * t * }
253 if$
254 }
255 if$
256 }
257 't
258 if$
259 nameptr #1 + 'nameptr :=
260 namesleft #1 - 'namesleft :=
261 }
262 while$
263 }
264
265 FUNCTION {format.names.full}
266 { 's :=
267 #1 'nameptr :=
268 s num.names$ 'numnames :=
269 numnames 'namesleft :=
270 { namesleft #0 > }
271 { s nameptr "{vv }{ll}{ jj}" format.name$ 't := % last name first
272 nameptr #1 >
273 {
274 namesleft #1 >
275 { ", " * t * }
276 {
277 t "others" =
278 { " et~al.," * }
279 { " \& " * t * }
280 if$
281 }
282 if$
283 }
284 't
285 if$
286 nameptr #1 + 'nameptr :=
287 namesleft #1 - 'namesleft :=
288 }
289 while$
290 }
291
292 FUNCTION {format.ed.names}
293 { 's :=
294 #1 'nameptr :=
295 s num.names$ 'numnames :=
296 numnames 'namesleft :=
297 { namesleft #0 > }
298 { s nameptr "{vv }{ll}{ jj}{ f., }" format.name$ 't :=
299 nameptr #1 >
300 { namesleft #1 >
301 { " " * t * }
302 { numnames #2 >
303 { " " * }
304 'skip$
305 if$
306 t "others" =
307 { " et~al." * }
308 { " " * t * }
309 if$
310 }
311 if$
312 }
313 't
314 if$
315 nameptr #1 + 'nameptr :=
316 namesleft #1 - 'namesleft :=
317 }
318 while$
319 }
320
321 FUNCTION {format.authors}
322 { author empty$
323 { "" }
324 { author format.names }
325 if$
326 }
327
328 FUNCTION {format.key} % this function is just for apalike
329 { empty$
330 { key field.or.null }
331 { "" }
332 if$
333 }
334
335 FUNCTION {format.editors}
336 { editor empty$
337 { "" }
338 { editor format.names
339 editor num.names$ #1 >
340 { " eds," * }
341 { " ed." * }
342 if$
343 }
344 if$
345 }
346
347 FUNCTION {format.editors.extra}
348 { editor empty$
349 { "" }
350 { editor format.ed.names
351 editor num.names$ #1 >
352 { " eds" * }
353 { " ed." * }
354 if$
355 }
356 if$
357 }
358
359 FUNCTION {format.title}
360 { title empty$
361 { "" }
362 { title "t" change.case$ }
363 if$
364 }
365
366 FUNCTION {n.dashify}
367 { 't :=
368 ""
369 { t empty$ not }
370 { t #1 #1 substring$ "-" =
371 { t #1 #2 substring$ "--" = not
372 { "--" *
373 t #2 global.max$ substring$ 't :=
374 }
375 { { t #1 #1 substring$ "-" = }
376 { "-" *
377 t #2 global.max$ substring$ 't :=
378 }
379 while$
380 }
381 if$
382 }
383 { t #1 #1 substring$ *
384 t #2 global.max$ substring$ 't :=
385 }
386 if$
387 }
388 while$
389 }
390
391 FUNCTION {first.page.number}
392 { 't :=
393 ""
394 { t "" =
395 { #0 }
396 { t #1 #1 substring$ "-" = not }
397 if$
398 }
399 { t #1 #1 substring$ *
400 t #2 global.max$ substring$ 't :=
401 }
402 while$
403 }
404
405 FUNCTION {format.btitle}
406 { title
407 }
408
409 FUNCTION {tie.or.space.connect}
410 { duplicate$ text.length$ #5 <
411 { "~" }
412 { " " }
413 if$
414 swap$ * *
415 }
416
417 FUNCTION {either.or.check}
418 { empty$
419 'pop$
420 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
421 if$
422 }
423
424 FUNCTION {format.bvolume}
425 { volume empty$
426 { "" }
427 { "Vol." volume tie.or.space.connect
428 series empty$
429 'skip$
430 { " of " * series * }
431 if$
432 "volume and number" number either.or.check
433 }
434 if$
435 }
436
437 FUNCTION {format.number.series}
438 { volume empty$
439 { number empty$
440 { series field.or.null }
441 { output.state mid.sentence =
442 { "No." }
443 { "No." }
444 if$
445 number tie.or.space.connect
446 series empty$
447 { "there's a number but no series in " cite$ * warning$ }
448 { " in " * series * }
449 if$
450 }
451 if$
452 }
453 { "" }
454 if$
455 }
456
457 FUNCTION {format.edition}
458 { edition empty$
459 { "" }
460 { output.state mid.sentence =
461 { edition "l" change.case$ " edn" * }
462 { edition "t" change.case$ " edn" * }
463 if$
464 }
465 if$
466 }
467
468 INTEGERS { multiresult }
469
470 FUNCTION {multi.page.check}
471 { 't :=
472 #0 'multiresult :=
473 { multiresult not
474 t empty$ not
475 and
476 }
477 { t #1 #1 substring$
478 duplicate$ "-" =
479 swap$ duplicate$ "," =
480 swap$ "+" =
481 or or
482 { #1 'multiresult := }
483 { t #2 global.max$ substring$ 't := }
484 if$
485 }
486 while$
487 multiresult
488 }
489
490 FUNCTION {format.pages}
491 { pages empty$
492 { "" }
493 { pages multi.page.check
494 { "pp" pages n.dashify tie.or.space.connect }
495 { "p." pages tie.or.space.connect }
496 if$
497 }
498 if$
499 }
500
501 FUNCTION {format.page}
502 { pages empty$
503 { "" }
504 { "p.~" pages first.page.number * }
505 if$
506 }
507
508 FUNCTION {format.vol.num.pages}
509 { volume field.or.null
510 number empty$
511 'skip$
512 { "(" number * ")" * *
513 volume empty$
514 { "there's a number but no volume in " cite$ * warning$ }
515 'skip$
516 if$
517 }
518 if$
519 pages empty$
520 'skip$
521 { duplicate$ empty$
522 { pop$ format.pages }
523 { ", " * pages n.dashify * }
524 if$
525 }
526 if$
527 }
528
529 FUNCTION {format.vol.page}
530 { volume field.or.null
531 pages empty$
532 'skip$
533 { duplicate$ empty$
534 { pop$ format.pages }
535 { ", " * pages first.page.number * }
536 if$
537 }
538 if$
539 }
540
541 FUNCTION {format.vol.num.page}
542 { volume field.or.null
543 number empty$
544 'skip$
545 { "(" number * ")" * *
546 volume empty$
547 { "there's a number but no volume in " cite$ * warning$ }
548 'skip$
549 if$
550 }
551 if$
552 pages empty$
553 'skip$
554 { duplicate$ empty$
555 { pop$ format.pages }
556 { ", " * pages first.page.number * }
557 if$
558 }
559 if$
560 }
561 FUNCTION {format.chapter.pages}
562 { chapter empty$
563 'format.pages
564 { type empty$
565 { "Chapt." }
566 { type "l" change.case$ }
567 if$
568 chapter tie.or.space.connect
569 pages empty$
570 'skip$
571 { ", " * format.pages * }
572 if$
573 }
574 if$
575 }
576
577 FUNCTION {format.in.ed.booktitle}
578 { booktitle empty$
579 { "" }
580 { editor empty$
581 { "in " booktitle * }
582 { "in " format.editors.extra * ", " * booktitle * }
583 if$
584 }
585 if$
586 }
587
588 FUNCTION {format.in.ed.collect}
589 { booktitle empty$
590 { "" }
591 { editor empty$
592 { "in " }
593 { "in " format.editors.extra * ", " * }
594 if$
595 series empty$
596 { skip$ }
597 { series * }
598 if$
599 volume empty$
600 { number empty$
601 { }
602 { output.state mid.sentence =
603 { "No." }
604 { "No." }
605 if$
606 number tie.or.space.connect *
607 }
608 if$
609 }
610 {
611 output.state mid.sentence =
612 { ", " * }
613 { skip$ }
614 if$
615 "Vol." volume tie.or.space.connect *
616 }
617 if$
618 output.state mid.sentence =
619 { ", " * }
620 { skip$ }
621 if$
622 booktitle *
623 }
624 if$
625 }
626
627 FUNCTION {format.thesis.type}
628 { type empty$
629 'skip$
630 { pop$
631 type "t" change.case$
632 }
633 if$
634 }
635
636 FUNCTION {format.url}
637 {
638 url empty$
639 { skip$ }
640 { "\verb+" url * "+" * output.nonnull }
641 if$
642 }
643
644 FUNCTION {format.tr.number}
645 {
646 type empty$
647 { "Technical Report" }
648 { type }
649 if$
650 number empty$
651 { "t" change.case$ }
652 { number tie.or.space.connect }
653 if$
654 }
655
656 FUNCTION {format.article.crossref}
657 { "in" % this is for apalike
658 " \cite{" * crossref * "}" *
659 }
660
661 FUNCTION {format.book.crossref}
662 { volume empty$
663 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
664 "in "
665 }
666 { "Vol.\" volume tie.or.space.connect
667 " of " *
668 }
669 if$
670 "\cite{" * crossref * "}" * % this is for apalike
671 }
672
673 FUNCTION {format.incoll.inproc.crossref}
674 { "in" % this is for apalike
675 " \cite{" * crossref * "}" *
676 }
677
678 FUNCTION {article}
679 { output.bibitem
680 format.authors "author" output.check
681 author format.key output % special for
682 output.year.check % apalike
683 crossref missing$
684 { journal "journal" output.check.extra
685 format.vol.page output.extra
686 }
687 { format.article.crossref output.nonnull
688 format.page output
689 }
690 if$
691 fin.entry
692 }
693
694 FUNCTION {book}
695 { output.bibitem
696 author empty$
697 { format.editors "author and editor" output.check
698 editor format.key output
699 }
700 { format.authors output.nonnull
701 crossref missing$
702 { "author and editor" editor either.or.check }
703 'skip$
704 if$
705 }
706 if$
707 output.year.check % special for apalike
708 format.btitle "title" output.check
709 format.edition output
710 new.block
711 crossref missing$
712 { format.bvolume output
713 format.number.series output
714 new.sentence
715 publisher "publisher" output.check
716 address output
717 }
718 {format.book.crossref output.nonnull}
719 if$
720 fin.entry
721 }
722
723 FUNCTION {booklet}
724 { output.bibitem
725 format.authors output
726 author format.key output % special for
727 output.year.check % apalike
728 format.btitle "title" output.check
729 howpublished output
730 address output
731 fin.entry
732 }
733
734 FUNCTION {inbook}
735 { output.bibitem
736 author empty$
737 { format.editors "author and editor" output.check
738 editor format.key output
739 }
740 { format.authors output.nonnull
741 crossref missing$
742 { "author and editor" editor either.or.check }
743 'skip$
744 if$
745 }
746 if$
747 output.year.check % special for apalike
748 format.btitle "title" output.check
749 format.edition output
750 new.block
751 crossref missing$
752 {
753 % format.number.series output
754 new.sentence
755 publisher "publisher" output.check
756 address output
757 format.pages output
758 }
759 { format.chapter.pages "chapter and pages" output.check
760 format.book.crossref output.nonnull
761 }
762 if$
763 fin.entry
764 }
765
766 FUNCTION {incollection}
767 { output.bibitem
768 format.authors "author" output.check
769 author format.key output % special for
770 output.year.check % apalike
771 crossref missing$
772 {
773 format.in.ed.collect "booktitle" output.check
774 format.edition output
775 booktitle empty$ edition empty$ =
776 { } { new.block } if$
777 new.sentence
778 publisher "publisher" output.check
779 address output
780 }
781 { format.incoll.inproc.crossref output.nonnull
782 format.chapter.pages output
783 }
784 if$
785 format.chapter.pages output
786 fin.entry
787 }
788
789 FUNCTION {inproceedings}
790 { output.bibitem
791 format.authors "author" output.check
792 author format.key output % special for
793 output.year.check % apalike
794 crossref missing$
795 { format.in.ed.booktitle "booktitle" output.check
796 " " *
797 before.all 'output.state :=
798 % new.block
799 format.bvolume output
800 format.number.series output
801 format.title "title" output.check
802 new.block
803 % organization output
804 publisher output
805 address output
806 format.pages output
807 }
808 { format.incoll.inproc.crossref output.nonnull
809 format.pages output
810 }
811 if$
812 fin.entry
813 }
814
815 FUNCTION {conference} { inproceedings }
816
817 FUNCTION {manual}
818 { output.bibitem
819 format.authors output
820 author format.key output % special for
821 output.year.check % apalike
822 format.btitle "title" output.check
823 new.block
824 organization address new.block.checkb
825 organization output
826 address output
827 format.edition output
828 fin.entry
829 }
830
831 FUNCTION {mastersthesis}
832 { output.bibitem
833 format.authors "author" output.check
834 author format.key output % special for
835 output.year.check % apalike
836 "Master's thesis" format.thesis.type output.nonnull
837 school "school" output.check
838 address output
839 fin.entry
840 }
841
842 FUNCTION {misc}
843 { output.bibitem
844 format.authors output
845 author format.key output % special for
846 output.year.misc.check % apalike
847 format.btitle output
848 howpublished output
849 fin.entry
850 }
851
852 FUNCTION {phdthesis}
853 { output.bibitem
854 format.authors "author" output.check
855 author format.key output % special for
856 output.year.check % apalike
857 "PhD thesis" format.thesis.type output.nonnull
858 school "school" output.check
859 address output
860 fin.entry
861 }
862
863 FUNCTION {proceedings}
864 { output.bibitem
865 format.editors output
866 editor format.key output % special for
867 mid.sentence 'output.state :=
868 output.year.check % apalike
869 format.btitle "title" output.check
870 " " *
871 before.all 'output.state :=
872 % new.block
873 format.bvolume output
874 format.number.series output
875 new.block
876 % organization output % a nonempty organization
877 publisher output
878 address output
879 fin.entry
880 }
881
882 FUNCTION {techreport}
883 { output.bibitem
884 format.authors "author" output.check
885 author format.key output % special for
886 output.year.check % apalike
887 format.tr.number output.nonnull
888 format.btitle "title" output.check
889 format.url
890 new.block
891 institution "institution" output.check
892 address output
893 fin.entry
894 }
895
896 FUNCTION {unpublished}
897 { output.bibitem
898 format.authors "author" output.check
899 author format.key output % special for
900 output.year.check % apalike
901 format.btitle "title" output.check
902 note "note" output.check
903 fin.entry
904 }
905
906 FUNCTION {default.type} { misc }
907
908 MACRO {jan} {"Jan."}
909
910 MACRO {feb} {"Feb."}
911
912 MACRO {mar} {"Mar."}
913
914 MACRO {apr} {"Apr,"}
915
916 MACRO {may} {"May"}
917
918 MACRO {jun} {"June"}
919
920 MACRO {jul} {"July"}
921
922 MACRO {aug} {"Aug."}
923
924 MACRO {sep} {"Sept."}
925
926 MACRO {oct} {"Oct."}
927
928 MACRO {nov} {"Nov."}
929
930 MACRO {dec} {"Dec."}
931
932 READ
933
934 FUNCTION {sortify}
935 { purify$
936 "l" change.case$
937 }
938
939 INTEGERS { len }
940
941 FUNCTION {chop.word}
942 { 's :=
943 'len :=
944 s #1 len substring$ =
945 { s len #1 + global.max$ substring$ }
946 's
947 if$
948 }
949
950 % There are three apalike cases: one person (Jones),
951 % two (Jones and de~Bruijn), and more (Jones et~al.).
952 % This function is much like format.crossref.editors.
953 %
954 FUNCTION {format.lab.names}
955 { 's :=
956 s #1 "{vv~}{ll}" format.name$
957 s num.names$ duplicate$
958 #2 >
959 { pop$ " et~al." * }
960 { #2 <
961 'skip$
962 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
963 { " et~al." * }
964 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
965 if$
966 }
967 if$
968 }
969 if$
970 }
971
972 % Format names in full
973 %
974 FUNCTION {format.lab.names.full}
975 { 's :=
976 s #1 "{vv~}{ll}" format.name$
977 s num.names$ duplicate$
978 #2 <
979 'skip$
980 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
981 'skip$
982 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
983 if$
984 }
985 if$
986 }
987
988 FUNCTION {author.key.label}
989 { author empty$
990 { key empty$
991 { cite$ #1 #3 substring$ }
992 'key % apalike uses the whole key
993 if$
994 }
995 { author format.lab.names }
996 if$
997 }
998
999
1000 FUNCTION {author.editor.key.label}
1001 { author empty$
1002 { editor empty$
1003 { key empty$
1004 { cite$ #1 #3 substring$ }
1005 'key % apalike uses the whole key
1006 if$
1007 }
1008 { editor format.lab.names }
1009 if$
1010 }
1011 { author format.lab.names }
1012 if$
1013 }
1014
1015 FUNCTION {author.editor.key.label.full}
1016 { author empty$
1017 { editor empty$
1018 { key empty$
1019 { cite$ #1 #3 substring$ }
1020 'key
1021 if$
1022 }
1023 { editor format.names.full }
1024 if$
1025 }
1026 { author format.names.full }
1027 if$
1028 }
1029
1030 FUNCTION {editor.key.label}
1031 { editor empty$
1032 { key empty$
1033 { cite$ #1 #3 substring$ }
1034 'key % apalike uses the whole key, no organization
1035 if$
1036 }
1037 { editor format.lab.names }
1038 if$
1039 }
1040
1041 FUNCTION {calc.label}
1042 {
1043 type$ "book" =
1044 type$ "inbook" =
1045 or
1046 'author.editor.key.label.full
1047 { type$ "proceedings" =
1048 { editor format.names.full }
1049 { author format.names.full }
1050 if$
1051 }
1052 if$
1053 "\protect\citeauthoryear{" swap$ * "}{" % these three lines are
1054 * % for apalike, which
1055 type$ "book" =
1056 type$ "inbook" =
1057 or
1058 'author.editor.key.label
1059 { type$ "proceedings" =
1060 'editor.key.label % apalike ignores organization
1061 'author.key.label % for labeling and sorting
1062 if$
1063 }
1064 if$
1065 * "}{" *
1066 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
1067 * % the matching closing "}" comes in at the reverse.pass
1068 'label :=
1069 }
1070
1071 FUNCTION {sort.format.names}
1072 { 's :=
1073 #1 'nameptr :=
1074 ""
1075 s num.names$ 'numnames :=
1076 numnames 'namesleft :=
1077 { namesleft #0 > }
1078 { nameptr #1 >
1079 { " " * }
1080 'skip$
1081 if$ % apalike uses initials
1082 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
1083 "Mc" t #2 text.prefix$ =
1084 { "mac" t #3 t text.length$ substring$ * 't := }
1085 'skip$
1086 if$
1087 nameptr numnames = t "others" = and
1088 { "et al." * }
1089 { t sortify * }
1090 if$
1091 nameptr #1 + 'nameptr :=
1092 namesleft #1 - 'namesleft :=
1093 }
1094 while$
1095 }
1096
1097 FUNCTION {sort.format.title}
1098 { 't :=
1099 "A " #2
1100 "An " #3
1101 "The " #4 t chop.word
1102 chop.word
1103 chop.word
1104 sortify
1105 #1 global.max$ substring$
1106 }
1107
1108 FUNCTION {author.sort}
1109 { author empty$
1110 { key empty$
1111 { "to sort, need author or key in " cite$ * warning$
1112 ""
1113 }
1114 { key sortify }
1115 if$
1116 }
1117 { author sort.format.names }
1118 if$
1119 }
1120
1121 FUNCTION {author.editor.sort}
1122 { author empty$
1123 { editor empty$
1124 { key empty$
1125 { "to sort, need author, editor, or key in " cite$ * warning$
1126 ""
1127 }
1128 { key sortify }
1129 if$
1130 }
1131 { editor sort.format.names }
1132 if$
1133 }
1134 { author sort.format.names }
1135 if$
1136 }
1137
1138 FUNCTION {editor.sort}
1139 { editor empty$
1140 { key empty$
1141 { "to sort, need editor or key in " cite$ * warning$
1142 ""
1143 }
1144 { key sortify }
1145 if$
1146 }
1147 { editor sort.format.names }
1148 if$
1149 }
1150
1151 % apalike uses two sorting passes; the first one sets the
1152 % labels so that the `a's, `b's, etc. can be computed;
1153 % the second pass puts the references in "correct" order.
1154 % The presort function is for the first pass. It computes
1155 % label, sort.label, and title, and then concatenates.
1156 FUNCTION {presort}
1157 { calc.label
1158 label sortify
1159 " "
1160 *
1161 type$ "book" =
1162 type$ "inbook" =
1163 or
1164 'author.editor.sort
1165 { type$ "proceedings" =
1166 'editor.sort
1167 'author.sort
1168 if$
1169 }
1170 if$
1171 #1 entry.max$ substring$ % for
1172 'sort.label := % apalike
1173 sort.label % style
1174 *
1175 " "
1176 *
1177 title field.or.null
1178 sort.format.title
1179 *
1180 #1 entry.max$ substring$
1181 'sort.key$ :=
1182 }
1183
1184 ITERATE {presort}
1185
1186 SORT % by label, sort.label, title---for final label calculation
1187
1188 STRINGS { last.label next.extra } % apalike labels are only for the text;
1189
1190 INTEGERS { last.extra.num } % there are none in the bibliography
1191
1192 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1193 { #0 int.to.chr$ 'last.label :=
1194 "" 'next.extra :=
1195 #0 'last.extra.num :=
1196 }
1197
1198 FUNCTION {forward.pass}
1199 { last.label label =
1200 { last.extra.num #1 + 'last.extra.num :=
1201 last.extra.num int.to.chr$ 'extra.label :=
1202 }
1203 { "a" chr.to.int$ 'last.extra.num :=
1204 "" 'extra.label :=
1205 label 'last.label :=
1206 }
1207 if$
1208 }
1209
1210 FUNCTION {reverse.pass}
1211 { next.extra "b" =
1212 { "a" 'extra.label := }
1213 'skip$
1214 if$
1215 label extra.label * "}" * 'label :=
1216 extra.label 'next.extra :=
1217 }
1218
1219 EXECUTE {initialize.extra.label.stuff}
1220
1221 ITERATE {forward.pass}
1222
1223 REVERSE {reverse.pass}
1224
1225 % Now that the label is right we sort for real,
1226 % on sort.label then year then title. This is
1227 % for the second sorting pass.
1228 FUNCTION {bib.sort.order}
1229 { sort.label
1230 " "
1231 *
1232 year field.or.null sortify
1233 *
1234 " "
1235 *
1236 title field.or.null
1237 sort.format.title
1238 *
1239 #1 entry.max$ substring$
1240 'sort.key$ :=
1241 }
1242
1243 ITERATE {bib.sort.order}
1244
1245 SORT % by sort.label, year, title---giving final bibliography order
1246
1247 FUNCTION {begin.bib}
1248 {
1249 preamble$ empty$ % no \etalchar in apalike
1250 'skip$
1251 { preamble$ write$ newline$ }
1252 if$
1253 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1254 }
1255
1256 EXECUTE {begin.bib}
1257
1258 EXECUTE {init.state.consts}
1259
1260 ITERATE {call.type$}
1261
1262 FUNCTION {end.bib}
1263 { newline$
1264 "\end{thebibliography}" write$ newline$
1265 }
1266
1267 EXECUTE {end.bib}