Debian Codegraph @

texmf-dist/bibtex/bst/ciad-beamertheme/ciad.bst

raw
1 % Copyright (c) 2013-25 Stephane GALLAND <[email protected]>
2 %
3 % UTBM logo and name are registered and owned by the
4 % "Universite de Technologie de Belfort-Montbeliard".
5 %
6 % UBE logo and name are registered and owned by the
7 % "Universite Bourgogne Europe".
8 %
9 % CIAD logo and name are registered and owned by the
10 % "Laboratoire Connaissance et Intelligence Artificielle Distribuées".
11 %
12 % This program is free library; you can redistribute it and/or modify
13 % it under the terms of the GNU Lesser General Public License as
14 % published by the Free Software Foundation; either version 3 of the
15 % License, or any later version.
16 %
17 % This library is distributed in the hope that it will be useful, but
18 % WITHOUT ANY WARRANTY; without even the implied warranty of
19 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 % Lesser General Public License for more details.
21 %
22 % You should have received a copy of the GNU Lesser General Public
23 % License along with this library; see the file COPYING. If not,
24 % write to the Free Software Foundation, Inc., 59 Temple Place - Suite
25 % 330, Boston, MA 02111-1307, USA.
26 %
27
28 %NAME: apalike.bst
29 % BibTeX `apalike' bibliography style (24-Jan-88 version)
30 % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
31 % Copyright (C) 1988, all rights reserved.
32 % Copying of this file is allowed, provided that if you make any changes at all
33 % you name it something other than `apalike.bst'.
34 % This restriction helps ensure that all copies are identical.
35 % Differences between this style and `alpha' are generally heralded by a `%'.
36 % The file btxbst.doc has the documentation for alpha.bst.
37 %
38 % This style should be used with the `apalike' LaTeX style (apalike.sty).
39 % \cite's come out like "(Jones, 1986)" in the text but there are no labels
40 % in the bibliography, and something like "(1986)" comes out immediately
41 % after the author. Author (and editor) names appear as last name, comma,
42 % initials. A `year' field is required for every entry, and so is either
43 % an author (or in some cases, an editor) field or a key field.
44 %
45 % Editorial note:
46 % Many journals require a style like `apalike', but I strongly, strongly,
47 % strongly recommend that you not use it if you have a choice---use something
48 % like `plain' instead. Mary-Claire van Leunen (A Handbook for Scholars,
49 % Knopf, 1979) argues convincingly that a style like `plain' encourages better
50 % writing than one like `apalike'. Furthermore the strongest arguments for
51 % using an author-date style like `apalike'---that it's "the most practical"
52 % (The Chicago Manual of Style, University of Chicago Press, thirteenth
53 % edition, 1982, pages 400--401)---fall flat on their face with the new
54 % computer-typesetting technology. For instance page 401 anachronistically
55 % states "The chief disadvantage of [a style like `plain'] is that additions
56 % or deletions cannot be made after the manuscript is typed without changing
57 % numbers in both text references and list." LaTeX sidesteps the disadvantage.
58 %
59 % History:
60 % 15-sep-86 (SK,OP) Original version, by Susan King and Oren Patashnik.
61 % 10-nov-86 (OP) Truncated the sort.key$ string to the correct length
62 % in bib.sort.order to eliminate error message.
63 % 24-jan-88 (OP) Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
64 % apalike now sorts by author, then year, then title;
65 % THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
66
67 ENTRY
68 { address
69 author
70 booktitle
71 chapter
72 edition
73 editor
74 howpublished
75 institution
76 journal
77 key
78 % month not used in apalike
79 note
80 number
81 organization
82 pages
83 publisher
84 school
85 series
86 title
87 type
88 volume
89 year
90 doi
91 }
92 {}
93 { label extra.label sort.label }
94
95 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
96
97 FUNCTION {init.state.consts}
98 { #0 'before.all :=
99 #1 'mid.sentence :=
100 #2 'after.sentence :=
101 #3 'after.block :=
102 }
103
104 STRINGS { s t }
105
106 FUNCTION {output.nonnull}
107 { 's :=
108 output.state mid.sentence =
109 { ", " * write$ }
110 { output.state after.block =
111 { add.period$ write$
112 newline$
113 "\newblock " write$
114 }
115 { output.state before.all =
116 'write$
117 { add.period$ " " * write$ }
118 if$
119 }
120 if$
121 mid.sentence 'output.state :=
122 }
123 if$
124 s
125 }
126
127 FUNCTION {output}
128 { duplicate$ empty$
129 'pop$
130 'output.nonnull
131 if$
132 }
133
134 FUNCTION {output.check}
135 { 't :=
136 duplicate$ empty$
137 { pop$ "empty " t * " in " * cite$ * warning$ }
138 'output.nonnull
139 if$
140 }
141
142 % apalike needs this function because
143 % the year has special punctuation;
144 % apalike ignores the month
145 FUNCTION {output.year.check}
146 { year empty$
147 { "empty year in " cite$ * warning$ }
148 { write$
149 " (" year * extra.label * ")" *
150 mid.sentence 'output.state :=
151 }
152 if$
153 }
154
155 FUNCTION {output.bibitem}
156 { newline$
157 "\bibitem[" write$
158 label write$
159 "]{" write$
160 cite$ write$
161 "}" write$
162 newline$
163 ""
164 before.all 'output.state :=
165 }
166
167 FUNCTION {fin.entry}
168 { add.period$
169 write$
170 newline$
171 }
172
173 FUNCTION {new.block}
174 { output.state before.all =
175 'skip$
176 { after.block 'output.state := }
177 if$
178 }
179
180 FUNCTION {new.sentence}
181 { output.state after.block =
182 'skip$
183 { output.state before.all =
184 'skip$
185 { after.sentence 'output.state := }
186 if$
187 }
188 if$
189 }
190
191 FUNCTION {not}
192 { { #0 }
193 { #1 }
194 if$
195 }
196
197 FUNCTION {and}
198 { 'skip$
199 { pop$ #0 }
200 if$
201 }
202
203 FUNCTION {or}
204 { { pop$ #1 }
205 'skip$
206 if$
207 }
208
209 FUNCTION {new.block.checkb}
210 { empty$
211 swap$ empty$
212 and
213 'skip$
214 'new.block
215 if$
216 }
217
218 FUNCTION {field.or.null}
219 { duplicate$ empty$
220 { pop$ "" }
221 'skip$
222 if$
223 }
224
225 FUNCTION {emphasize}
226 { duplicate$ empty$
227 { pop$ "" }
228 { "{\em " swap$ * "}" * }
229 if$
230 }
231
232 INTEGERS { nameptr namesleft numnames }
233
234 FUNCTION {format.names}
235 { 's :=
236 #1 'nameptr :=
237 s num.names$ 'numnames :=
238 numnames 'namesleft :=
239 { namesleft #0 > }
240 { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := % last name first
241 nameptr #1 >
242 { namesleft #1 >
243 { ", " * t * }
244 { numnames #2 >
245 { "," * }
246 'skip$
247 if$
248 t "others" =
249 { " et~al." * }
250 { " and " * t * }
251 if$
252 }
253 if$
254 }
255 't
256 if$
257 nameptr #1 + 'nameptr :=
258 namesleft #1 - 'namesleft :=
259 }
260 while$
261 }
262
263 FUNCTION {format.authors}
264 { author empty$
265 { "" }
266 { author format.names }
267 if$
268 }
269
270 FUNCTION {format.key} % this function is just for apalike
271 { empty$
272 { key field.or.null }
273 { "" }
274 if$
275 }
276
277 FUNCTION {format.editors}
278 { editor empty$
279 { "" }
280 { editor format.names
281 editor num.names$ #1 >
282 { ", editors" * }
283 { ", editor" * }
284 if$
285 }
286 if$
287 }
288
289 FUNCTION {format.title}
290 { title empty$
291 { "" }
292 { title "t" change.case$ }
293 if$
294 }
295
296 FUNCTION {n.dashify}
297 { 't :=
298 ""
299 { t empty$ not }
300 { t #1 #1 substring$ "-" =
301 { t #1 #2 substring$ "--" = not
302 { "--" *
303 t #2 global.max$ substring$ 't :=
304 }
305 { { t #1 #1 substring$ "-" = }
306 { "-" *
307 t #2 global.max$ substring$ 't :=
308 }
309 while$
310 }
311 if$
312 }
313 { t #1 #1 substring$ *
314 t #2 global.max$ substring$ 't :=
315 }
316 if$
317 }
318 while$
319 }
320
321 FUNCTION {format.btitle}
322 { title emphasize
323 }
324
325 FUNCTION {tie.or.space.connect}
326 { duplicate$ text.length$ #3 <
327 { "~" }
328 { " " }
329 if$
330 swap$ * *
331 }
332
333 FUNCTION {either.or.check}
334 { empty$
335 'pop$
336 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
337 if$
338 }
339
340 FUNCTION {format.bvolume}
341 { volume empty$
342 { "" }
343 { "volume" volume tie.or.space.connect
344 series empty$
345 'skip$
346 { " of " * series emphasize * }
347 if$
348 "volume and number" number either.or.check
349 }
350 if$
351 }
352
353 FUNCTION {format.number.series}
354 { volume empty$
355 { number empty$
356 { series field.or.null }
357 { output.state mid.sentence =
358 { "number" }
359 { "Number" }
360 if$
361 number tie.or.space.connect
362 series empty$
363 { "there's a number but no series in " cite$ * warning$ }
364 { " in " * series * }
365 if$
366 }
367 if$
368 }
369 { "" }
370 if$
371 }
372
373 FUNCTION {format.edition}
374 { edition empty$
375 { "" }
376 { output.state mid.sentence =
377 { edition "l" change.case$ " edition" * }
378 { edition "t" change.case$ " edition" * }
379 if$
380 }
381 if$
382 }
383
384 INTEGERS { multiresult }
385
386 FUNCTION {multi.page.check}
387 { 't :=
388 #0 'multiresult :=
389 { multiresult not
390 t empty$ not
391 and
392 }
393 { t #1 #1 substring$
394 duplicate$ "-" =
395 swap$ duplicate$ "," =
396 swap$ "+" =
397 or or
398 { #1 'multiresult := }
399 { t #2 global.max$ substring$ 't := }
400 if$
401 }
402 while$
403 multiresult
404 }
405
406 FUNCTION {format.pages}
407 { pages empty$
408 { "" }
409 { pages multi.page.check
410 { "pages" pages n.dashify tie.or.space.connect }
411 { "page" pages tie.or.space.connect }
412 if$
413 }
414 if$
415 }
416
417 FUNCTION {format.vol.num.pages}
418 { volume field.or.null
419 number empty$
420 'skip$
421 { "(" number * ")" * *
422 volume empty$
423 { "there's a number but no volume in " cite$ * warning$ }
424 'skip$
425 if$
426 }
427 if$
428 pages empty$
429 'skip$
430 { duplicate$ empty$
431 { pop$ format.pages }
432 { ":" * pages n.dashify * }
433 if$
434 }
435 if$
436 }
437
438 FUNCTION {format.chapter.pages}
439 { chapter empty$
440 'format.pages
441 { type empty$
442 { "chapter" }
443 { type "l" change.case$ }
444 if$
445 chapter tie.or.space.connect
446 pages empty$
447 'skip$
448 { ", " * format.pages * }
449 if$
450 }
451 if$
452 }
453
454 FUNCTION {format.in.ed.booktitle}
455 { booktitle empty$
456 { "" }
457 { editor empty$
458 { "In " booktitle emphasize * }
459 { "In " format.editors * ", " * booktitle emphasize * }
460 if$
461 }
462 if$
463 }
464
465 FUNCTION {format.thesis.type}
466 { type empty$
467 'skip$
468 { pop$
469 type "t" change.case$
470 }
471 if$
472 }
473
474 FUNCTION {format.tr.number}
475 { type empty$
476 { "Technical Report" }
477 'type
478 if$
479 number empty$
480 { "t" change.case$ }
481 { number tie.or.space.connect }
482 if$
483 }
484
485 FUNCTION {format.article.crossref}
486 { "In" % this is for apalike
487 " \cite{" * crossref * "}" *
488 }
489
490 FUNCTION {format.book.crossref}
491 { volume empty$
492 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
493 "In "
494 }
495 { "Volume" volume tie.or.space.connect
496 " of " *
497 }
498 if$
499 "\cite{" * crossref * "}" * % this is for apalike
500 }
501
502 FUNCTION {format.incoll.inproc.crossref}
503 { "In" % this is for apalike
504 " \cite{" * crossref * "}" *
505 }
506
507 FUNCTION {article}
508 { output.bibitem
509 format.authors "author" output.check
510 author format.key output % special for
511 output.year.check % apalike
512 new.block
513 format.title "title" output.check
514 new.block
515 crossref missing$
516 { journal emphasize "journal" output.check
517 format.vol.num.pages output
518 }
519 { format.article.crossref output.nonnull
520 format.pages output
521 }
522 if$
523 new.block
524 note output
525 fin.entry
526 }
527
528 FUNCTION {book}
529 { output.bibitem
530 author empty$
531 { format.editors "author and editor" output.check
532 editor format.key output
533 }
534 { format.authors output.nonnull
535 crossref missing$
536 { "author and editor" editor either.or.check }
537 'skip$
538 if$
539 }
540 if$
541 output.year.check % special for apalike
542 new.block
543 format.btitle "title" output.check
544 crossref missing$
545 { format.bvolume output
546 new.block
547 format.number.series output
548 new.sentence
549 publisher "publisher" output.check
550 address output
551 }
552 { new.block
553 format.book.crossref output.nonnull
554 }
555 if$
556 format.edition output
557 new.block
558 note output
559 fin.entry
560 }
561
562 FUNCTION {booklet}
563 { output.bibitem
564 format.authors output
565 author format.key output % special for
566 output.year.check % apalike
567 new.block
568 format.title "title" output.check
569 new.block
570 howpublished output
571 address output
572 new.block
573 note output
574 fin.entry
575 }
576
577 FUNCTION {inbook}
578 { output.bibitem
579 author empty$
580 { format.editors "author and editor" output.check
581 editor format.key output
582 }
583 { format.authors output.nonnull
584 crossref missing$
585 { "author and editor" editor either.or.check }
586 'skip$
587 if$
588 }
589 if$
590 output.year.check % special for apalike
591 new.block
592 format.btitle "title" output.check
593 crossref missing$
594 { format.bvolume output
595 format.chapter.pages "chapter and pages" output.check
596 new.block
597 format.number.series output
598 new.sentence
599 publisher "publisher" output.check
600 address output
601 }
602 { format.chapter.pages "chapter and pages" output.check
603 new.block
604 format.book.crossref output.nonnull
605 }
606 if$
607 format.edition output
608 new.block
609 note output
610 fin.entry
611 }
612
613 FUNCTION {incollection}
614 { output.bibitem
615 format.authors "author" output.check
616 author format.key output % special for
617 output.year.check % apalike
618 new.block
619 format.title "title" output.check
620 new.block
621 crossref missing$
622 { format.in.ed.booktitle "booktitle" output.check
623 format.bvolume output
624 format.number.series output
625 format.chapter.pages output
626 new.sentence
627 publisher "publisher" output.check
628 address output
629 format.edition output
630 }
631 { format.incoll.inproc.crossref output.nonnull
632 format.chapter.pages output
633 }
634 if$
635 new.block
636 note output
637 fin.entry
638 }
639
640 FUNCTION {inproceedings}
641 { output.bibitem
642 format.authors "author" output.check
643 author format.key output % special for
644 output.year.check % apalike
645 new.block
646 format.title "title" output.check
647 new.block
648 crossref missing$
649 { format.in.ed.booktitle "booktitle" output.check
650 format.bvolume output
651 format.number.series output
652 format.pages output
653 address output % for apalike
654 new.sentence % there's no year
655 organization output % here so things
656 publisher output % are simpler
657 }
658 { format.incoll.inproc.crossref output.nonnull
659 format.pages output
660 }
661 if$
662 new.block
663 note output
664 fin.entry
665 }
666
667 FUNCTION {conference} { inproceedings }
668
669 FUNCTION {manual}
670 { output.bibitem
671 format.authors output
672 author format.key output % special for
673 output.year.check % apalike
674 new.block
675 format.btitle "title" output.check
676 organization address new.block.checkb
677 organization output
678 address output
679 format.edition output
680 new.block
681 note output
682 fin.entry
683 }
684
685 FUNCTION {mastersthesis}
686 { output.bibitem
687 format.authors "author" output.check
688 author format.key output % special for
689 output.year.check % apalike
690 new.block
691 format.title "title" output.check
692 new.block
693 "Master's thesis" format.thesis.type output.nonnull
694 school "school" output.check
695 address output
696 new.block
697 note output
698 fin.entry
699 }
700
701 FUNCTION {misc}
702 { output.bibitem
703 format.authors output
704 author format.key output % special for
705 output.year.check % apalike
706 new.block
707 format.title output
708 new.block
709 howpublished output
710 new.block
711 note output
712 fin.entry
713 }
714
715 FUNCTION {phdthesis}
716 { output.bibitem
717 format.authors "author" output.check
718 author format.key output % special for
719 output.year.check % apalike
720 new.block
721 format.btitle "title" output.check
722 new.block
723 "PhD thesis" format.thesis.type output.nonnull
724 school "school" output.check
725 address output
726 new.block
727 note output
728 fin.entry
729 }
730
731 FUNCTION {proceedings}
732 { output.bibitem
733 format.editors output
734 editor format.key output % special for
735 output.year.check % apalike
736 new.block
737 format.btitle "title" output.check
738 format.bvolume output
739 format.number.series output
740 address output % for apalike
741 new.sentence % we always output
742 organization output % a nonempty organization
743 publisher output % here
744 new.block
745 note output
746 fin.entry
747 }
748
749 FUNCTION {techreport}
750 { output.bibitem
751 format.authors "author" output.check
752 author format.key output % special for
753 output.year.check % apalike
754 new.block
755 format.title "title" output.check
756 new.block
757 format.tr.number output.nonnull
758 institution "institution" output.check
759 address output
760 new.block
761 note output
762 fin.entry
763 }
764
765 FUNCTION {unpublished}
766 { output.bibitem
767 format.authors "author" output.check
768 author format.key output % special for
769 output.year.check % apalike
770 new.block
771 format.title "title" output.check
772 new.block
773 note "note" output.check
774 fin.entry
775 }
776
777 FUNCTION {default.type} { misc }
778
779 MACRO {jan} {"January"}
780
781 MACRO {feb} {"February"}
782
783 MACRO {mar} {"March"}
784
785 MACRO {apr} {"April"}
786
787 MACRO {may} {"May"}
788
789 MACRO {jun} {"June"}
790
791 MACRO {jul} {"July"}
792
793 MACRO {aug} {"August"}
794
795 MACRO {sep} {"September"}
796
797 MACRO {oct} {"October"}
798
799 MACRO {nov} {"November"}
800
801 MACRO {dec} {"December"}
802
803 MACRO {acmcs} {"ACM Computing Surveys"}
804
805 MACRO {acta} {"Acta Informatica"}
806
807 MACRO {cacm} {"Communications of the ACM"}
808
809 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
810
811 MACRO {ibmsj} {"IBM Systems Journal"}
812
813 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
814
815 MACRO {ieeetc} {"IEEE Transactions on Computers"}
816
817 MACRO {ieeetcad}
818 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
819
820 MACRO {ipl} {"Information Processing Letters"}
821
822 MACRO {jacm} {"Journal of the ACM"}
823
824 MACRO {jcss} {"Journal of Computer and System Sciences"}
825
826 MACRO {scp} {"Science of Computer Programming"}
827
828 MACRO {sicomp} {"SIAM Journal on Computing"}
829
830 MACRO {tocs} {"ACM Transactions on Computer Systems"}
831
832 MACRO {tods} {"ACM Transactions on Database Systems"}
833
834 MACRO {tog} {"ACM Transactions on Graphics"}
835
836 MACRO {toms} {"ACM Transactions on Mathematical Software"}
837
838 MACRO {toois} {"ACM Transactions on Office Information Systems"}
839
840 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
841
842 MACRO {tcs} {"Theoretical Computer Science"}
843
844 READ
845
846 FUNCTION {sortify}
847 { purify$
848 "l" change.case$
849 }
850
851 INTEGERS { len }
852
853 FUNCTION {chop.word}
854 { 's :=
855 'len :=
856 s #1 len substring$ =
857 { s len #1 + global.max$ substring$ }
858 's
859 if$
860 }
861
862 % There are three apalike cases: one person (Jones),
863 % two (Jones and de~Bruijn), and more (Jones et~al.).
864 % This function is much like format.crossref.editors.
865 %
866 % CIAD UPDATE: We consider only the first and third cases.
867 %
868 FUNCTION {format.lab.names}
869 { 's :=
870 s #1 "{vv~}{ll}" format.name$
871 }
872
873 FUNCTION {author.key.label}
874 { author empty$
875 { key empty$
876 { cite$ #1 #3 substring$ }
877 'key % apalike uses the whole key
878 if$
879 }
880 { author format.lab.names }
881 if$
882 }
883
884 FUNCTION {author.editor.key.label}
885 { author empty$
886 { editor empty$
887 { key empty$
888 { cite$ #1 #3 substring$ }
889 'key % apalike uses the whole key
890 if$
891 }
892 { editor format.lab.names }
893 if$
894 }
895 { author format.lab.names }
896 if$
897 }
898
899 FUNCTION {editor.key.label}
900 { editor empty$
901 { key empty$
902 { cite$ #1 #3 substring$ }
903 'key % apalike uses the whole key, no organization
904 if$
905 }
906 { editor format.lab.names }
907 if$
908 }
909
910 FUNCTION {calc.label.namesyear}
911 { type$ "book" =
912 type$ "inbook" =
913 or
914 'author.editor.key.label
915 { type$ "proceedings" =
916 'editor.key.label % apalike ignores organization
917 'author.key.label % for labeling and sorting
918 if$
919 }
920 if$
921 ", " % these three lines are
922 * % for apalike, which
923 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
924 *
925 }
926
927 FUNCTION {calc.label.doi}
928 { "\href{https://doi.org/" doi field.or.null *
929 "}{" *
930 doi field.or.null *
931 "}" *
932 }
933
934 FUNCTION {calc.label}
935 { doi empty$
936 { calc.label.namesyear }
937 { "\biblabelciad{" calc.label.namesyear *
938 "}{" *
939 calc.label.doi *
940 "}" *
941 }
942 if$
943 'label :=
944 }
945
946 FUNCTION {sort.format.names}
947 { 's :=
948 #1 'nameptr :=
949 ""
950 s num.names$ 'numnames :=
951 numnames 'namesleft :=
952 { namesleft #0 > }
953 { nameptr #1 >
954 { " " * }
955 'skip$
956 if$ % apalike uses initials
957 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
958 nameptr numnames = t "others" = and
959 { "et al" * }
960 { t sortify * }
961 if$
962 nameptr #1 + 'nameptr :=
963 namesleft #1 - 'namesleft :=
964 }
965 while$
966 }
967
968 FUNCTION {sort.format.title}
969 { 't :=
970 "A " #2
971 "An " #3
972 "The " #4 t chop.word
973 chop.word
974 chop.word
975 sortify
976 #1 global.max$ substring$
977 }
978
979 FUNCTION {author.sort}
980 { author empty$
981 { key empty$
982 { "to sort, need author or key in " cite$ * warning$
983 ""
984 }
985 { key sortify }
986 if$
987 }
988 { author sort.format.names }
989 if$
990 }
991
992 FUNCTION {author.editor.sort}
993 { author empty$
994 { editor empty$
995 { key empty$
996 { "to sort, need author, editor, or key in " cite$ * warning$
997 ""
998 }
999 { key sortify }
1000 if$
1001 }
1002 { editor sort.format.names }
1003 if$
1004 }
1005 { author sort.format.names }
1006 if$
1007 }
1008
1009 FUNCTION {editor.sort}
1010 { editor empty$
1011 { key empty$
1012 { "to sort, need editor or key in " cite$ * warning$
1013 ""
1014 }
1015 { key sortify }
1016 if$
1017 }
1018 { editor sort.format.names }
1019 if$
1020 }
1021
1022 % apalike uses two sorting passes; the first one sets the
1023 % labels so that the `a's, `b's, etc. can be computed;
1024 % the second pass puts the references in "correct" order.
1025 % The presort function is for the first pass. It computes
1026 % label, sort.label, and title, and then concatenates.
1027 FUNCTION {presort}
1028 { calc.label
1029 label sortify
1030 " "
1031 *
1032 type$ "book" =
1033 type$ "inbook" =
1034 or
1035 'author.editor.sort
1036 { type$ "proceedings" =
1037 'editor.sort
1038 'author.sort
1039 if$
1040 }
1041 if$
1042 #1 entry.max$ substring$ % for
1043 'sort.label := % apalike
1044 sort.label % style
1045 *
1046 " "
1047 *
1048 title field.or.null
1049 sort.format.title
1050 *
1051 #1 entry.max$ substring$
1052 'sort.key$ :=
1053 }
1054
1055 ITERATE {presort}
1056
1057 SORT % by label, sort.label, title---for final label calculation
1058
1059 STRINGS { last.label next.extra } % apalike labels are only for the text;
1060
1061 INTEGERS { last.extra.num } % there are none in the bibliography
1062
1063 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1064 { #0 int.to.chr$ 'last.label :=
1065 "" 'next.extra :=
1066 #0 'last.extra.num :=
1067 }
1068
1069 FUNCTION {forward.pass}
1070 { last.label label =
1071 { last.extra.num #1 + 'last.extra.num :=
1072 last.extra.num int.to.chr$ 'extra.label :=
1073 }
1074 { "a" chr.to.int$ 'last.extra.num :=
1075 "" 'extra.label :=
1076 label 'last.label :=
1077 }
1078 if$
1079 }
1080
1081 FUNCTION {reverse.pass}
1082 { next.extra "b" =
1083 { "a" 'extra.label := }
1084 'skip$
1085 if$
1086 label extra.label * 'label :=
1087 extra.label 'next.extra :=
1088 }
1089
1090 EXECUTE {initialize.extra.label.stuff}
1091
1092 ITERATE {forward.pass}
1093
1094 REVERSE {reverse.pass}
1095
1096 % Now that the label is right we sort for real,
1097 % on sort.label then year then title. This is
1098 % for the second sorting pass.
1099 FUNCTION {bib.sort.order}
1100 { sort.label
1101 " "
1102 *
1103 year field.or.null sortify
1104 *
1105 " "
1106 *
1107 title field.or.null
1108 sort.format.title
1109 *
1110 #1 entry.max$ substring$
1111 'sort.key$ :=
1112 }
1113
1114 ITERATE {bib.sort.order}
1115
1116 SORT % by sort.label, year, title---giving final bibliography order
1117
1118 FUNCTION {begin.bib}
1119 { preamble$ empty$ % no \etalchar in apalike
1120 'skip$
1121 { preamble$ write$ newline$ }
1122 if$
1123 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1124 }
1125
1126 EXECUTE {begin.bib}
1127
1128 EXECUTE {init.state.consts}
1129
1130 ITERATE {call.type$}
1131
1132 FUNCTION {end.bib}
1133 { newline$
1134 "\end{thebibliography}" write$ newline$
1135 }
1136
1137 EXECUTE {end.bib}