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