"Fossies" - the Fresh Open Source Software Archive

Member "relax-5.0.0/docs/latex/relax.bst" (18 Apr 2019, 21701 Bytes) of package /linux/privat/relax-5.0.0.src.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "relax.bst": 4.0.3_vs_4.1.0.

    1 % Copyright (C) 2006,2012 Edward d'Auvergne
    2 % 
    3 % This is a modification to the `apalike' bibliography style to make it more
    4 % like the style used by Kluwer (which most likely comes from the `apalike'
    5 % style itself.  The modifications have been made by Edward d'Auvergne.
    6 % The `apalike' comments have been left in this file and are:
    7 %
    8 % BibTeX `apalike' bibliography style (24-Jan-88 version)
    9 % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
   10 % Copyright (C) 1988, all rights reserved.
   11 % Copying of this file is allowed, provided that if you make any changes at all
   12 % you name it something other than `apalike.bst'.
   13 % This restriction helps ensure that all copies are identical.
   14 % Differences between this style and `alpha' are generally heralded by a `%'.
   15 % The file btxbst.doc has the documentation for alpha.bst.
   16 %
   17 % This style should be used with the `apalike' LaTeX style (apalike.sty).
   18 % \cite's come out like "(Jones, 1986)" in the text but there are no labels
   19 % in the bibliography, and something like "(1986)" comes out immediately
   20 % after the author.  Author (and editor) names appear as last name, comma,
   21 % initials.  A `year' field is required for every entry, and so is either
   22 % an author (or in some cases, an editor) field or a key field.
   23 %
   24 % Editorial note:
   25 % Many journals require a style like `apalike', but I strongly, strongly,
   26 % strongly recommend that you not use it if you have a choice---use something
   27 % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
   28 % Knopf, 1979) argues convincingly that a style like `plain' encourages better
   29 % writing than one like `apalike'.  Furthermore the strongest arguments for
   30 % using an author-date style like `apalike'---that it's "the most practical"
   31 % (The Chicago Manual of Style, University of Chicago Press, thirteenth
   32 % edition, 1982, pages 400--401)---fall flat on their face with the new
   33 % computer-typesetting technology.  For instance page 401 anachronistically
   34 % states "The chief disadvantage of [a style like `plain'] is that additions
   35 % or deletions cannot be made after the manuscript is typed without changing
   36 % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
   37 %
   38 % History:
   39 %   15-sep-86	(SK,OP)	Original version, by Susan King and Oren Patashnik.
   40 %   10-nov-86	(OP)	Truncated the sort.key$ string to the correct length
   41 %			in bib.sort.order to eliminate error message.
   42 %   24-jan-88	(OP)	Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
   43 %			apalike now sorts by author, then year, then title;
   44 %			THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
   45 
   46 ENTRY
   47   { address
   48     author
   49     booktitle
   50     chapter
   51     doi
   52     edition
   53     editor
   54     howpublished
   55     institution
   56     journal
   57     key
   58 %    month		not used in apalike
   59     note
   60     number
   61     organization
   62     pages
   63     publisher
   64     school
   65     series
   66     title
   67     type
   68     volume
   69     year
   70   }
   71   {}
   72   { label extra.label sort.label }
   73 
   74 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
   75 
   76 FUNCTION {init.state.consts}
   77 { #0 'before.all :=
   78   #1 'mid.sentence :=
   79   #2 'after.sentence :=
   80   #3 'after.block :=
   81 }
   82 
   83 STRINGS { s t }
   84 
   85 FUNCTION {output.nonnull}
   86 { 's :=
   87   output.state mid.sentence =
   88     { ", " * write$ }
   89     { output.state after.block =
   90     { add.period$ write$
   91       newline$
   92       "\newblock " write$
   93     }
   94     { output.state before.all =
   95         'write$
   96         { add.period$ " " * write$ }
   97       if$
   98     }
   99       if$
  100       mid.sentence 'output.state :=
  101     }
  102   if$
  103   s
  104 }
  105 
  106 FUNCTION {output}
  107 { duplicate$ empty$
  108     'pop$
  109     'output.nonnull
  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 %                    apalike needs this function because
  122 %                    the year has special punctuation;
  123 %                    apalike ignores the month
  124 FUNCTION {output.year.check}
  125 { year empty$
  126     { "empty year in " cite$ * warning$ }
  127     { write$
  128       " (" year * extra.label * ")" *
  129       mid.sentence 'output.state :=
  130     }
  131   if$
  132 }
  133 
  134 FUNCTION {output.bibitem}
  135 { newline$
  136   "\bibitem[" write$
  137   label write$
  138   "]{" write$
  139   cite$ write$
  140   "}" write$
  141   newline$
  142   ""
  143   before.all 'output.state :=
  144 }
  145 
  146 FUNCTION {fin.entry}
  147 { add.period$
  148   write$
  149   newline$
  150 }
  151 
  152 FUNCTION {new.block}
  153 { output.state before.all =
  154     'skip$
  155     { after.block 'output.state := }
  156   if$
  157 }
  158 
  159 FUNCTION {new.sentence}
  160 { output.state after.block =
  161     'skip$
  162     { output.state before.all =
  163     'skip$
  164     { after.sentence 'output.state := }
  165       if$
  166     }
  167   if$
  168 }
  169 
  170 FUNCTION {not}
  171 {   { #0 }
  172     { #1 }
  173   if$
  174 }
  175 
  176 FUNCTION {and}
  177 {   'skip$
  178     { pop$ #0 }
  179   if$
  180 }
  181 
  182 FUNCTION {or}
  183 {   { pop$ #1 }
  184     'skip$
  185   if$
  186 }
  187 
  188 FUNCTION {new.block.checkb}
  189 { empty$
  190   swap$ empty$
  191   and
  192     'skip$
  193     'new.block
  194   if$
  195 }
  196 
  197 FUNCTION {field.or.null}
  198 { duplicate$ empty$
  199     { pop$ "" }
  200     'skip$
  201   if$
  202 }
  203 
  204 FUNCTION {boldface}
  205 { duplicate$ empty$
  206     { pop$ "" }
  207     { "{\bf " swap$ * "}" * }
  208   if$
  209 }
  210  
  211 FUNCTION {emphasize}
  212 { duplicate$ empty$
  213     { pop$ "" }
  214     { "{\em " swap$ * "}" * }
  215   if$
  216 }
  217 
  218 INTEGERS { nameptr namesleft numnames }
  219 
  220 FUNCTION {format.names}
  221 { 's :=
  222   #1 'nameptr :=
  223   s num.names$ 'numnames :=
  224   numnames 'namesleft :=
  225     { namesleft #0 > }
  226     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  227       nameptr #1 >
  228     { namesleft #1 >
  229         { ", " * t * }
  230         { numnames #2 >
  231         { "," * }
  232         'skip$
  233           if$
  234           t "others" =
  235         { " et~al." * }
  236         { " and " * t * }
  237           if$
  238         }
  239       if$
  240     }
  241     't
  242       if$
  243       nameptr #1 + 'nameptr :=
  244       namesleft #1 - 'namesleft :=
  245     }
  246   while$
  247 }
  248 
  249 FUNCTION {format.authors}
  250 { author empty$
  251     { "" }
  252     { author format.names }
  253   if$
  254 }
  255 
  256 FUNCTION {format.key}            % this function is just for apalike
  257 { empty$
  258     { key field.or.null }
  259     { "" }
  260   if$
  261 }
  262 
  263 FUNCTION {format.editors}
  264 { editor empty$
  265     { "" }
  266     { editor format.names
  267       editor num.names$ #1 >
  268     { " (eds.)" * }
  269     { " (ed.)" * }
  270       if$
  271     }
  272   if$
  273 }
  274 
  275 FUNCTION {format.doi}
  276 {
  277   doi empty$
  278     { "" }
  279     { "(\href{http://dx.doi.org/" doi * "}{" * doi * "})" * }
  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.btitle}
  316 { title emphasize
  317 }
  318 
  319 FUNCTION {tie.or.space.connect}
  320 { duplicate$ text.length$ #3 <
  321     { "~" }
  322     { " " }
  323   if$
  324   swap$ * *
  325 }
  326 
  327 FUNCTION {either.or.check}
  328 { empty$
  329     'pop$
  330     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  331   if$
  332 }
  333 
  334 FUNCTION {format.bvolume}
  335 { volume empty$
  336     { "" }
  337     { "Vol." volume tie.or.space.connect
  338       series empty$
  339     'skip$
  340     { " of " * series emphasize * }
  341       if$
  342       "volume and number" number either.or.check
  343     }
  344   if$
  345 }
  346 
  347 FUNCTION {format.number.series}
  348 { volume empty$
  349     { number empty$
  350     { series field.or.null }
  351     { output.state mid.sentence =
  352         { "No." }
  353         { "No." }
  354       if$
  355       number tie.or.space.connect
  356       series empty$
  357         { "there's a number but no series in " cite$ * warning$ }
  358         { " in " * series * }
  359       if$
  360     }
  361       if$
  362     }
  363     { "" }
  364   if$
  365 }
  366 
  367 FUNCTION {format.edition}
  368 { edition empty$
  369     { "" }
  370     { output.state mid.sentence =
  371     { edition "l" change.case$ " edition" * }
  372     { edition "t" change.case$ " edition" * }
  373       if$
  374     }
  375   if$
  376 }
  377 
  378 INTEGERS { multiresult }
  379 
  380 FUNCTION {multi.page.check}
  381 { 't :=
  382   #0 'multiresult :=
  383     { multiresult not
  384       t empty$ not
  385       and
  386     }
  387     { t #1 #1 substring$
  388       duplicate$ "-" =
  389       swap$ duplicate$ "," =
  390       swap$ "+" =
  391       or or
  392     { #1 'multiresult := }
  393     { t #2 global.max$ substring$ 't := }
  394       if$
  395     }
  396   while$
  397   multiresult
  398 }
  399 
  400 FUNCTION {format.pages}
  401 { pages empty$
  402     { "" }
  403     { pages multi.page.check
  404     { "pages" pages n.dashify tie.or.space.connect }
  405     { "page" pages tie.or.space.connect }
  406       if$
  407     }
  408   if$
  409 }
  410 
  411 FUNCTION {format.vol.num.pages}
  412 { volume field.or.null
  413   volume empty$
  414     'skip$
  415     { boldface }
  416   if$
  417   number empty$
  418     'skip$
  419     { "(" number * ")" * *
  420       volume empty$
  421     { "there's a number but no volume in " cite$ * warning$ }
  422     'skip$
  423       if$
  424     }
  425   if$
  426   pages empty$
  427     'skip$
  428     { duplicate$ empty$
  429     { pop$ format.pages }
  430     { ", " * pages n.dashify * }
  431       if$
  432     }
  433   if$
  434 }
  435 
  436 FUNCTION {format.chapter.pages}
  437 { chapter empty$
  438     'format.pages
  439     { type empty$
  440     { "Chapt." }
  441     { type "l" change.case$ }
  442       if$
  443       chapter tie.or.space.connect
  444       pages empty$
  445     'skip$
  446     { ", " * format.pages * }
  447       if$
  448     }
  449   if$
  450 }
  451 
  452 FUNCTION {format.in.ed.booktitle}
  453 { booktitle empty$
  454     { "" }
  455     { editor empty$
  456     { "In: " booktitle emphasize * }
  457     { "In: " format.editors * ": " * booktitle emphasize * }
  458       if$
  459     }
  460   if$
  461 }
  462 
  463 FUNCTION {format.thesis.type}
  464 { type empty$
  465     'skip$
  466     { pop$
  467       type "t" change.case$
  468     }
  469   if$
  470 }
  471 
  472 FUNCTION {format.tr.number}
  473 { type empty$
  474     { "Technical Report" }
  475     'type
  476   if$
  477   number empty$
  478     { "t" change.case$ }
  479     { number tie.or.space.connect }
  480   if$
  481 }
  482 
  483 FUNCTION {format.article.crossref}
  484 { "In"							% this is for apalike
  485   " \cite{" * crossref * "}" *
  486 }
  487 
  488 FUNCTION {format.book.crossref}
  489 { volume empty$
  490     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  491       "In "
  492     }
  493     { "Vol." volume tie.or.space.connect
  494       " of " *
  495     }
  496   if$
  497   "\cite{" * crossref * "}" *				% this is for apalike
  498 }
  499 
  500 FUNCTION {format.incoll.inproc.crossref}
  501 { "In"							% this is for apalike
  502   " \cite{" * crossref * "}" *
  503 }
  504 
  505 FUNCTION {article}
  506 { output.bibitem
  507   format.authors "author" output.check
  508   author format.key output				% special for
  509   output.year.check					% apalike
  510   new.block
  511   format.title "title" output.check
  512   new.block
  513   crossref missing$
  514     { journal emphasize "journal" output.check
  515       format.vol.num.pages output
  516     }
  517     { format.article.crossref output.nonnull
  518       format.pages output
  519     }
  520   if$
  521   new.block
  522   format.doi output
  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
  644   output.year.check
  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       new.sentence
  652       format.number.series output
  653       address output
  654       organization output
  655       format.pages output
  656     }
  657     { format.incoll.inproc.crossref output.nonnull
  658       format.pages output
  659     }
  660   if$
  661   publisher output
  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   format.doi output
  728   new.block
  729   note output
  730   fin.entry
  731 }
  732 
  733 FUNCTION {proceedings}
  734 { output.bibitem
  735   format.editors output
  736   editor format.key output				% special for
  737   output.year.check					% apalike
  738   new.block
  739   format.btitle "title" output.check
  740   format.bvolume output
  741   format.number.series output
  742   address output				% for apalike
  743   new.sentence					% we always output
  744   organization output				% a nonempty organization
  745   publisher output				% here
  746   new.block
  747   note output
  748   fin.entry
  749 }
  750 
  751 FUNCTION {techreport}
  752 { output.bibitem
  753   format.authors "author" output.check
  754   author format.key output				% special for
  755   output.year.check					% apalike
  756   new.block
  757   format.title "title" output.check
  758   new.block
  759   format.tr.number output.nonnull
  760   institution "institution" output.check
  761   address output
  762   new.block
  763   note output
  764   fin.entry
  765 }
  766 
  767 FUNCTION {unpublished}
  768 { output.bibitem
  769   format.authors "author" output.check
  770   author format.key output				% special for
  771   output.year.check					% apalike
  772   new.block
  773   format.title "title" output.check
  774   new.block
  775   note "note" output.check
  776   fin.entry
  777 }
  778 
  779 FUNCTION {default.type} { misc }
  780 
  781 MACRO {jan} {"January"}
  782 
  783 MACRO {feb} {"February"}
  784 
  785 MACRO {mar} {"March"}
  786 
  787 MACRO {apr} {"April"}
  788 
  789 MACRO {may} {"May"}
  790 
  791 MACRO {jun} {"June"}
  792 
  793 MACRO {jul} {"July"}
  794 
  795 MACRO {aug} {"August"}
  796 
  797 MACRO {sep} {"September"}
  798 
  799 MACRO {oct} {"October"}
  800 
  801 MACRO {nov} {"November"}
  802 
  803 MACRO {dec} {"December"}
  804 
  805 READ
  806 
  807 FUNCTION {sortify}
  808 { purify$
  809   "l" change.case$
  810 }
  811 
  812 INTEGERS { len }
  813 
  814 FUNCTION {chop.word}
  815 { 's :=
  816   'len :=
  817   s #1 len substring$ =
  818     { s len #1 + global.max$ substring$ }
  819     's
  820   if$
  821 }
  822 
  823 %			There are three apalike cases: one person (Jones),
  824 %			two (Jones and de~Bruijn), and more (Jones et~al.).
  825 %			This function is much like format.crossref.editors.
  826 %
  827 FUNCTION {format.lab.names}
  828 { 's :=
  829   s #1 "{vv~}{ll}" format.name$
  830   s num.names$ duplicate$
  831   #2 >
  832     { pop$ " et~al." * }
  833     { #2 <
  834     'skip$
  835     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  836         { " et~al." * }
  837         { " and " * s #2 "{vv~}{ll}" format.name$ * }
  838       if$
  839     }
  840       if$
  841     }
  842   if$
  843 }
  844 
  845 FUNCTION {author.key.label}
  846 { author empty$
  847     { key empty$
  848     { cite$ #1 #3 substring$ }
  849     'key					% apalike uses the whole key
  850       if$
  851     }
  852     { author format.lab.names }
  853   if$
  854 }
  855 
  856 FUNCTION {author.editor.key.label}
  857 { author empty$
  858     { editor empty$
  859     { key empty$
  860         { cite$ #1 #3 substring$ }
  861         'key				% apalike uses the whole key
  862       if$
  863     }
  864     { editor format.lab.names }
  865       if$
  866     }
  867     { author format.lab.names }
  868   if$
  869 }
  870 
  871 FUNCTION {editor.key.label}
  872 { editor empty$
  873     { key empty$
  874     { cite$ #1 #3 substring$ }
  875     'key			% apalike uses the whole key, no organization
  876       if$
  877     }
  878     { editor format.lab.names }
  879   if$
  880 }
  881 
  882 FUNCTION {calc.label}
  883 { type$ "book" =
  884   type$ "inbook" =
  885   or
  886     'author.editor.key.label
  887     { type$ "proceedings" =
  888     'editor.key.label			% apalike ignores organization
  889     'author.key.label			% for labeling and sorting
  890       if$
  891     }
  892   if$
  893   ", "							% these three lines are
  894   *							% for apalike, which
  895   year field.or.null purify$ #-1 #4 substring$		% uses all four digits
  896   *
  897   'label :=
  898 }
  899 
  900 FUNCTION {sort.format.names}
  901 { 's :=
  902   #1 'nameptr :=
  903   ""
  904   s num.names$ 'numnames :=
  905   numnames 'namesleft :=
  906     { namesleft #0 > }
  907     { nameptr #1 >
  908     { "   " * }
  909     'skip$
  910       if$						% apalike uses initials
  911       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  912       nameptr numnames = t "others" = and
  913     { "et al" * }
  914     { t sortify * }
  915       if$
  916       nameptr #1 + 'nameptr :=
  917       namesleft #1 - 'namesleft :=
  918     }
  919   while$
  920 }
  921 
  922 FUNCTION {sort.format.title}
  923 { 't :=
  924   "A " #2
  925     "An " #3
  926       "The " #4 t chop.word
  927     chop.word
  928   chop.word
  929   sortify
  930   #1 global.max$ substring$
  931 }
  932 
  933 FUNCTION {author.sort}
  934 { author empty$
  935     { key empty$
  936     { "to sort, need author or key in " cite$ * warning$
  937       ""
  938     }
  939     { key sortify }
  940       if$
  941     }
  942     { author sort.format.names }
  943   if$
  944 }
  945 
  946 FUNCTION {author.editor.sort}
  947 { author empty$
  948     { editor empty$
  949     { key empty$
  950         { "to sort, need author, editor, or key in " cite$ * warning$
  951           ""
  952         }
  953         { key sortify }
  954       if$
  955     }
  956     { editor sort.format.names }
  957       if$
  958     }
  959     { author sort.format.names }
  960   if$
  961 }
  962 
  963 FUNCTION {editor.sort}
  964 { editor empty$
  965     { key empty$
  966     { "to sort, need editor or key in " cite$ * warning$
  967       ""
  968     }
  969     { key sortify }
  970       if$
  971     }
  972     { editor sort.format.names }
  973   if$
  974 }
  975 
  976 %			apalike uses two sorting passes; the first one sets the
  977 %			labels so that the `a's, `b's, etc. can be computed;
  978 %			the second pass puts the references in "correct" order.
  979 %			The presort function is for the first pass. It computes
  980 %			label, sort.label, and title, and then concatenates.
  981 FUNCTION {presort}
  982 { calc.label
  983   label sortify
  984   "    "
  985   *
  986   type$ "book" =
  987   type$ "inbook" =
  988   or
  989     'author.editor.sort
  990     { type$ "proceedings" =
  991     'editor.sort
  992     'author.sort
  993       if$
  994     }
  995   if$
  996   #1 entry.max$ substring$	% for
  997   'sort.label :=		% apalike
  998   sort.label			% style
  999   *
 1000   "    "
 1001   *
 1002   title field.or.null
 1003   sort.format.title
 1004   *
 1005   #1 entry.max$ substring$
 1006   'sort.key$ :=
 1007 }
 1008 
 1009 ITERATE {presort}
 1010 
 1011 SORT		% by label, sort.label, title---for final label calculation
 1012 
 1013 STRINGS { last.label next.extra }	% apalike labels are only for the text;
 1014 
 1015 INTEGERS { last.extra.num }		% there are none in the bibliography
 1016 
 1017 FUNCTION {initialize.extra.label.stuff}	% and hence there is no `longest.label'
 1018 { #0 int.to.chr$ 'last.label :=
 1019   "" 'next.extra :=
 1020   #0 'last.extra.num :=
 1021 }
 1022 
 1023 FUNCTION {forward.pass}
 1024 { last.label label =
 1025     { last.extra.num #1 + 'last.extra.num :=
 1026       last.extra.num int.to.chr$ 'extra.label :=
 1027     }
 1028     { "a" chr.to.int$ 'last.extra.num :=
 1029       "" 'extra.label :=
 1030       label 'last.label :=
 1031     }
 1032   if$
 1033 }
 1034 
 1035 FUNCTION {reverse.pass}
 1036 { next.extra "b" =
 1037     { "a" 'extra.label := }
 1038     'skip$
 1039   if$
 1040   label extra.label * 'label :=
 1041   extra.label 'next.extra :=
 1042 }
 1043 
 1044 EXECUTE {initialize.extra.label.stuff}
 1045 
 1046 ITERATE {forward.pass}
 1047 
 1048 REVERSE {reverse.pass}
 1049 
 1050 %				Now that the label is right we sort for real,
 1051 %				on sort.label then year then title.  This is
 1052 %				for the second sorting pass.
 1053 FUNCTION {bib.sort.order}
 1054 { sort.label
 1055   "    "
 1056   *
 1057   year field.or.null sortify
 1058   *
 1059   "    "
 1060   *
 1061   title field.or.null
 1062   sort.format.title
 1063   *
 1064   #1 entry.max$ substring$
 1065   'sort.key$ :=
 1066 }
 1067 
 1068 ITERATE {bib.sort.order}
 1069 
 1070 SORT		% by sort.label, year, title---giving final bibliography order
 1071 
 1072 FUNCTION {begin.bib}
 1073 { preamble$ empty$				% no \etalchar in apalike
 1074     'skip$
 1075     { preamble$ write$ newline$ }
 1076   if$
 1077   "\begin{thebibliography}{}" write$ newline$		% no labels in apalike
 1078 }
 1079 
 1080 EXECUTE {begin.bib}
 1081 
 1082 EXECUTE {init.state.consts}
 1083 
 1084 ITERATE {call.type$}
 1085 
 1086 FUNCTION {end.bib}
 1087 { newline$
 1088   "\end{thebibliography}" write$ newline$
 1089 }
 1090 
 1091 EXECUTE {end.bib}