Commit before breaking everything
[matches/honours.git] / thesis / styles / uwa.bst
1 %%% ====================================================================
2 %%%  @BibTeX-style-file{
3 %%%     filename = "uwa.bst",
4 %%%     version  = "1.1",
5 %%%     date     = "1998/07/15",
6 %%%     time     = "14:37:33 EST",
7 %%%     checksum = "38973 1474 4577 33560" 
8 %%%     author   = "Greg Gamble",
9 %%%     address  = "Centre for Discrete Mathematics & Computing,
10 %%%                 Department of Computer Science
11 %%%                       & Electrical Engineering,
12 %%%                 The University of Queensland,
13 %%%                 Queensland 4072,
14 %%%                 Australia",
15 %%%     telephone = "+61 7 336 51195",
16 %%%     FAX       = "+61 7 336 51999",
17 %%%     copyright = "Copyright (C) 1998 Greg Gamble,
18 %%%                  all rights reserved.  Copying of this file is
19 %%%                  authorised only if either:
20 %%%                   (1) you make absolutely no changes to your copy,
21 %%%                       including name; OR
22 %%%                   (2) if you do make changes, you first rename it
23 %%%                       to some other name.",
24 %%%     email     = "[email protected] (Internet)",
25 %%%     keywords  = "bibtex, bibliography, latex,",
26 %%%     supported = "yes",
27 %%%     abstract  = "BibTeX bibliography style `uwa' for BibTeX
28 %%%                  versions 0.99a or later and LaTeX version 2e,
29 %%%                  a significantly modified version of the American 
30 %%%                  Mathematical Society's `amsplain', incorporating
31 %%%                  many features of `abbrv'. Versions 1.0 and 1.0a
32 %%%                  of the style were written (and modified) while
33 %%%                  the author was at the University of Western
34 %%%                  Australia - hence the style name `uwa'. Note,
35 %%%                  that the style `uwab' provides an identical
36 %%%                  style except that it does not use \bysame
37 %%%                  (a horizontal line in place of the author(s)
38 %%%                  of a bibitem, indicating the author(s) are the
39 %%%                  same as the previous bibitem).
40 %%%                    Briefly the style produces bibitems that are 
41 %%%                  either one or two (if there is both a note and 
42 %%%                  other information) sentences. Functions are provided 
43 %%%                  to emphasize, embolden, slantify and parenthesize. 
44 %%%                    The general philosophy is titles (including 
45 %%%                  booktitles and series) are either set in quotes 
46 %%%                  (article type titles) or emphasized; prepositions 
47 %%%                  like `in' are included to provide breaks between 
48 %%%                  fields of similar typeface and set either in upshape 
49 %%%                  or slanted to set it off from adjacent text; 
50 %%%                    * volume is set in bold unless it would clash 
51 %%%                      with a cross-reference (where the style is: 
52 %%%                      `vol. ... of ...'); 
53 %%%                    * number is treated as if it is a volume unless 
54 %%%                      both exist (in which case it is set as:
55 %%%                      `,no. ...' following the volume); 
56 %%%                    * organization, address, edition, year are set 
57 %%%                      together separated by commas in parentheses; 
58 %%%                      and in many places, e.g. before a left 
59 %%%                      parenthesis and before volume, the comma that
60 %%%                      is set by most styles is suppressed (the function
61 %%%                      no.comma is used in most places this has been done
62 %%%                      - a comma can be inserted, if this is desired, 
63 %%%                      usually by simply removing the `no.comma'
64 %%%                      - please ... if you modify the style in this
65 %%%                      or any other way, heed the copyright warning
66 %%%                      by changing the name of the file); 
67 %%%                    * name(s) and month(s) are set as in the `abbrv' style.
68 %%%                  Peculiar to the style is the use of \bysame in place
69 %%%                  of the authors names for succeeding bibitems by the
70 %%%                  same authors. If this feature is not desirable (i.e.
71 %%%                  explicit author lists for all papers is required),
72 %%%                  use the `uwab' style instead.
73 %%%                    The `ize' endings for many function names have been 
74 %%%                  retained ... it would be too confusing to change such 
75 %%%                  American spelling to English (even though, personally 
76 %%%                  I prefer the English usage: `ise').
77 %%%                    Changes:
78 %%%                  - Version 1.0 [1996/02/26]: first release of `uwa.bst'
79 %%%                  - Version 1.0a [1996/05/24]: added field: 
80 %%%                    * editiontype, so that technical documentation 
81 %%%                      could use the MANUAL type and have `Version No.'
82 %%%                      instead of `No. ed.'
83 %%%                  - Version 1.1 [1998/07/15]: added fields: 
84 %%%                    * url. It is typeset before the note field (if 
85 %%%                      there is one) using LaTeX's \verb with | delimiters 
86 %%%                      (by default). For the rare situation, where a | 
87 %%%                      actually appears in the URL, the delimiter may be 
88 %%%                      changed by setting the field verbdelim;
89 %%%                    * verbdelim (see description for url field).
90 %%%                    Examples of usage (including some that demonstrate
91 %%%                  `editiontype', `url' and `verbdelim') are provided in
92 %%%                  `uwaxampl.bib'",
93 %%%     docstring = "The checksum field above contains a CRC-16
94 %%%                  checksum as the first value, followed by the
95 %%%                  equivalent of the standard UNIX wc (word
96 %%%                  count) utility output of lines, words, and
97 %%%                  characters.  This is produced by Robert
98 %%%                  Solovay's checksum utility.",
99 %%%  }
100 %%% ====================================================================
101
102 % See the file btxbst.doc for extra documentation other than
103 % what is included here.  And see btxhak.tex for a description
104 % of the BibTeX language and how to use it.
105
106 % This defines the types of fields that can occur in a database entry
107 % for this particular bibliography style.  Except for `language',
108 % this is the standard list from plain.bst.
109
110 %% Types of entries currently allowed in a BibTeX file:
111 %%
112 %% ARTICLE -- An article from a journal or magazine.
113 %%
114 %% BOOK -- A book with an explicit publisher.
115 %%
116 %% BOOKLET -- A work that is printed and bound,
117 %% but without a named publisher or sponsoring institution.
118 %%
119 %% CONFERENCE -- The same as INPROCEEDINGS,
120 %% included for Scribe compatibility.
121 %%
122 %% INBOOK -- A part of a book,
123 %% which may be a chapter (or section or whatever) and/or a range of pages.
124 %%
125 %% INCOLLECTION -- A part of a book having its own title.
126 %%
127 %% INPROCEEDINGS -- An article in a conference proceedings.
128 %%
129 %% MANUAL -- Technical documentation.
130 %%
131 %% MASTERSTHESIS -- A Master's thesis.
132 %%
133 %% MISC -- Use this type when nothing else fits.
134 %%
135 %% PHDTHESIS -- A PhD thesis.
136 %%
137 %% PROCEEDINGS -- The proceedings of a conference.
138 %%
139 %% TECHREPORT -- A report published by a school or other institution,
140 %% usually numbered within a series.
141 %%
142 %% UNPUBLISHED -- A document having an author and title, but not formally
143 %% published.
144
145 ENTRY
146   { address
147     author
148     booktitle
149     chapter
150     edition
151     editiontype
152     editor
153     howpublished
154     institution
155     journal
156     key
157     language
158     month
159     note
160     number
161     organization
162     pages
163     publisher
164     school
165     series
166     title
167     type
168     url
169     verbdelim
170     volume
171     year
172   }
173   {}
174   { label extra.label }
175
176 INTEGERS { output.state before.all mid.sentence after.sentence after.block 
177            mid.sentence.nocomma
178          }
179
180 FUNCTION {init.state.consts}
181 { #0 'before.all :=
182   #1 'mid.sentence :=
183   #2 'after.sentence :=
184   #3 'after.block :=
185   #4 'mid.sentence.nocomma :=
186 }
187
188 % Scratch variables:
189
190 STRINGS { s t }
191
192 % Utility functions
193
194 FUNCTION {shows}
195 { duplicate$ "::::  `" swap$ * "'" * top$
196 }
197
198 FUNCTION {showstack}
199 {"STACK====================================================================="
200 top$
201 stack$
202 "ENDSTACK=================================================================="
203 top$
204 }
205
206 FUNCTION {not}
207 {   { #0 }
208     { #1 }
209   if$
210 }
211
212 FUNCTION {and}
213 {   'skip$
214     { pop$ #0 }
215   if$
216 }
217
218 FUNCTION {or}
219 {   { pop$ #1 }
220     'skip$
221   if$
222 }
223
224 % Standard warning message for a missing or empty field. For the user
225 % we call any such field `missing' without respect to the distinction
226 % made by BibTeX between missing and empty.
227
228 FUNCTION {missing.warning}
229 { "missing " swap$ * " in " * cite$ * warning$ }
230
231 FUNCTION {field.or.null}
232 { duplicate$ empty$
233     { pop$ "" }
234     'skip$
235   if$
236 }
237
238 FUNCTION {field.or.null.check}
239 { 't :=
240   duplicate$ empty$
241     { pop$ "" t missing.warning }
242     'skip$
243   if$
244 }
245
246 FUNCTION {emphasize}
247 { duplicate$ empty$
248     { pop$ "" }
249     { "\emph{" swap$ * "}" * }
250   if$
251 }
252
253 FUNCTION {embolden}
254 { duplicate$ empty$
255     { pop$ "" }
256     { "\textbf{" swap$ * "}" * }
257   if$
258 }
259
260 FUNCTION {slantify}
261 { duplicate$ empty$
262     { pop$ "" }
263     { "\textsl{" swap$ * "}" * }
264   if$
265 }
266
267 FUNCTION {parenthesize}
268 { duplicate$ empty$
269     { pop$ "" }
270     { "(" swap$ * ")" * }
271   if$
272 }
273
274 % n.dashify is used to make sure page ranges get the TeX code
275 % (two hyphens) for en-dashes.
276
277 FUNCTION {n.dashify}
278 { 't :=
279   ""
280     { t empty$ not }
281     { t #1 #1 substring$ "-" =
282         { t #1 #2 substring$ "--" = not
283             { "--" *
284               t #2 global.max$ substring$ 't :=
285             }
286             {   { t #1 #1 substring$ "-" = }
287                 { "-" *
288                   t #2 global.max$ substring$ 't :=
289                 }
290               while$
291             }
292           if$
293         }
294         { t #1 #1 substring$ *
295           t #2 global.max$ substring$ 't :=
296         }
297       if$
298     }
299   while$
300 }
301
302 % tie.or.space.connect connects two items with a ~ if the
303 % second item is less than 3 letters long, otherwise it just puts an
304 % ordinary space.
305
306 FUNCTION {tie.or.space.connect}
307 { duplicate$ text.length$ #3 <
308     { "~" }
309     { " " }
310   if$
311   swap$ * *
312 }
313
314 FUNCTION {add.space.if.necessary}
315 { duplicate$ "" =
316     'skip$
317     { " " * }
318   if$
319 }
320
321 % either.or.check gives a warning if two mutually exclusive fields
322 % were used in the database.
323
324 FUNCTION {either.or.check}
325 { empty$
326     'pop$
327     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
328   if$
329 }
330
331 % output.nonnull is called by output.
332
333 FUNCTION {output.nonnull}
334 % remove the top item from the stack because it's in the way.
335 { 's :=
336   output.state mid.sentence.nocomma =
337 % If we're in mid-sentence, but no comma is required append a space to the new
338 % top item and write it ... and then restore the normal mid-sentence state
339     { " " * write$
340       mid.sentence 'output.state :=
341     }
342     { output.state mid.sentence =
343 % If we're in mid-sentence, add a comma to the new top item and write it
344         { ", " * write$ }
345         { output.state after.block =
346 % If we are finishing a block add a period and take this opportunity to
347 % start a new line and thus avoid extra long lines in the .bbl file
348             { add.period$ write$
349               newline$
350               "\newblock " write$
351             }
352 % Otherwise, if we're at the beginning of a bibitem,
353             { output.state before.all =
354 % just write out the top item from the stack;
355                 'write$
356 % and the last alternative is that we're at the end of the current
357 % bibitem, so we add a period to the top stack item and write it out.
358                 { add.period$ " " * write$ }
359               if$
360               mid.sentence 'output.state :=
361             }
362           if$
363         }
364       if$
365     }
366   if$
367 % Put the top item back on the stack that we removed earlier.
368   s
369 }
370
371 % Output checks to see if the stack top is empty; if not, it
372 % calls output.nonnull to write it out.
373
374 FUNCTION {output}
375 { duplicate$ empty$
376     'pop$
377     'output.nonnull
378   if$
379 }
380
381 % Output.check is like output except that it gives a warning on-screen
382 % if the given field in the database entry is empty.  t is the field
383 % name.
384
385 FUNCTION {output.check}
386 { 't :=
387   duplicate$ empty$
388     { pop$ t missing.warning }
389     'output.nonnull
390   if$
391 }
392
393 FUNCTION {output.bibitem}
394 { newline$
395   "\bibitem{" write$
396   cite$ write$
397   "}" write$
398   newline$
399 % This empty string is the first thing that will be written
400 % the next time write$ is called.  Done this way because each
401 % item is saved on the stack until we find out what punctuation
402 % should be added after it.  Therefore we need an empty first item.
403   ""
404   before.all 'output.state :=
405 }
406
407 FUNCTION {fin.entry}
408 { add.period$
409   write$
410   newline$
411 }
412
413 % The three append functions are like the corresponding output 
414 % functions ...
415 % append.nonnull concatenates the top 2 elements on the stack 
416 % putting the string append.conjuction in between if both are
417 % non-empty ... the result is left on top of the stack
418
419 STRINGS { append.conjunction }
420
421 FUNCTION {append.nonnull}
422 % remove the top item from the stack because it's in the way.
423 { 's :=
424    duplicate$ empty$
425      { pop$ s }
426      { append.conjunction * s * }
427    if$
428 }
429
430 % append does exactly what append.nonnull was described to do ...
431 % if the top element is non-empty it calls append.nonnull to 
432 % concatenate the top 2 stack elements ... otherwise it just
433 % throws away the top element.
434
435 FUNCTION {append}
436 { duplicate$ empty$
437     'pop$
438     'append.nonnull
439   if$
440 }
441
442 % append.check is like append except that it gives a warning on-screen
443 % if the given field in the database entry is empty.  t is the field
444 % name ... analogous to output.check.
445
446 FUNCTION {append.check}
447 { 't :=
448   duplicate$ empty$
449     { pop$ t missing.warning }
450     'append.nonnull
451   if$
452 }
453
454 FUNCTION {new.block}
455 { output.state before.all =
456     'skip$
457     { after.block 'output.state := }
458   if$
459 }
460
461 FUNCTION {new.sentence}
462 { output.state after.block =
463     'skip$
464     { output.state before.all =
465         'skip$
466         { after.sentence 'output.state := }
467       if$
468     }
469   if$
470 }
471
472 FUNCTION {new.block.checka}
473 { empty$
474     'skip$
475     'new.block
476   if$
477 }
478
479 FUNCTION {new.block.checkb}
480 { empty$
481   swap$ empty$
482   and
483     'skip$
484     'new.block
485   if$
486 }
487
488 FUNCTION {new.sentence.checka}
489 { empty$
490     'skip$
491     'new.sentence
492   if$
493 }
494
495 FUNCTION {new.sentence.checkb}
496 { empty$
497   swap$ empty$
498   and
499     'skip$
500     'new.sentence
501   if$
502 }
503
504 FUNCTION {no.comma}
505 { duplicate$ empty$
506     'skip$
507     { output.state before.all =
508         'skip$
509         { mid.sentence.nocomma 'output.state := }
510       if$
511     }
512   if$
513 }
514
515 INTEGERS { nameptr namesleft numnames }
516
517 % The extra section to write out a language field was added
518 % for AMSPLAIN.BST.  Not present in plain.bst.
519
520 FUNCTION {format.language}
521 { language no.comma parenthesize
522 }
523
524 FUNCTION {format.note}
525 { note empty$
526     { "" }
527     { note new.block }
528   if$
529 }
530
531 % The url field is formatted in a similar fashion to the note field
532 % but appears before it. We use LaTeX's \verb with | delimiters
533 % by default, i.e. \verb|<URL>| is how it appears in the output.
534 % For the rare situations where a | appears in the URL, the user
535 % can set the verbdelim field to a different character.
536
537 FUNCTION {format.url}
538 { url empty$
539     { "" }
540     { verbdelim empty$
541         { "\verb|" url * "|" * new.block }
542         { "\verb" verbdelim * url * verbdelim * new.block }
543       if$
544     }
545   if$
546 }
547
548 % This version of format.names puts names in the format
549 %
550 % Initials von Last, Jr.
551
552 FUNCTION {format.names}
553 { 's :=
554   #1 'nameptr :=
555   s num.names$ 'numnames :=
556   numnames 'namesleft :=
557     { namesleft #0 > }
558     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
559       nameptr #1 >
560         { namesleft #1 >
561             { ", " * t * }
562             { numnames #2 >
563                 { "," * }
564                 'skip$
565               if$
566               t "others" =
567                 { " et~al." * }
568                 { " and " * t * }
569               if$
570             }
571           if$
572         }
573         't
574       if$
575       nameptr #1 + 'nameptr :=
576       namesleft #1 - 'namesleft :=
577     }
578   while$
579 }
580
581 FUNCTION {format.authors}
582 { author empty$
583     { "" }
584     { extra.label "\bysame" =
585          {"\bysame"}
586          { author format.names }
587      if$
588     }
589   if$
590 }
591
592 FUNCTION {format.editors}
593 { editor empty$
594     { "" }
595     { editor format.names
596       editor num.names$ #1 >
597         { " (eds.)" * }
598         { " (ed.)" * }
599       if$
600     }
601   if$
602 }
603
604 FUNCTION {format.nonauthor.editors}
605 { editor empty$
606     { "" }
607     { editor num.names$ #1 >
608         { "Eds." slantify }
609         { "Ed." slantify }
610       if$
611       editor format.names tie.or.space.connect
612     }
613   if$
614 }
615
616 % This is the only place we set anything in quotes ... so we don't
617 % provide a special function like: emphasize, embolden, slantify
618 % and parenthesize
619
620 FUNCTION {format.atitle}
621 { title empty$
622     { "" }
623     { " `" title "t" change.case$ * "'" * }
624   if$
625 }
626
627 FUNCTION {format.btitle}
628 { title empty$
629     { "" }
630     { title "t" change.case$ emphasize }
631   if$
632 }
633
634 % format.title ... treat as an article if pages are empty
635 % or as if whole book otherwise
636
637 FUNCTION {format.title}
638 { pages empty$
639     'format.btitle
640     'format.atitle
641   if$
642 }
643
644 % For formatting the volume number for a journal or book of a series
645
646 FUNCTION {format.journal.vol.year}
647 { " " 'append.conjunction :=
648   ""
649   journal emphasize "journal name" append.check
650   volume embolden append
651   year parenthesize "year" append.check
652 }
653
654 % For formatting the issue number for a journal article.
655
656 FUNCTION {format.number}
657 { number empty$
658     { "" }
659     { "no.~" number * }
660   if$
661 }
662
663 FUNCTION {format.series}
664 { series emphasize
665 }
666
667 FUNCTION {format.series.volume.number}
668 { format.series
669   " " 'append.conjunction :=
670   volume embolden
671   duplicate$ empty$
672     { pop$ number embolden append }
673     { append.nonnull
674       number empty$
675         'skip$
676         { ", no.~" * number * 
677           series empty$
678             { "doesn't make sense to use both volume and number if series info is missing"
679               warning$
680               "in BibTeX entry type `" type$ * "'" * top$
681             }
682             'skip$
683           if$
684         }
685       if$
686     }
687   if$
688 }
689
690 FUNCTION {format.in.series.volume.number}
691 { series empty$
692     { "" }
693     { "in " }
694   if$
695   format.series.volume.number *
696 }
697
698 FUNCTION {format.edition}
699 { edition empty$
700     { "" }
701     { editiontype empty$ 
702         { output.state mid.sentence =
703             { edition "l" change.case$ " ed." * }
704             { edition "t" change.case$ " ed." * }
705           if$
706         }
707         { editiontype " " * edition * }
708         if$
709     }
710   if$
711 }
712
713 % For formatting miscellaneous dates ... builds the date on top of the stack
714
715 FUNCTION {format.date}
716 { month empty$
717     { year field.or.null }
718     { month
719       year empty$
720         { "there's a month but no year in " cite$ * warning$ }
721         { " " * year * }
722       if$
723     }
724   if$
725 }
726
727 FUNCTION {format.edition.date}
728 { ", " 'append.conjunction :=
729   ""
730   format.edition append
731   format.date "year" append.check
732   parenthesize
733 }
734
735 FUNCTION {format.howpublished.address.date}
736 { ", " 'append.conjunction :=
737   ""
738   howpublished append
739   address append
740   format.date append
741   parenthesize
742 }
743    
744 FUNCTION {format.publisher.address.edition.date}
745 { ", " 'append.conjunction :=
746   ""
747   publisher "publisher" append.check
748   address append
749   format.edition append
750   format.date "year" append.check
751   parenthesize
752 }
753    
754 FUNCTION {format.org.publisher.address.date}
755 { ", " 'append.conjunction :=
756   ""
757   organization append
758   publisher append
759   address append
760   format.date "year" append.check
761   parenthesize
762 }
763    
764 FUNCTION {format.bvolume}
765 { volume empty$
766     { "" }
767     { "vol.~" volume *
768       series empty$
769         'skip$
770         { " of " * format.series * }
771       if$
772       "volume and number" number either.or.check
773     }
774   if$
775 }
776
777 % format.booktitle formats the booktitle field of types incollection
778 % and inproceedings
779
780 FUNCTION {format.booktitle}
781 { booktitle empty$
782     { "" }
783     { title empty$
784         { "" }
785         { "in " }
786       if$
787       booktitle emphasize * 
788     }
789   if$
790 }
791
792 INTEGERS { multiresult }
793
794 FUNCTION {multi.page.check}
795 { 't :=
796   #0 'multiresult :=
797     { multiresult not
798       t empty$ not
799       and
800     }
801     { t #1 #1 substring$
802       duplicate$ "-" =
803       swap$ duplicate$ "," =
804       swap$ "+" =
805       or or
806         { #1 'multiresult := }
807         { t #2 global.max$ substring$ 't := }
808       if$
809     }
810   while$
811   multiresult
812 }
813
814 FUNCTION {format.pages}
815 { pages empty$
816     { "" }
817     { pages n.dashify }
818   if$
819 }
820
821 FUNCTION {format.book.pages}
822 { pages empty$
823     { "" }
824     { pages multi.page.check
825         { "pp.~" pages n.dashify * }
826         { "p.~" pages * }
827       if$
828     }
829   if$
830 }
831
832 FUNCTION {format.chapter.pages}
833 { chapter empty$
834     'format.book.pages
835     { type empty$
836         { "ch.~" }
837         { type "l" change.case$ " " * }
838       if$
839       chapter *
840       pages empty$
841         'skip$
842         { ", " * format.book.pages * }
843       if$
844     }
845   if$
846 }
847
848 FUNCTION {empty.misc.check}
849 { author empty$ title empty$ howpublished empty$
850   month empty$ year empty$ note empty$
851   and and and and and
852   key empty$ not and
853     { "all relevant fields are empty in " cite$ * warning$ }
854     'skip$
855   if$
856 }
857
858 FUNCTION {format.thesis.type}
859 { type empty$
860     'skip$
861     { pop$
862       type "t" change.case$
863     }
864   if$
865 }
866
867 FUNCTION {format.techrep.type.number}
868 { type empty$
869     { "Tech. Report" }
870     'type
871   if$
872   emphasize
873   " " 'append.conjunction :=
874   number embolden append
875 }
876
877 % Now we have a number of format.crossref functions 
878
879 FUNCTION {format.article.crossref}
880 { key empty$
881     { journal empty$
882         { "need key or journal for " cite$ * " to crossref " * crossref *
883           warning$
884           ""
885         }
886         { "in" journal emphasize tie.or.space.connect }
887       if$
888     }
889     { "in" key tie.or.space.connect }
890   if$
891   " \cite{" * crossref * "}" *
892 }
893
894 FUNCTION {format.crossref.editor}
895 { editor #1 "{vv~}{ll}" format.name$
896   editor num.names$ duplicate$
897   #2 >
898     { pop$ " et~al." * }
899     { #2 <
900         'skip$
901         { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
902             { " et~al." * }
903             { " and " * editor #2 "{vv~}{ll}" format.name$ * }
904           if$
905         }
906       if$
907     }
908   if$
909 }
910
911 FUNCTION {format.book.crossref}
912 { volume empty$
913     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
914       "in "
915     }
916     { "vol.~" volume * " of " * }
917   if$
918   editor empty$
919   editor field.or.null author field.or.null =
920   or
921     { key empty$
922         { series empty$
923             { "need editor, key, or series for " cite$ * " to crossref " *
924               crossref * warning$
925               "" *
926             }
927             { format.series * }
928           if$
929         }
930         { key * }
931       if$
932     }
933     { format.crossref.editor * }
934   if$
935   " \cite{" * crossref * "}" *
936 }
937
938 FUNCTION {format.incoll.inproc.crossref}
939 { editor empty$
940   editor field.or.null author field.or.null =
941   or
942     { key empty$
943         { booktitle empty$
944             { "need editor, key, or booktitle for " cite$ * " to crossref " *
945               crossref * warning$
946               ""
947             }
948             { "in " booktitle emphasize * }
949           if$
950         }
951         { "in" slantify key tie.or.space.connect }
952       if$
953     }
954     { "in" slantify format.crossref.editor tie.or.space.connect }
955   if$
956   " \cite{" * crossref * "}" *
957 }
958
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
960
961 % The main functions for each entry type.
962
963 % journal, vol and year are formatted together because they are
964 % not separated by commas.
965
966 FUNCTION {article}
967 { output.bibitem
968   format.authors "author" output.check
969   format.atitle "title" output.check
970   crossref missing$
971     { format.journal.vol.year output
972       format.number output
973       format.pages "pages" output.check
974     }
975     { format.article.crossref output.nonnull
976       format.pages output
977     }
978   if$
979   format.language output
980   format.url output
981   format.note output
982   fin.entry
983 }
984
985 FUNCTION {book}
986 { output.bibitem
987   author empty$
988     { format.editors "author and editor" output.check }
989     { format.authors output.nonnull
990       crossref missing$
991         { "author and editor" editor either.or.check }
992         'skip$
993       if$
994     }
995   if$
996   format.btitle "title" output.check
997   crossref missing$
998     { format.in.series.volume.number output
999       format.publisher.address.edition.date no.comma output
1000     }
1001     { format.book.crossref output.nonnull 
1002       format.edition.date no.comma output
1003     }
1004   if$
1005   format.language output
1006   format.url output
1007   format.note output
1008   fin.entry
1009 }
1010
1011 FUNCTION {booklet}
1012 { output.bibitem
1013   format.authors output
1014   format.btitle "title" output.check
1015   format.howpublished.address.date no.comma output
1016   format.language output
1017   format.url output
1018   format.note output
1019   fin.entry
1020 }
1021
1022 FUNCTION {inbook}
1023 { output.bibitem
1024   author empty$
1025     { format.editors "author and editor" output.check }
1026     { format.authors output.nonnull
1027       crossref missing$
1028         { "author and editor" editor either.or.check }
1029         'skip$
1030       if$
1031     }
1032   if$
1033   format.btitle "title" output.check
1034   crossref missing$
1035     { format.in.series.volume.number output
1036       format.chapter.pages "chapter and pages" output.check
1037       format.publisher.address.edition.date no.comma output
1038     }
1039     { format.book.crossref output.nonnull
1040       format.chapter.pages "chapter and pages" output.check
1041       format.edition.date no.comma output
1042     }
1043   if$
1044   format.language output
1045   format.url output
1046   format.note output
1047   fin.entry
1048 }
1049
1050 FUNCTION {incollection}
1051 { output.bibitem
1052   format.authors "author" output.check
1053   format.title "title" output.check 
1054   crossref missing$
1055     { format.booktitle "booktitle" output.check
1056       format.nonauthor.editors output
1057       format.in.series.volume.number output
1058       format.chapter.pages "chapter and pages" output.check
1059       format.publisher.address.edition.date no.comma output
1060     }
1061     { format.incoll.inproc.crossref output.nonnull
1062       format.chapter.pages "chapter and pages" output.check
1063       format.edition.date no.comma output
1064     }
1065   if$
1066   format.language output
1067   format.url output
1068   format.note output
1069   fin.entry
1070 }
1071
1072 FUNCTION {inproceedings}
1073 { output.bibitem
1074   format.authors "author" output.check
1075   format.title "title" output.check
1076   crossref missing$
1077     { format.booktitle "booktitle" output.check
1078       format.nonauthor.editors output
1079       format.series.volume.number output
1080       format.org.publisher.address.date no.comma output
1081     }
1082     { format.incoll.inproc.crossref output.nonnull
1083     }
1084   if$
1085   format.pages output
1086   format.language output
1087   format.url output
1088   format.note output
1089   fin.entry
1090 }
1091
1092 FUNCTION {conference} { inproceedings }
1093
1094 FUNCTION {manual}
1095 { output.bibitem
1096   author empty$
1097     { organization empty$
1098         'skip$
1099         { organization output.nonnull }
1100       if$
1101     }
1102     { format.authors output.nonnull }
1103   if$
1104   format.btitle "title" output.check
1105   ", " 'append.conjunction :=
1106   ""
1107   author empty$
1108     { organization append }
1109     'skip$
1110   if$
1111   address append
1112   format.edition append
1113   format.date "year" append.check
1114   parenthesize no.comma output
1115   format.language output
1116   format.url output
1117   format.note output
1118   fin.entry
1119 }
1120
1121 FUNCTION {mastersthesis}
1122 { output.bibitem
1123   format.authors "author" output.check
1124   format.btitle "title" output.check
1125   ", " 'append.conjunction :=
1126   ""
1127   "Master's thesis" format.thesis.type append.nonnull
1128   school "school" append.check
1129   address append
1130   format.date "year" append.check
1131   parenthesize no.comma output
1132   format.language output
1133   format.url output
1134   format.note output
1135   fin.entry
1136 }
1137
1138 FUNCTION {misc}
1139 { output.bibitem
1140   format.authors output
1141   format.btitle output
1142   format.howpublished.address.date no.comma output
1143   format.pages output
1144   format.language output
1145   format.url output
1146   format.note output
1147   fin.entry
1148   empty.misc.check
1149 }
1150
1151 FUNCTION {phdthesis}
1152 { output.bibitem
1153   format.authors "author" output.check
1154   format.btitle "title" output.check
1155   ", " 'append.conjunction :=
1156   ""
1157   "Ph.D. thesis" format.thesis.type append.nonnull
1158   school "school" append.check
1159   address append
1160   format.date "year" append.check
1161   parenthesize no.comma output
1162   format.language output
1163   format.url output
1164   format.note output
1165   fin.entry
1166 }
1167
1168 FUNCTION {proceedings}
1169 { output.bibitem
1170   editor empty$
1171     { organization output }
1172     { format.editors output.nonnull }
1173   if$
1174   format.btitle "title" output.check
1175   format.in.series.volume.number output
1176   ", " 'append.conjunction :=
1177   ""
1178   editor empty$
1179     { organization append }
1180     'skip$
1181   if$
1182   publisher append
1183   format.date "year" append.check
1184   parenthesize no.comma output
1185   format.language output
1186   format.url output
1187   format.note output
1188   fin.entry
1189 }
1190
1191 FUNCTION {techreport}
1192 { output.bibitem
1193   format.authors "author" output.check
1194   format.atitle "title" output.check
1195   format.techrep.type.number output.nonnull
1196   ", " 'append.conjunction :=
1197   ""
1198   institution "institution" append.check
1199   address append
1200   format.date "year" append.check
1201   parenthesize no.comma output
1202   format.language output
1203   format.url output
1204   format.note output
1205   fin.entry
1206 }
1207
1208 FUNCTION {unpublished}
1209 { output.bibitem
1210   format.authors "author" output.check
1211   format.btitle "title" output.check
1212   format.date parenthesize no.comma output
1213   format.language output
1214   format.url output
1215   format.note "note" output.check
1216   fin.entry
1217 }
1218
1219 FUNCTION {default.type} { misc }
1220
1221 MACRO {jan} {"Jan."}
1222
1223 MACRO {feb} {"Feb."}
1224
1225 MACRO {mar} {"Mar."}
1226
1227 MACRO {apr} {"Apr."}
1228
1229 MACRO {may} {"May"}
1230
1231 MACRO {jun} {"Jun."}
1232
1233 MACRO {jul} {"Jul."}
1234
1235 MACRO {aug} {"Aug."}
1236
1237 MACRO {sep} {"Sep."}
1238
1239 MACRO {oct} {"Oct."}
1240
1241 MACRO {nov} {"Nov."}
1242
1243 MACRO {dec} {"Dec."}
1244
1245 READ
1246
1247 FUNCTION {sortify}
1248 { purify$
1249   "l" change.case$
1250 }
1251
1252 INTEGERS { len }
1253
1254 FUNCTION {chop.word}
1255 { 's :=
1256   'len :=
1257   s #1 len substring$ =
1258     { s len #1 + global.max$ substring$ }
1259     's
1260   if$
1261 }
1262
1263 FUNCTION {sort.format.names}
1264 { 's :=
1265   #1 'nameptr :=
1266   ""
1267   s num.names$ 'numnames :=
1268   numnames 'namesleft :=
1269     { namesleft #0 > }
1270     { nameptr #1 >
1271         { "   " * }
1272         'skip$
1273       if$
1274       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
1275       nameptr numnames = t "others" = and
1276         { "et~al." * }
1277         { t sortify * }
1278       if$
1279       nameptr #1 + 'nameptr :=
1280       namesleft #1 - 'namesleft :=
1281     }
1282   while$
1283 }
1284
1285 FUNCTION {sort.format.title}
1286 { 't :=
1287   "A " #2
1288     "An " #3
1289       "The " #4 t chop.word
1290     chop.word
1291   chop.word
1292   sortify
1293   #1 global.max$ substring$
1294 }
1295
1296 FUNCTION {author.sort}
1297 { author empty$
1298     { key empty$
1299         { "to sort, need author or key in " cite$ * warning$
1300           ""
1301         }
1302         { key sortify }
1303       if$
1304     }
1305     { author sort.format.names }
1306   if$
1307 }
1308
1309 FUNCTION {author.editor.sort}
1310 { author empty$
1311     { editor empty$
1312         { key empty$
1313             { "to sort, need author, editor, or key in " cite$ * warning$
1314               ""
1315             }
1316             { key sortify }
1317           if$
1318         }
1319         { editor sort.format.names }
1320       if$
1321     }
1322     { author sort.format.names }
1323   if$
1324 }
1325
1326 FUNCTION {author.organization.sort}
1327 { author empty$
1328     { organization empty$
1329         { key empty$
1330             { "to sort, need author, organization, or key in " cite$ * warning$
1331               ""
1332             }
1333             { key sortify }
1334           if$
1335         }
1336         { "The " #4 organization chop.word sortify }
1337       if$
1338     }
1339     { author sort.format.names }
1340   if$
1341 }
1342
1343 FUNCTION {editor.organization.sort}
1344 { editor empty$
1345     { organization empty$
1346         { key empty$
1347             { "to sort, need editor, organization, or key in " cite$ * warning$
1348               ""
1349             }
1350             { key sortify }
1351           if$
1352         }
1353         { "The " #4 organization chop.word sortify }
1354       if$
1355     }
1356     { editor sort.format.names }
1357   if$
1358 }
1359
1360 FUNCTION {presort}
1361 { type$ "book" =
1362   type$ "inbook" =
1363   or
1364     'author.editor.sort
1365     { type$ "proceedings" =
1366         'editor.organization.sort
1367         { type$ "manual" =
1368             'author.organization.sort
1369             'author.sort
1370           if$
1371         }
1372       if$
1373     }
1374   if$
1375   "    "
1376   *
1377   year field.or.null sortify
1378   *
1379   "    "
1380   *
1381   title field.or.null
1382   sort.format.title
1383   *
1384   #1 entry.max$ substring$
1385   'sort.key$ :=
1386 }
1387
1388 ITERATE {presort}
1389
1390 SORT
1391
1392 STRINGS { longest.label prev.author this.author }
1393
1394 INTEGERS { number.label longest.label.width }
1395
1396 FUNCTION {initialize.longest.label}
1397 { "" 'longest.label :=
1398   #1 'number.label :=
1399   #0 'longest.label.width :=
1400   "abcxyz" 'prev.author :=
1401   "" 'this.author :=
1402 }
1403
1404 FUNCTION {longest.label.pass}
1405 { number.label int.to.str$ 'label :=
1406   number.label #1 + 'number.label :=
1407   label width$ longest.label.width >
1408     { label 'longest.label :=
1409       label width$ 'longest.label.width :=
1410     }
1411     'skip$
1412   if$
1413   author empty$
1414     { editor empty$
1415       { "" }
1416       'editor
1417       if$
1418     }
1419     'author
1420   if$
1421   'this.author :=
1422   this.author prev.author =
1423     { "\bysame" 'extra.label := }
1424     { "" 'extra.label :=
1425       this.author "" =
1426         { "abcxyz" }
1427         'this.author
1428       if$
1429       'prev.author :=
1430     }
1431   if$
1432 }
1433
1434 EXECUTE {initialize.longest.label}
1435
1436 ITERATE {longest.label.pass}
1437
1438 FUNCTION {begin.bib}
1439 { preamble$ empty$
1440     'skip$
1441     { preamble$ write$ newline$ }
1442   if$
1443   "\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}"
1444        write$ newline$
1445   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
1446 }
1447
1448 EXECUTE {begin.bib}
1449
1450 EXECUTE {init.state.consts}
1451
1452 ITERATE {call.type$}
1453
1454 FUNCTION {end.bib}
1455 { newline$
1456   "\end{thebibliography}" write$ newline$
1457 }
1458
1459 EXECUTE {end.bib}
1460 %% \CharacterTable
1461 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
1462 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
1463 %%   Digits        \0\1\2\3\4\5\6\7\8\9
1464 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
1465 %%   Dollar        \$     Percent       \%     Ampersand     \&
1466 %%   Acute accent  \'     Left paren    \(     Right paren   \)
1467 %%   Asterisk      \*     Plus          \+     Comma         \,
1468 %%   Minus         \-     Point         \.     Solidus       \/
1469 %%   Colon         \:     Semicolon     \;     Less than     \<
1470 %%   Equals        \=     Greater than  \>     Question mark \?
1471 %%   Commercial at \@     Left bracket  \[     Backslash     \\
1472 %%   Right bracket \]     Circumflex    \^     Underscore    \_
1473 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
1474 %%   Right brace   \}     Tilde         \~}

UCC git Repository :: git.ucc.asn.au