~ubuntu-branches/ubuntu/jaunty/luatex/jaunty

« back to all changes in this revision

Viewing changes to src/texk/web2c/tests/apalike.bst

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2007-09-24 12:56:11 UTC
  • Revision ID: james.westby@ubuntu.com-20070924125611-a8ge689azbptxvla
Tags: upstream-0.11.2
ImportĀ upstreamĀ versionĀ 0.11.2

Show diffs side-by-side

added added

removed removed

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