1% BibTeX standard bibliography style `plain'
2   % Version 0.99b (8-Dec-10 release) for BibTeX versions 0.99a or later.
3   % Copyright (C) 1984, 1985, 1988, 2010 Howard Trickey and Oren Patashnik.
4   % Unlimited copying and redistribution of this file are permitted as long as
5   % it is unmodified.  Modifications (and redistribution of modified versions)
6   % are also permitted, but only if the resulting file is renamed to something
7   % besides btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
8   % This restriction helps ensure that all standard styles are identical.
9   % The file btxbst.doc has the documentation for this style.
10
11ENTRY
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
38INTEGERS { output.state before.all mid.sentence after.sentence after.block }
39
40FUNCTION {init.state.consts}
41{ #0 'before.all :=
42  #1 'mid.sentence :=
43  #2 'after.sentence :=
44  #3 'after.block :=
45}
46
47STRINGS { s t }
48
49FUNCTION {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
70FUNCTION {output}
71{ duplicate$ empty$
72    'pop$
73    'output.nonnull
74  if$
75}
76
77FUNCTION {output.check}
78{ 't :=
79  duplicate$ empty$
80    { pop$ "empty " t * " in " * cite$ * warning$ }
81    'output.nonnull
82  if$
83}
84
85FUNCTION {output.bibitem}
86{ newline$
87  "\bibitem{" write$
88  cite$ write$
89  "}" write$
90  newline$
91  ""
92  before.all 'output.state :=
93}
94
95FUNCTION {fin.entry}
96{ add.period$
97  write$
98  newline$
99}
100
101FUNCTION {new.block}
102{ output.state before.all =
103    'skip$
104    { after.block 'output.state := }
105  if$
106}
107
108FUNCTION {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
119FUNCTION {not}
120{   { #0 }
121    { #1 }
122  if$
123}
124
125FUNCTION {and}
126{   'skip$
127    { pop$ #0 }
128  if$
129}
130
131FUNCTION {or}
132{   { pop$ #1 }
133    'skip$
134  if$
135}
136
137FUNCTION {new.block.checka}
138{ empty$
139    'skip$
140    'new.block
141  if$
142}
143
144FUNCTION {new.block.checkb}
145{ empty$
146  swap$ empty$
147  and
148    'skip$
149    'new.block
150  if$
151}
152
153FUNCTION {new.sentence.checka}
154{ empty$
155    'skip$
156    'new.sentence
157  if$
158}
159
160FUNCTION {new.sentence.checkb}
161{ empty$
162  swap$ empty$
163  and
164    'skip$
165    'new.sentence
166  if$
167}
168
169FUNCTION {field.or.null}
170{ duplicate$ empty$
171    { pop$ "" }
172    'skip$
173  if$
174}
175
176FUNCTION {emphasize}
177{ duplicate$ empty$
178    { pop$ "" }
179    { "{\em " swap$ * "}" * }
180  if$
181}
182
183INTEGERS { nameptr namesleft numnames }
184
185FUNCTION {format.names}
186{ 's :=
187  #1 'nameptr :=
188  s num.names$ 'numnames :=
189  numnames 'namesleft :=
190    { namesleft #0 > }
191    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
192      nameptr #1 >
193        { namesleft #1 >
194            { ", " * t * }
195            { numnames #2 >
196                { "," * }
197                'skip$
198              if$
199              t "others" =
200                { " et~al." * }
201                { " and " * t * }
202              if$
203            }
204          if$
205        }
206        't
207      if$
208      nameptr #1 + 'nameptr :=
209      namesleft #1 - 'namesleft :=
210    }
211  while$
212}
213
214FUNCTION {format.authors}
215{ author empty$
216    { "" }
217    { author format.names }
218  if$
219}
220
221FUNCTION {format.editors}
222{ editor empty$
223    { "" }
224    { editor format.names
225      editor num.names$ #1 >
226        { ", editors" * }
227        { ", editor" * }
228      if$
229    }
230  if$
231}
232
233FUNCTION {format.title}
234{ title empty$
235    { "" }
236    { title "t" change.case$ }
237  if$
238}
239
240FUNCTION {n.dashify}
241{ 't :=
242  ""
243    { t empty$ not }
244    { t #1 #1 substring$ "-" =
245        { t #1 #2 substring$ "--" = not
246            { "--" *
247              t #2 global.max$ substring$ 't :=
248            }
249            {   { t #1 #1 substring$ "-" = }
250                { "-" *
251                  t #2 global.max$ substring$ 't :=
252                }
253              while$
254            }
255          if$
256        }
257        { t #1 #1 substring$ *
258          t #2 global.max$ substring$ 't :=
259        }
260      if$
261    }
262  while$
263}
264
265FUNCTION {format.date}
266{ year empty$
267    { month empty$
268        { "" }
269        { "there's a month but no year in " cite$ * warning$
270          month
271        }
272      if$
273    }
274    { month empty$
275        'year
276        { month " " * year * }
277      if$
278    }
279  if$
280}
281
282FUNCTION {format.btitle}
283{ title emphasize
284}
285
286FUNCTION {tie.or.space.connect}
287{ duplicate$ text.length$ #3 <
288    { "~" }
289    { " " }
290  if$
291  swap$ * *
292}
293
294FUNCTION {either.or.check}
295{ empty$
296    'pop$
297    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
298  if$
299}
300
301FUNCTION {format.bvolume}
302{ volume empty$
303    { "" }
304    { "volume" volume tie.or.space.connect
305      series empty$
306        'skip$
307        { " of " * series emphasize * }
308      if$
309      "volume and number" number either.or.check
310    }
311  if$
312}
313
314FUNCTION {format.number.series}
315{ volume empty$
316    { number empty$
317        { series field.or.null }
318        { output.state mid.sentence =
319            { "number" }
320            { "Number" }
321          if$
322          number tie.or.space.connect
323          series empty$
324            { "there's a number but no series in " cite$ * warning$ }
325            { " in " * series * }
326          if$
327        }
328      if$
329    }
330    { "" }
331  if$
332}
333
334FUNCTION {format.edition}
335{ edition empty$
336    { "" }
337    { output.state mid.sentence =
338        { edition "l" change.case$ " edition" * }
339        { edition "t" change.case$ " edition" * }
340      if$
341    }
342  if$
343}
344
345INTEGERS { multiresult }
346
347FUNCTION {multi.page.check}
348{ 't :=
349  #0 'multiresult :=
350    { multiresult not
351      t empty$ not
352      and
353    }
354    { t #1 #1 substring$
355      duplicate$ "-" =
356      swap$ duplicate$ "," =
357      swap$ "+" =
358      or or
359        { #1 'multiresult := }
360        { t #2 global.max$ substring$ 't := }
361      if$
362    }
363  while$
364  multiresult
365}
366
367FUNCTION {format.pages}
368{ pages empty$
369    { "" }
370    { pages multi.page.check
371        { "pages" pages n.dashify tie.or.space.connect }
372        { "page" pages tie.or.space.connect }
373      if$
374    }
375  if$
376}
377
378FUNCTION {format.vol.num.pages}
379{ volume field.or.null
380  number empty$
381    'skip$
382    { "(" number * ")" * *
383      volume empty$
384        { "there's a number but no volume in " cite$ * warning$ }
385        'skip$
386      if$
387    }
388  if$
389  pages empty$
390    'skip$
391    { duplicate$ empty$
392        { pop$ format.pages }
393        { ":" * pages n.dashify * }
394      if$
395    }
396  if$
397}
398
399FUNCTION {format.chapter.pages}
400{ chapter empty$
401    'format.pages
402    { type empty$
403        { "chapter" }
404        { type "l" change.case$ }
405      if$
406      chapter tie.or.space.connect
407      pages empty$
408        'skip$
409        { ", " * format.pages * }
410      if$
411    }
412  if$
413}
414
415FUNCTION {format.in.ed.booktitle}
416{ booktitle empty$
417    { "" }
418    { editor empty$
419        { "In " booktitle emphasize * }
420        { "In " format.editors * ", " * booktitle emphasize * }
421      if$
422    }
423  if$
424}
425
426FUNCTION {empty.misc.check}
427{ author empty$ title empty$ howpublished empty$
428  month empty$ year empty$ note empty$
429  and and and and and
430  key empty$ not and
431    { "all relevant fields are empty in " cite$ * warning$ }
432    'skip$
433  if$
434}
435
436FUNCTION {format.thesis.type}
437{ type empty$
438    'skip$
439    { pop$
440      type "t" change.case$
441    }
442  if$
443}
444
445FUNCTION {format.tr.number}
446{ type empty$
447    { "Technical Report" }
448    'type
449  if$
450  number empty$
451    { "t" change.case$ }
452    { number tie.or.space.connect }
453  if$
454}
455
456FUNCTION {format.article.crossref}
457{ key empty$
458    { journal empty$
459        { "need key or journal for " cite$ * " to crossref " * crossref *
460          warning$
461          ""
462        }
463        { "In {\em " journal * "\/}" * }
464      if$
465    }
466    { "In " key * }
467  if$
468  " \cite{" * crossref * "}" *
469}
470
471FUNCTION {format.crossref.editor}
472{ editor #1 "{vv~}{ll}" format.name$
473  editor num.names$ duplicate$
474  #2 >
475    { pop$ " et~al." * }
476    { #2 <
477        'skip$
478        { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
479            { " et~al." * }
480            { " and " * editor #2 "{vv~}{ll}" format.name$ * }
481          if$
482        }
483      if$
484    }
485  if$
486}
487
488FUNCTION {format.book.crossref}
489{ volume empty$
490    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
491      "In "
492    }
493    { "Volume" volume tie.or.space.connect
494      " of " *
495    }
496  if$
497  editor empty$
498  editor field.or.null author field.or.null =
499  or
500    { key empty$
501        { series empty$
502            { "need editor, key, or series for " cite$ * " to crossref " *
503              crossref * warning$
504              "" *
505            }
506            { "{\em " * series * "\/}" * }
507          if$
508        }
509        { key * }
510      if$
511    }
512    { format.crossref.editor * }
513  if$
514  " \cite{" * crossref * "}" *
515}
516
517FUNCTION {format.incoll.inproc.crossref}
518{ editor empty$
519  editor field.or.null author field.or.null =
520  or
521    { key empty$
522        { booktitle empty$
523            { "need editor, key, or booktitle for " cite$ * " to crossref " *
524              crossref * warning$
525              ""
526            }
527            { "In {\em " booktitle * "\/}" * }
528          if$
529        }
530        { "In " key * }
531      if$
532    }
533    { "In " format.crossref.editor * }
534  if$
535  " \cite{" * crossref * "}" *
536}
537
538FUNCTION {article}
539{ output.bibitem
540  format.authors "author" output.check
541  new.block
542  format.title "title" output.check
543  new.block
544  crossref missing$
545    { journal emphasize "journal" output.check
546      format.vol.num.pages output
547      format.date "year" output.check
548    }
549    { format.article.crossref output.nonnull
550      format.pages output
551    }
552  if$
553  new.block
554  note output
555  fin.entry
556}
557
558FUNCTION {book}
559{ output.bibitem
560  author empty$
561    { format.editors "author and editor" output.check }
562    { format.authors output.nonnull
563      crossref missing$
564        { "author and editor" editor either.or.check }
565        'skip$
566      if$
567    }
568  if$
569  new.block
570  format.btitle "title" output.check
571  crossref missing$
572    { format.bvolume output
573      new.block
574      format.number.series output
575      new.sentence
576      publisher "publisher" output.check
577      address output
578    }
579    { new.block
580      format.book.crossref output.nonnull
581    }
582  if$
583  format.edition output
584  format.date "year" output.check
585  new.block
586  note output
587  fin.entry
588}
589
590FUNCTION {booklet}
591{ output.bibitem
592  format.authors output
593  new.block
594  format.title "title" output.check
595  howpublished address new.block.checkb
596  howpublished output
597  address output
598  format.date output
599  new.block
600  note output
601  fin.entry
602}
603
604FUNCTION {inbook}
605{ output.bibitem
606  author empty$
607    { format.editors "author and editor" output.check }
608    { format.authors output.nonnull
609      crossref missing$
610        { "author and editor" editor either.or.check }
611        'skip$
612      if$
613    }
614  if$
615  new.block
616  format.btitle "title" output.check
617  crossref missing$
618    { format.bvolume output
619      format.chapter.pages "chapter and pages" output.check
620      new.block
621      format.number.series output
622      new.sentence
623      publisher "publisher" output.check
624      address output
625    }
626    { format.chapter.pages "chapter and pages" output.check
627      new.block
628      format.book.crossref output.nonnull
629    }
630  if$
631  format.edition output
632  format.date "year" output.check
633  new.block
634  note output
635  fin.entry
636}
637
638FUNCTION {incollection}
639{ output.bibitem
640  format.authors "author" output.check
641  new.block
642  format.title "title" output.check
643  new.block
644  crossref missing$
645    { format.in.ed.booktitle "booktitle" output.check
646      format.bvolume output
647      format.number.series output
648      format.chapter.pages output
649      new.sentence
650      publisher "publisher" output.check
651      address output
652      format.edition output
653      format.date "year" output.check
654    }
655    { format.incoll.inproc.crossref output.nonnull
656      format.chapter.pages output
657    }
658  if$
659  new.block
660  note output
661  fin.entry
662}
663
664FUNCTION {inproceedings}
665{ output.bibitem
666  format.authors "author" output.check
667  new.block
668  format.title "title" output.check
669  new.block
670  crossref missing$
671    { format.in.ed.booktitle "booktitle" output.check
672      format.bvolume output
673      format.number.series output
674      format.pages output
675      address empty$
676        { organization publisher new.sentence.checkb
677          organization output
678          publisher output
679          format.date "year" output.check
680        }
681        { address output.nonnull
682          format.date "year" output.check
683          new.sentence
684          organization output
685          publisher output
686        }
687      if$
688    }
689    { format.incoll.inproc.crossref output.nonnull
690      format.pages output
691    }
692  if$
693  new.block
694  note output
695  fin.entry
696}
697
698FUNCTION {conference} { inproceedings }
699
700FUNCTION {manual}
701{ output.bibitem
702  author empty$
703    { organization empty$
704        'skip$
705        { organization output.nonnull
706          address output
707        }
708      if$
709    }
710    { format.authors output.nonnull }
711  if$
712  new.block
713  format.btitle "title" output.check
714  author empty$
715    { organization empty$
716        { address new.block.checka
717          address output
718        }
719        'skip$
720      if$
721    }
722    { organization address new.block.checkb
723      organization output
724      address output
725    }
726  if$
727  format.edition output
728  format.date output
729  new.block
730  note output
731  fin.entry
732}
733
734FUNCTION {mastersthesis}
735{ output.bibitem
736  format.authors "author" output.check
737  new.block
738  format.title "title" output.check
739  new.block
740  "Master's thesis" format.thesis.type output.nonnull
741  school "school" output.check
742  address output
743  format.date "year" output.check
744  new.block
745  note output
746  fin.entry
747}
748
749FUNCTION {misc}
750{ output.bibitem
751  format.authors output
752  title howpublished new.block.checkb
753  format.title output
754  howpublished new.block.checka
755  howpublished output
756  format.date output
757  new.block
758  note output
759  fin.entry
760  empty.misc.check
761}
762
763FUNCTION {phdthesis}
764{ output.bibitem
765  format.authors "author" output.check
766  new.block
767  format.btitle "title" output.check
768  new.block
769  "PhD thesis" format.thesis.type output.nonnull
770  school "school" output.check
771  address output
772  format.date "year" output.check
773  new.block
774  note output
775  fin.entry
776}
777
778FUNCTION {proceedings}
779{ output.bibitem
780  editor empty$
781    { organization output }
782    { format.editors output.nonnull }
783  if$
784  new.block
785  format.btitle "title" output.check
786  format.bvolume output
787  format.number.series output
788  address empty$
789    { editor empty$
790        { publisher new.sentence.checka }
791        { organization publisher new.sentence.checkb
792          organization output
793        }
794      if$
795      publisher output
796      format.date "year" output.check
797    }
798    { address output.nonnull
799      format.date "year" output.check
800      new.sentence
801      editor empty$
802        'skip$
803        { organization output }
804      if$
805      publisher output
806    }
807  if$
808  new.block
809  note output
810  fin.entry
811}
812
813FUNCTION {techreport}
814{ output.bibitem
815  format.authors "author" output.check
816  new.block
817  format.title "title" output.check
818  new.block
819  format.tr.number output.nonnull
820  institution "institution" output.check
821  address output
822  format.date "year" output.check
823  new.block
824  note output
825  fin.entry
826}
827
828FUNCTION {unpublished}
829{ output.bibitem
830  format.authors "author" output.check
831  new.block
832  format.title "title" output.check
833  new.block
834  note "note" output.check
835  format.date output
836  fin.entry
837}
838
839FUNCTION {default.type} { misc }
840
841MACRO {jan} {"January"}
842
843MACRO {feb} {"February"}
844
845MACRO {mar} {"March"}
846
847MACRO {apr} {"April"}
848
849MACRO {may} {"May"}
850
851MACRO {jun} {"June"}
852
853MACRO {jul} {"July"}
854
855MACRO {aug} {"August"}
856
857MACRO {sep} {"September"}
858
859MACRO {oct} {"October"}
860
861MACRO {nov} {"November"}
862
863MACRO {dec} {"December"}
864
865MACRO {acmcs} {"ACM Computing Surveys"}
866
867MACRO {acta} {"Acta Informatica"}
868
869MACRO {cacm} {"Communications of the ACM"}
870
871MACRO {ibmjrd} {"IBM Journal of Research and Development"}
872
873MACRO {ibmsj} {"IBM Systems Journal"}
874
875MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
876
877MACRO {ieeetc} {"IEEE Transactions on Computers"}
878
879MACRO {ieeetcad}
880 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
881
882MACRO {ipl} {"Information Processing Letters"}
883
884MACRO {jacm} {"Journal of the ACM"}
885
886MACRO {jcss} {"Journal of Computer and System Sciences"}
887
888MACRO {scp} {"Science of Computer Programming"}
889
890MACRO {sicomp} {"SIAM Journal on Computing"}
891
892MACRO {tocs} {"ACM Transactions on Computer Systems"}
893
894MACRO {tods} {"ACM Transactions on Database Systems"}
895
896MACRO {tog} {"ACM Transactions on Graphics"}
897
898MACRO {toms} {"ACM Transactions on Mathematical Software"}
899
900MACRO {toois} {"ACM Transactions on Office Information Systems"}
901
902MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
903
904MACRO {tcs} {"Theoretical Computer Science"}
905
906READ
907
908FUNCTION {sortify}
909{ purify$
910  "l" change.case$
911}
912
913INTEGERS { len }
914
915FUNCTION {chop.word}
916{ 's :=
917  'len :=
918  s #1 len substring$ =
919    { s len #1 + global.max$ substring$ }
920    's
921  if$
922}
923
924FUNCTION {sort.format.names}
925{ 's :=
926  #1 'nameptr :=
927  ""
928  s num.names$ 'numnames :=
929  numnames 'namesleft :=
930    { namesleft #0 > }
931    { nameptr #1 >
932        { "   " * }
933        'skip$
934      if$
935      s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
936      nameptr numnames = t "others" = and
937        { "et al" * }
938        { t sortify * }
939      if$
940      nameptr #1 + 'nameptr :=
941      namesleft #1 - 'namesleft :=
942    }
943  while$
944}
945
946FUNCTION {sort.format.title}
947{ 't :=
948  "A " #2
949    "An " #3
950      "The " #4 t chop.word
951    chop.word
952  chop.word
953  sortify
954  #1 global.max$ substring$
955}
956
957FUNCTION {author.sort}
958{ author empty$
959    { key empty$
960        { "to sort, need author or key in " cite$ * warning$
961          ""
962        }
963        { key sortify }
964      if$
965    }
966    { author sort.format.names }
967  if$
968}
969
970FUNCTION {author.editor.sort}
971{ author empty$
972    { editor empty$
973        { key empty$
974            { "to sort, need author, editor, or key in " cite$ * warning$
975              ""
976            }
977            { key sortify }
978          if$
979        }
980        { editor sort.format.names }
981      if$
982    }
983    { author sort.format.names }
984  if$
985}
986
987FUNCTION {author.organization.sort}
988{ author empty$
989    { organization empty$
990        { key empty$
991            { "to sort, need author, organization, or key in " cite$ * warning$
992              ""
993            }
994            { key sortify }
995          if$
996        }
997        { "The " #4 organization chop.word sortify }
998      if$
999    }
1000    { author sort.format.names }
1001  if$
1002}
1003
1004FUNCTION {editor.organization.sort}
1005{ editor empty$
1006    { organization empty$
1007        { key empty$
1008            { "to sort, need editor, organization, or key in " cite$ * warning$
1009              ""
1010            }
1011            { key sortify }
1012          if$
1013        }
1014        { "The " #4 organization chop.word sortify }
1015      if$
1016    }
1017    { editor sort.format.names }
1018  if$
1019}
1020
1021FUNCTION {presort}
1022{ type$ "book" =
1023  type$ "inbook" =
1024  or
1025    'author.editor.sort
1026    { type$ "proceedings" =
1027        'editor.organization.sort
1028        { type$ "manual" =
1029            'author.organization.sort
1030            'author.sort
1031          if$
1032        }
1033      if$
1034    }
1035  if$
1036  "    "
1037  *
1038  year field.or.null sortify
1039  *
1040  "    "
1041  *
1042  title field.or.null
1043  sort.format.title
1044  *
1045  #1 entry.max$ substring$
1046  'sort.key$ :=
1047}
1048
1049ITERATE {presort}
1050
1051SORT
1052
1053STRINGS { longest.label }
1054
1055INTEGERS { number.label longest.label.width }
1056
1057FUNCTION {initialize.longest.label}
1058{ "" 'longest.label :=
1059  #1 'number.label :=
1060  #0 'longest.label.width :=
1061}
1062
1063FUNCTION {longest.label.pass}
1064{ number.label int.to.str$ 'label :=
1065  number.label #1 + 'number.label :=
1066  label width$ longest.label.width >
1067    { label 'longest.label :=
1068      label width$ 'longest.label.width :=
1069    }
1070    'skip$
1071  if$
1072}
1073
1074EXECUTE {initialize.longest.label}
1075
1076ITERATE {longest.label.pass}
1077
1078FUNCTION {begin.bib}
1079{ preamble$ empty$
1080    'skip$
1081    { preamble$ write$ newline$ }
1082  if$
1083  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
1084}
1085
1086EXECUTE {begin.bib}
1087
1088EXECUTE {init.state.consts}
1089
1090ITERATE {call.type$}
1091
1092FUNCTION {end.bib}
1093{ newline$
1094  "\end{thebibliography}" write$ newline$
1095}
1096
1097EXECUTE {end.bib}
1098