Debian Codegraph @

texmf-dist/bibtex/bst/apacite/apacite.bst

raw
1 %%
2 %% This is file `apacite.bst',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% apacite.dtx (with options: `bibstyle')
8 %%
9 %% This is a generated file.
10 %%
11 %% Copyright (C) 1994-2013 Erik Meijer and any individual authors listed
12 %% elsewhere in this file.
13 %%
14 %% This file is part of the `apacite' package.
15 %% -------------------------------------------
16 %%
17 %% It may be distributed and/or modified under the
18 %% conditions of the LaTeX Project Public License, either
19 %% version 1.3 of this license or (at your option) any later
20 %% version. The latest version of this license is in:
21 %%
22 %% http://www.latex-project.org/lppl.txt
23 %%
24 %% and version 1.3 or later is part of all distributions of
25 %% LaTeX version 2005/12/01 or later.
26 %%
27 %% The `apacite' package consists of the files apacite.dtx and
28 %% apacite.ins, and the following generated files:
29 %% apacite.sty, apacdoc.sty, apacite.drv,
30 %% apacite.bst, apacitex.bst, apacann.bst, apacannx.bst,
31 %% apa5ex.bib, apacxmpl.tex,
32 %% english.apc, dutch.apc, finnish.apc, french.apc,
33 %% german.apc, ngerman.apc, greek.apc, norsk.apc,
34 %% spanish.apc, swedish.apc.
35 %%
36 %% This work has the LPPL maintenance status `maintained'
37 %%
38 %% The Current Maintainer of this work is Erik Meijer
39 %%
40 %% This file may only be distributed together with a copy of the
41 %% source files of the apacite package, i.e., apacite.dtx and
42 %% apacite.ins. You may however distribute the apacite package without
43 %% the generated files.
44 %%
45 %% apacite.bst
46 %% [2013/07/21 v6.03 APA bibliography style]
47 %% apacite.bst : reference list according to APA manual
48 %% Written by Erik Meijer
49
50 FUNCTION {identify.apacite.version}
51 { % Put identifying string in the .blg file
52 "apacite.bst"
53 " [2013/07/21 v6.03 APA bibliography style]"
54 * top$
55 }
56 ENTRY
57 { address
58 annote
59 annotate
60 author
61 booktitle
62 chair
63 chapter
64 day
65 doi
66 edition
67 editor
68 englishtitle
69 firstkey
70 howpublished
71 institution
72 journal
73 key
74 lastchecked
75 month
76 nihms
77 note
78 number
79 organization
80 originaladdress
81 originalbooktitle
82 originaledition
83 originaleditor
84 originaljournal
85 originalnumber
86 originalpages
87 originalpublisher
88 originalvolume
89 originalyear
90 pages
91 pmcid
92 publisher
93 school
94 series
95 symposium
96 text
97 title
98 translator
99 type
100 url
101 urldate
102 volume
103 year
104 }
105 { cite.order %% order of first citation
106 title.number %% for sorting titles
107 cite.initials %% dummy (0-1) indicating whether or not
108 %% initials of the 1st author must
109 %% be used for citing
110 cite.num.names.full %% number of names to be cited for full and
111 cite.num.names.short %% short cite
112 add.to.year %% For a, b, c, etc. after year
113 %% in multiple citations with same author-year
114 }
115 { year.label %% For sorting entries by year
116 author.year.sort.label %% For sorting entries and checking whether
117 %% initials should be added, how many authors
118 %% should be cited and whether a, b, etc.
119 %% after year is necessary
120 title.sort.label %% for sorting titles
121 citeorder.sort.label %% for sorting by citation order
122 type.2 %% Replacement for type with misc entries and
123 %% entries that revert to misc.
124 }
125 INTEGERS { len pos name.max old.number numnames numnames.old
126 nameptr lastname format.num.names cite.initials.old
127 cite.num.names.old add.to.year.old forward
128 multiresult dot brace.level
129 }
130
131 STRINGS { s t u old.label field
132 aut1f aut1s aut1f.old aut1s.old
133 aut2 aut2.old
134 aut3 aut3.old
135 aut4 aut4.old
136 aut5 aut5.old
137 aut6 aut6.old
138 year.label.old
139 }
140 FUNCTION {test} { #0 }
141 FUNCTION {dump.stack}
142 { "---- STACK {" cite$ * "} ----" * top$
143 stack$
144 "---- END STACK {" cite$ * "} ----" * top$
145 }
146 FUNCTION {make.index} { #0 }
147 FUNCTION {unsorted} { #0 }
148 MACRO {jan} {"{\APACmonth{01}}"}
149 MACRO {feb} {"{\APACmonth{02}}"}
150 MACRO {mar} {"{\APACmonth{03}}"}
151 MACRO {apr} {"{\APACmonth{04}}"}
152 MACRO {may} {"{\APACmonth{05}}"}
153 MACRO {jun} {"{\APACmonth{06}}"}
154 MACRO {jul} {"{\APACmonth{07}}"}
155 MACRO {aug} {"{\APACmonth{08}}"}
156 MACRO {sep} {"{\APACmonth{09}}"}
157 MACRO {oct} {"{\APACmonth{10}}"}
158 MACRO {nov} {"{\APACmonth{11}}"}
159 MACRO {dec} {"{\APACmonth{12}}"}
160 MACRO {winter} {"{\APACmonth{13}}"}
161 MACRO {spring} {"{\APACmonth{14}}"}
162 MACRO {summer} {"{\APACmonth{15}}"}
163 MACRO {fall} {"{\APACmonth{16}}"}
164 FUNCTION {not}
165 { { #0 }
166 { #1 }
167 if$
168 }
169
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171
172 FUNCTION {and}
173 { 'skip$
174 { pop$ #0 }
175 if$
176 }
177
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179
180 FUNCTION {or}
181 { { pop$ #1 }
182 'skip$
183 if$
184 }
185
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 % issues warning if field is empty
191 % call with
192 % "field" field warning.if.empty
193 % Note that the first field must be between quotes
194 % because it is the fieldname for use in the warning message.
195 %
196 FUNCTION {warning.if.empty}
197 { empty$
198 { "No " swap$ * " in " * cite$ * warning$ }
199 { pop$ }
200 if$
201 }
202
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 %
205 % issues warning if title, type, and howpublished are empty
206 %
207 FUNCTION {check.relevant.fields}
208 { title empty$
209 type empty$ and
210 howpublished empty$ and
211 { "No title, type, and howpublished in " cite$ * warning$ }
212 'skip$
213 if$
214 }
215
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 %
218 % delivers 1 if (both editor and translator
219 % not empty and not equal to each other)
220 % 0 if (editor or translator empty) or
221 % (editor = translator)
222 %
223 FUNCTION {editor.ne.trans}
224 { translator empty$
225 { #0 }
226 { editor empty$
227 { #0 }
228 { translator editor =
229 { #0 }
230 { #1 }
231 if$
232 }
233 if$
234 }
235 if$
236 }
237
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239
240 FUNCTION {conv.int.to.str}
241 { duplicate$ #10 <
242 { "0000" swap$ int.to.str$ * }
243 { duplicate$ #100 <
244 { "000" swap$ int.to.str$ * }
245 { duplicate$ #1000 <
246 { "00" swap$ int.to.str$ * }
247 { duplicate$ #10000 <
248 { "0" swap$ int.to.str$ * }
249 { int.to.str$ }
250 if$
251 }
252 if$
253 }
254 if$
255 }
256 if$
257 }
258
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260
261 FUNCTION {ref.type}
262 { type$ "article" =
263 type$ "magazine" =
264 type$ "newspaper" =
265 type$ "book" =
266 type$ "techreport" =
267 type$ "unpublished" =
268 type$ "misc" =
269 type$ "booklet" =
270 type$ "manual" =
271 type$ "proceedings" =
272 or
273 or
274 or
275 or
276 or
277 or
278 or
279 or
280 or
281 { #1 }
282 { type$ "incollection" =
283 type$ "phdthesis" =
284 type$ "mastersthesis" =
285 type$ "lecture" =
286 type$ "inbook" =
287 type$ "inproceedings" =
288 type$ "conference" =
289 type$ "intechreport" =
290 or
291 or
292 or
293 or
294 or
295 or
296 or
297 { #2 }
298 { type$ "literal" =
299 { #3 }
300 { #0 }
301 if$
302 }
303 if$
304 }
305 if$
306 }
307
308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309
310 FUNCTION {is.atype}
311 { type$ "article" =
312 type$ "magazine" =
313 type$ "newspaper" =
314 type$ "incollection" =
315 type$ "inbook" =
316 type$ "inproceedings" =
317 type$ "conference" =
318 type$ "intechreport" =
319 type$ "manual" =
320 or
321 or
322 or
323 or
324 or
325 or
326 or
327 or
328 { #1 }
329 { journal empty$ not
330 %
331 type$ "phdthesis" =
332 type$ "mastersthesis" =
333 or
334 %
335 and
336 { #1 }
337 { type$ "misc" =
338 type empty$ not and
339 { type "\bibmessage" =
340 type "\bibcomputerprogram" =
341 type "\bibcomputerprogrammanual" =
342 type "\bibcomputerprogramandmanual" =
343 type "\bibcomputersoftware" =
344 type "\bibcomputersoftwaremanual" =
345 type "\bibcomputersoftwareandmanual" =
346 type "\bibprogramminglanguage" =
347 or
348 or
349 or
350 or
351 or
352 or
353 or
354 { #1 }
355 { #0 }
356 if$
357 }
358 { #0 }
359 if$
360 }
361 if$
362 }
363 if$
364 }
365
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 %
368 % connects two strings with connect string
369 % if one of them empty, then connect string
370 % is left out
371 %
372 % call with S1 S2 connectstring connect.check
373 %
374 FUNCTION {connect.check}
375 { 'u :=
376 %
377 % if S2 = ""
378 %
379 duplicate$ empty$
380 %
381 % then remove S2
382 %
383 { pop$
384 %
385 % S1 is on top of stack.
386 % if it is empty, it is replaced by the empty string ""
387 %
388 duplicate$ empty$
389 { pop$ "" }
390 'skip$
391 if$
392 }
393 %
394 % else swap S1 and S2 so that S1 can be checked
395 %
396 { swap$
397 %
398 % if S1 is empty, remove S1 so that S2 is left on the
399 % stack and is the result is given
400 %
401 duplicate$ empty$
402 { pop$ }
403 %
404 % now the real work starts:
405 % push the connect string "C"
406 % so that top of stack is "C" "S1" "S2"
407 % concatenate, so that top of stack is
408 % "S1+C" "S2"
409 %
410 { u *
411 %
412 % swap and concatenate
413 %
414 swap$ *
415 }
416 if$
417 }
418 if$
419 }
420
421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422 %
423 % connects two strings with space ("\ ")
424 % if length of second is 4 or larger,
425 % connects them with non-breaking space ("tie", "~")
426 % if length of second smaller than 4
427 %
428 % call with S1 S2 tie.or.space.connect
429 % result: "S1\ S2" or "S1~S2"
430 %
431 FUNCTION {tie.or.space.connect}
432 { duplicate$ text.length$ #4 <
433 { "~" }
434 { "\ " }
435 if$
436 swap$ * *
437 }
438
439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
440 %
441 % connects two strings with comma (", ")
442 % if one of them is empty, the comma is left out
443 %
444 % call with S1 S2 connect.with.comma.check
445 % result: "S1, S2"
446 %
447 FUNCTION {connect.with.comma.check}
448 { ", " connect.check }
449
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451 %
452 % connects two strings with semicolon ("; ")
453 % if one of them is empty, semicolon is left out
454 %
455 % call with S1 S2 connect.with.semicolon.check
456 % result: "S1; S2"
457 %
458 FUNCTION {connect.with.semicolon.check}
459 { "; " connect.check }
460
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 %
463 % connects two strings with colon (": ")
464 % if one of them is empty, colon is left out
465 %
466 % call with S1 S2 connect.with.colon.check
467 % result: "S1: S2"
468 %
469 FUNCTION {connect.with.colon.check}
470 { ": " connect.check }
471
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 %
474 % connects two strings with space ("\ ")
475 %
476 % call with S1 S2 connect.with.space.check
477 % result: "S1\ S2"
478 %
479 FUNCTION {connect.with.space.check}
480 { "\ " connect.check }
481
482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 %
484 % encloses string in pre- and postfix string
485 % call with
486 % prefix postfix S enclose.check
487 % delivers empty string if S empty
488 %
489 FUNCTION {enclose.check}
490 { duplicate$ empty$
491 { pop$ pop$ pop$
492 ""
493 }
494 { swap$ * * }
495 if$
496 }
497
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 %
500 % emphasizes top of stack
501 % call with
502 % "string" emphasize.check
503 %
504 FUNCTION {emphasize.check}
505 { "\Bem{" swap$
506 "}" swap$
507 enclose.check
508 }
509
510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 %
512 % brackets top of stack
513 % call with
514 % "string" bracket
515 %
516 FUNCTION {bracket.check}
517 { "[" swap$
518 "]" swap$
519 enclose.check
520 }
521
522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
523 %
524 % parenthesizes top of stack
525 % call with
526 % "string" parenthesize
527 %
528 FUNCTION {parenthesize.check}
529 { "(" swap$
530 ")" swap$
531 enclose.check
532 }
533
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
535 %
536 % checks whether argument is "multiresult":
537 % whether it contains '-', '+', or ',' characters
538 % used with pages to check whether pp. or p. must be used
539 %
540 FUNCTION {multi.result.check}
541 { 't :=
542 #0 'multiresult :=
543 %
544 % while (not multiresult) and (length(t) > 1) do
545 %
546 { multiresult not
547 t text.length$ #1 >
548 and
549 }
550 %
551 % if t(1-2) = "--" or t(1) = "+" or ","
552 % then multiresult = 1
553 % else t = t(2-last)
554 %
555 { t #1 #2 substring$ 's :=
556 "--" s =
557 { #1 'multiresult := }
558 { t #1 #1 substring$ 's :=
559 "+" s =
560 "," s =
561 or
562 { #1 'multiresult := }
563 { t #2 global.max$ substring$ 't := }
564 if$
565 }
566 if$
567 }
568 while$
569 multiresult
570 }
571
572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 %
574 % Checks whether an author is a corporate author, i.e.,
575 % whether the field starts with "{\bibcorporate".
576 % Call with
577 % field is.bibcorporate
578 %
579 FUNCTION {is.bibcorporate}
580 { #1 #14 substring$ "{\bibcorporate" = }
581
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586
587 FUNCTION {sortify}
588 { purify$
589 "l" change.case$
590 }
591
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
593
594 FUNCTION {remove.spaces}
595 { % Remove spaces from string.
596 % Works best if string only contains alphanumeric characters and spaces.
597 's := % The original string
598 s text.length$ 'len := % Its length (no. of characters)
599 "" 't := % Initialize the transformed string
600 #0 'pos :=
601 %
602 % while (pos < len) do
603 %
604 { pos len < }
605 { pos #1 + 'pos :=
606 s pos #1 substring$ 'u :=
607 %
608 % u is the pos-th character in s
609 % If it is a space, move to next character,
610 % else copy character to output.
611 %
612 u " " =
613 'skip$
614 { t u * 't := }
615 if$
616 }
617 while$
618 %
619 % Now push the result back on the stack
620 t
621 }
622
623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625
626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627 %
628 % end block by writing what's left on the stack and
629 % starting a new line
630 %
631 FUNCTION {output.end.block}
632 { write$
633 newline$
634 }
635
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 %
638 % end block by adding a period and writing what's left
639 % on the stack and starting a new line
640 %
641 FUNCTION {output.dot.end.block}
642 { add.period$
643 output.end.block
644 }
645
646 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
647 %
648 % starting new block by writing what's left on the stack,
649 % starting a new line and adding some extra space or
650 % whatever is more defined in \newblock
651 %
652 FUNCTION {output.new.block}
653 { output.end.block
654 "\newblock" write$ newline$
655 }
656
657 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
658 %
659 % starting new block by writing what's left on the stack,
660 % starting a new line and adding some extra space or
661 % whatever is more defined in \newblock
662 %
663 FUNCTION {output.dot.new.block}
664 { add.period$
665 output.new.block
666 }
667
668 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
669
670 FUNCTION {start.new.block}
671 { "\unskip\ " write$ newline$
672 "\newblock " write$ newline$
673 }
674
675 FUNCTION {sort.name.format.classic} { "{ll{}}{ f{}}{ vv{}}{ jj{}}" }
676
677 FUNCTION {cite.name.format.classic} { "{ll}" }
678
679 FUNCTION {author.name.format.classic} { "{ll}{, f{\BPBI }.}{ vv}{, jj}" }
680
681 FUNCTION {index.name.format.classic} { "{ll}{, f{\BPBI }.}{ vv}{, jj}" }
682
683 FUNCTION {sort.name.format} { "{vv{}}{ll{}}{ f{}}{ jj{}}" }
684
685 FUNCTION {cite.name.format} { "{vv }{ll}" }
686
687 FUNCTION {cite.initials.name.format} { "{f{\BPBI }.~~}{vv }{ll}{ jj}" }
688
689 FUNCTION {author.name.format} { "{vv }{ll}{, f{\BPBI }.}{, jj}" }
690
691 FUNCTION {editor.name.format} { "{f{\BPBI }.~~}{vv }{ll}{ jj}" }
692
693 FUNCTION {index.name.format} { "{vv }{ll}{, f{\BPBI }.}{, jj}" }
694
695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
696
697 FUNCTION {init.initials}
698 { "yyyyy" 'aut1f.old :=
699 "yyyyy" 'aut1s.old :=
700 #0 'cite.initials.old :=
701 }
702
703 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704
705 FUNCTION {update.no.initials}
706 { 'field :=
707 field 'aut1f.old :=
708 field 'aut1s.old :=
709 #0 'cite.initials.old :=
710 }
711
712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713
714 FUNCTION {check.add.initials.aut}
715 { %
716 % If last name is equal to previous last name
717 % but initials are different, then initials should
718 % be cited. If initials are also the same, initials
719 % should be cited if that is the case for the previous
720 % author .
721 %
722 aut1s aut1s.old =
723 { aut1f aut1f.old =
724 { cite.initials.old 'cite.initials := }
725 { #1 'cite.initials :=
726 aut1f 'aut1f.old :=
727 aut1s 'aut1s.old :=
728 cite.initials 'cite.initials.old :=
729 }
730 if$
731 }
732 { %
733 % Different last name.
734 aut1f 'aut1f.old :=
735 aut1s 'aut1s.old :=
736 cite.initials 'cite.initials.old :=
737 }
738 if$
739 }
740
741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
742
743 FUNCTION {check.add.initials.field}
744 { 'field :=
745 field #1 cite.initials.name.format format.name$ 'aut1f :=
746 field #1 cite.name.format format.name$ 'aut1s :=
747 %
748 % Now do the actual work
749 %
750 check.add.initials.aut
751 }
752
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
754
755 FUNCTION {check.add.initials}
756 { %
757 % Check whether author or editor or other field acts as author.
758 % Initials are only relevant with author or editor.
759 %
760 firstkey empty$ not
761 { key empty$ not
762 { %
763 % Both key and firstkey are nonempty.
764 % Then, key is treated as last name of first author,
765 % and firstkey is treated as last name + initials of
766 % first author .
767 %
768 firstkey sortify remove.spaces 'aut1f :=
769 key sortify remove.spaces 'aut1s :=
770 check.add.initials.aut
771 }
772 { firstkey sortify remove.spaces update.no.initials }
773 if$
774 }
775 { key empty$ not
776 { key sortify remove.spaces update.no.initials }
777 { %
778 % No key or firstkey, so find out which field
779 % to use as author.
780 %
781 % Check reference type:
782 % if result is 1 then possibly editor acts as author
783 % 2 then editor does not act as author
784 % 3 then key should have been used
785 % 0 then unknown reference type
786 ref.type #2 =
787 { %
788 % Format first author with and without initials
789 author empty$
790 { title.sort.label update.no.initials }
791 { author check.add.initials.field }
792 if$
793 }
794 { %
795 % Format first author with and without initials
796 author empty$
797 { editor empty$
798 { title.sort.label update.no.initials }
799 { editor check.add.initials.field }
800 if$
801 }
802 { author check.add.initials.field }
803 if$
804 }
805 if$
806 }
807 if$
808 }
809 if$
810 }
811
812 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
813
814 FUNCTION {tentative.cite.num.names.field}
815 { 'field :=
816 field num.names$ 'numnames :=
817 numnames #3 <
818 { %
819 % 1 or 2 names: always cite all of them.
820 numnames 'cite.num.names.full :=
821 numnames 'cite.num.names.short :=
822 }
823 { numnames #6 <
824 { %
825 % 3-5 names: cite all of them the first time,
826 % only the first name later times
827 numnames 'cite.num.names.full :=
828 #1 'cite.num.names.short :=
829 }
830 { %
831 % 6 or more names: cite only the first name
832 #1 'cite.num.names.full :=
833 #1 'cite.num.names.short :=
834 }
835 if$
836 }
837 if$
838 }
839
840 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
841
842 FUNCTION {tentative.cite.num.names}
843 { %
844 % Check whether author or editor or other field acts as author.
845 % Number of names is only relevant with author or editor.
846 %
847 firstkey empty$ not
848 {
849 #1 'cite.num.names.full :=
850 #1 'cite.num.names.short :=
851 }
852 { key empty$ not
853 {
854 #1 'cite.num.names.full :=
855 #1 'cite.num.names.short :=
856 }
857 { %
858 % No key or firstkey, so find out which field
859 % to use as author.
860 %
861 % Check reference type:
862 % if result is 1 then possibly editor acts as author
863 % 2 then editor does not act as author
864 % 3 then key should have been used
865 % 0 then unknown reference type
866 ref.type #2 =
867 { %
868 % Format first author with and without initials
869 author empty$
870 {
871 #1 'cite.num.names.full :=
872 #1 'cite.num.names.short :=
873 }
874 { author tentative.cite.num.names.field }
875 if$
876 }
877 { %
878 % Format first author with and without initials
879 author empty$
880 { editor empty$
881 {
882 #1 'cite.num.names.full :=
883 #1 'cite.num.names.short :=
884 }
885 { editor tentative.cite.num.names.field }
886 if$
887 }
888 { author tentative.cite.num.names.field }
889 if$
890 }
891 if$
892 }
893 if$
894 }
895 if$
896 }
897
898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
899
900 FUNCTION {init.cite.num.names}
901 { #0 'cite.num.names.old :=
902 #0 'numnames.old :=
903 "yyyy" 'year.label.old :=
904 #0 'add.to.year.old :=
905 "" 'aut1f.old :=
906 "" 'aut2.old :=
907 "" 'aut3.old :=
908 "" 'aut4.old :=
909 "" 'aut5.old :=
910 "" 'aut6.old :=
911 }
912
913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914
915 FUNCTION {update.cite.num.names}
916 { cite.num.names.short 'cite.num.names.old :=
917 numnames 'numnames.old :=
918 year.label 'year.label.old :=
919 add.to.year 'add.to.year.old :=
920 aut1f 'aut1f.old :=
921 aut2 'aut2.old :=
922 aut3 'aut3.old :=
923 aut4 'aut4.old :=
924 aut5 'aut5.old :=
925 aut6 'aut6.old :=
926 }
927
928 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
929
930 FUNCTION {format.6.authors}
931 { %
932 % First author: with initials.
933 %
934 field #1 cite.initials.name.format format.name$ 'aut1f :=
935 %
936 % Second and later authors: without initials.
937 %
938 numnames #1 >
939 name.max #1 >
940 and
941 { %
942 % 2nd author
943 field #2 cite.name.format format.name$ 'aut2 :=
944 %
945 numnames #2 >
946 name.max #2 >
947 and
948 { %
949 % 3nd author
950 field #3 cite.name.format format.name$ 'aut3 :=
951 %
952 numnames #3 >
953 name.max #3 >
954 and
955 { %
956 % 4th author
957 field #4 cite.name.format format.name$ 'aut4 :=
958 %
959 numnames #4 >
960 name.max #4 >
961 and
962 { %
963 % 5th author
964 field #5 cite.name.format format.name$ 'aut5 :=
965 %
966 numnames #5 >
967 name.max #5 >
968 and
969 { %
970 % 6th author
971 field #6 cite.name.format format.name$ 'aut6 :=
972 }
973 { %
974 % 5 authors: 6 is empty
975 %
976 "" 'aut6 :=
977 }
978 if$
979 }
980 { %
981 % 4 authors: 5-6 are empty
982 %
983 "" 'aut5 :=
984 "" 'aut6 :=
985 }
986 if$
987 }
988 { %
989 % 3 authors: 4-6 are empty
990 %
991 "" 'aut4 :=
992 "" 'aut5 :=
993 "" 'aut6 :=
994 }
995 if$
996 }
997 { %
998 % 2 authors: 3-6 are empty
999 %
1000 "" 'aut3 :=
1001 "" 'aut4 :=
1002 "" 'aut5 :=
1003 "" 'aut6 :=
1004 }
1005 if$
1006 }
1007 { %
1008 % Only 1 author: 2-6 are empty
1009 %
1010 "" 'aut2 :=
1011 "" 'aut3 :=
1012 "" 'aut4 :=
1013 "" 'aut5 :=
1014 "" 'aut6 :=
1015 }
1016 if$
1017 }
1018
1019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020
1021 FUNCTION {change.add.to.year}
1022 {
1023 forward #1 =
1024 { %
1025 % Moving forward: this add.to.year number must be 1 higher than
1026 % previous.
1027 %
1028 add.to.year.old #0 >
1029 { add.to.year.old #1 + 'add.to.year := }
1030 { #2 'add.to.year := }
1031 if$
1032 }
1033 { %
1034 % Moving backward: this add.to.year number must be 1 lower than
1035 % previous.
1036 %
1037 add.to.year.old #1 - 'add.to.year :=
1038 }
1039 if$
1040 }
1041
1042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1043
1044 FUNCTION {definitive.cite.num.names.1.or.2}
1045 { %
1046 numnames numnames.old =
1047 { %
1048 % Same number of names: ambiguity could arise. Check whether current
1049 % and previous have the same author(s).
1050 %
1051 aut1f aut1f.old =
1052 { %
1053 % Same first author: if the second author is also the same or if
1054 % there is only one author, a's and b's should be added.
1055 %
1056 aut2 aut2.old =
1057 numnames #2 =
1058 and
1059 %
1060 numnames #1 =
1061 or
1062 { %
1063 % Same author(s): add to year.
1064 %
1065 change.add.to.year
1066 }
1067 { %
1068 % Different second author: no ambiguity possible.
1069 %
1070 skip$
1071 }
1072 if$
1073 }
1074 { %
1075 % Different first author: no ambiguity possible.
1076 %
1077 skip$
1078 }
1079 if$
1080 }
1081 { %
1082 % Different number of names: no ambiguity possible.
1083 %
1084 skip$
1085 }
1086 if$
1087 }
1088
1089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1090
1091 FUNCTION {definitive.cite.num.names.3.or.more}
1092 { %
1093 % Check whether current and previous have the same first author.
1094 %
1095 aut1f aut1f.old =
1096 { %
1097 % Same first author: check second author
1098 %
1099 aut2 aut2.old =
1100 { %
1101 % Same 1st & 2nd author: check 3rd.
1102 %
1103 aut3 aut3.old =
1104 { %
1105 % Same 1st-3rd authors: check 4th.
1106 %
1107 numnames.old #3 =
1108 { numnames #3 =
1109 { %
1110 % Both current and previous have 3 authors, which are
1111 % the same, so both have identical author-year
1112 % combinations, so ambiguity should be resolved by
1113 % a's and b's. Check whether more authors were
1114 % necessary for previous one.
1115 %
1116 change.add.to.year
1117 cite.num.names.short cite.num.names.old <
1118 { cite.num.names.old
1119 'cite.num.names.short :=
1120 }
1121 'skip$
1122 if$
1123 }
1124 { %
1125 % Previous has 3 authors, current has more, with same
1126 % first 3, so at least 4 must be used for current to
1127 % make a difference.
1128 %
1129 cite.num.names.short #4 <
1130 { #4 'cite.num.names.short := }
1131 'skip$
1132 if$
1133 }
1134 if$
1135 }
1136 { numnames #3 =
1137 { %
1138 % Current has 3 authors, previous has more, with same
1139 % first 3, so all 3 of current must be used.
1140 %
1141 numnames 'cite.num.names.short :=
1142 }
1143 { %
1144 % Same 1st-3rd author and both current and previous
1145 % have at least 4 authors: check 4th.
1146 %
1147 aut4 aut4.old =
1148 { %
1149 % Same 1st-4th authors: check 5th.
1150 %
1151 numnames.old #4 =
1152 { numnames #4 =
1153 { %
1154 % Both current and previous have 4 authors,
1155 % which are the same, so both have
1156 % identical author-year combinations, so
1157 % ambiguity should be resolved by a's and
1158 % b's. Check whether more authors were
1159 % necessary for previous one.
1160 %
1161 change.add.to.year
1162 cite.num.names.short cite.num.names.old <
1163 { cite.num.names.old
1164 'cite.num.names.short :=
1165 }
1166 'skip$
1167 if$
1168 }
1169 { %
1170 % Previous has 4 authors, current has more,
1171 % with same first 4, so at least 5 must be
1172 % used for current to make a difference.
1173 %
1174 cite.num.names.short #5 <
1175 { #5 'cite.num.names.short := }
1176 'skip$
1177 if$
1178 }
1179 if$
1180 }
1181 { numnames #4 =
1182 { %
1183 % Current has 4 authors, previous has more,
1184 % with same first 4, so all 4 of current
1185 % must be used.
1186 %
1187 numnames 'cite.num.names.short :=
1188 }
1189 { %
1190 % Same 1st-4th author and both current and
1191 % previous have at least 5 authors: check
1192 % 5th.
1193 %
1194 aut5 aut5.old =
1195 { %
1196 % Same 1st-5th authors: check 6th.
1197 %
1198 numnames.old #5 =
1199 { numnames #5 =
1200 { %
1201 % Both current and previous
1202 % have 5 authors, which are the
1203 % same, so both have identical
1204 % author-year combinations, so
1205 % ambiguity should be resolved
1206 % by a's and b's. Check whether
1207 % more authors were necessary
1208 % for previous one.
1209 %
1210 change.add.to.year
1211 cite.num.names.short
1212 cite.num.names.old <
1213 { cite.num.names.old
1214 'cite.num.names.short :=
1215 }
1216 'skip$
1217 if$
1218 }
1219 { %
1220 % Previous has 5 authors,
1221 % current has more, with same
1222 % first 5, so at least 6 must
1223 % be used for current to make
1224 % a difference.
1225 %
1226 cite.num.names.short #6 <
1227 { #6 'cite.num.names.short := }
1228 'skip$
1229 if$
1230 }
1231 if$
1232 }
1233 { numnames #5 =
1234 { %
1235 % Current has 5 authors,
1236 % previous has more, with same
1237 % first 5, so all 5 of current
1238 % must be used.
1239 %
1240 numnames 'cite.num.names.short :=
1241 }
1242 { %
1243 % Same 1st-5th author and both
1244 % current and previous have at
1245 % least 6 authors. If one has
1246 % 6 authors and the other has
1247 % more or the 6th is different,
1248 % 6 should be used (which is
1249 % the maximum).
1250 %
1251 numnames #6 >
1252 numnames.old #6 =
1253 and
1254 %
1255 numnames #6 =
1256 numnames.old #6 >
1257 and
1258 %
1259 or
1260 %
1261 aut6 aut6.old =
1262 not
1263 %
1264 or
1265 { #6 cite.num.names.short <
1266 { #6
1267 'cite.num.names.short
1268 :=
1269 }
1270 'skip$
1271 if$
1272 }
1273 { %
1274 % The first 6 authors are
1275 % the same and either both
1276 % have 6 or both have more.
1277 % So for all practical
1278 % purposes they have
1279 % identical author-year
1280 % combination, so ambiguity
1281 % should be resolved by a's
1282 % and b's. Check whether
1283 % more authors were
1284 % necessary for previous
1285 % one.
1286 %
1287 change.add.to.year
1288 cite.num.names.short
1289 cite.num.names.old
1290 <
1291 { cite.num.names.old
1292 'cite.num.names.short
1293 :=
1294 }
1295 'skip$
1296 if$
1297 }
1298 if$
1299 }
1300 if$
1301 }
1302 if$
1303 }
1304 { %
1305 % Different 5th author: citing 5 authors is
1306 % sufficient for this comparison.
1307 %
1308 cite.num.names.short #5 <
1309 { #5 'cite.num.names.short := }
1310 'skip$
1311 if$
1312 }
1313 if$
1314 }
1315 if$
1316 }
1317 if$
1318 }
1319 { %
1320 % Different 4th author: citing 4 authors is
1321 % sufficient for this comparison.
1322 %
1323 cite.num.names.short #4 <
1324 { #4 'cite.num.names.short := }
1325 'skip$
1326 if$
1327 }
1328 if$
1329 }
1330 if$
1331 }
1332 if$
1333 }
1334 { %
1335 % Different 3rd author: citing 3 authors is sufficient for this
1336 % comparison.
1337 %
1338 cite.num.names.short #3 <
1339 { #3 'cite.num.names.short := }
1340 'skip$
1341 if$
1342 }
1343 if$
1344 }
1345 { %
1346 % Different 2nd author: citing 2 authors is sufficient for this
1347 % comparison.
1348 %
1349 cite.num.names.short #2 <
1350 { #2 'cite.num.names.short := }
1351 'skip$
1352 if$
1353 }
1354 if$
1355 }
1356 { %
1357 % Different first author: no ambiguity, move to next entry.
1358 %
1359 skip$
1360 }
1361 if$
1362 }
1363
1364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1365
1366 FUNCTION {definitive.cite.num.names.field}
1367 { 'field :=
1368 field num.names$ 'numnames :=
1369 %
1370 % Format authors
1371 %
1372 format.6.authors
1373 %
1374 % Now compare authors with authors of previous entry.
1375 %
1376 cite.num.names.short numnames.old >
1377 { %
1378 % The previous entry has less authors than already defined
1379 % necessary to be cited. No ambiguity is possible and we're ready.
1380 %
1381 skip$
1382 }
1383 { %
1384 % Both previous and current entry have at least one author .
1385 %
1386 year.label year.label.old =
1387 { %
1388 % Same year label: possibly ambiguous citation.
1389 %
1390 % First check: current and/or previous have 1 or
1391 % 2 authors.
1392 %
1393 numnames #3 <
1394 numnames.old #3 <
1395 or
1396 %
1397 { definitive.cite.num.names.1.or.2 }
1398 { definitive.cite.num.names.3.or.more }
1399 if$
1400 }
1401 { %
1402 % Different year label: everything's fine,
1403 % move to next entry.
1404 %
1405 skip$
1406 }
1407 if$
1408 }
1409 if$
1410 %
1411 % If during the previous process the name maximum is exceeded
1412 % (which was not checked), correct this. NOTE: If the name
1413 % maximum is smaller than 6, this could lead to ambiguous
1414 % citations if, e.g., the year and the first 5 authors are
1415 % the same, but the 6th author is different.
1416 %
1417 cite.num.names.short name.max >
1418 { name.max 'cite.num.names.short := }
1419 'skip$
1420 if$
1421 %
1422 % For a "full" cite, the number of names should always be at least
1423 % as large as for a "short" cite.
1424 %
1425 cite.num.names.full cite.num.names.short <
1426 { cite.num.names.short 'cite.num.names.full := }
1427 'skip$
1428 if$
1429 %
1430 % Update "old" variables for next entry.
1431 %
1432 update.cite.num.names
1433 }
1434
1435 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1436
1437 FUNCTION {definitive.cite.no.names}
1438 { %
1439 % The formatted field that acts as author is on top
1440 % of the stack.
1441 'aut1f :=
1442 "" 'aut2 :=
1443 "" 'aut3 :=
1444 "" 'aut4 :=
1445 "" 'aut5 :=
1446 "" 'aut6 :=
1447 #1 'numnames :=
1448 %
1449 year.label year.label.old =
1450 { %
1451 % Same year label: possibly ambiguous citation.
1452 %
1453 definitive.cite.num.names.1.or.2
1454 }
1455 { %
1456 % Different year label: everything's fine,
1457 % move to next entry.
1458 %
1459 skip$
1460 }
1461 if$
1462 %
1463 % Update "old" variables for next entry.
1464 %
1465 update.cite.num.names
1466 }
1467
1468 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1469
1470 FUNCTION {definitive.cite.num.names}
1471 { %
1472 % Check whether author or editor or other field acts as author.
1473 % Number of names is only relevant with author or editor.
1474 %
1475 firstkey empty$ not
1476 { firstkey sortify remove.spaces definitive.cite.no.names }
1477 { key empty$ not
1478 { key sortify remove.spaces definitive.cite.no.names }
1479 { %
1480 % No key or firstkey, so find out which field
1481 % to use as author.
1482 %
1483 % Check reference type:
1484 % if result is 1 then possibly editor acts as author
1485 % 2 then editor does not act as author
1486 % 3 then key should have been used
1487 % 0 then unknown reference type
1488 ref.type #2 =
1489 { %
1490 % Format first author with and without initials
1491 author empty$
1492 { title.sort.label definitive.cite.no.names }
1493 { author definitive.cite.num.names.field }
1494 if$
1495 }
1496 { %
1497 % Format first author with and without initials
1498 author empty$
1499 { editor empty$
1500 { title.sort.label definitive.cite.no.names }
1501 { editor definitive.cite.num.names.field }
1502 if$
1503 }
1504 { author definitive.cite.num.names.field }
1505 if$
1506 }
1507 if$
1508 }
1509 if$
1510 }
1511 if$
1512 }
1513
1514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1515
1516 FUNCTION {make.tentative.year.sort.label}
1517 { %
1518 % Implicit or explicit ``no date'' is put at the front
1519 % (the year zero; years B.C. will imply complications)
1520 % because these are possibly old works.
1521 % ``In press'' is put at the end.
1522 %
1523 year empty$
1524 { "0000" 'year.label := }
1525 { year "\bibnodate" =
1526 year "l" change.case$ "no date" = or
1527 year "l" change.case$ "n.d." = or
1528 { "0000" 'year.label := }
1529 { year "\BIP" =
1530 year "l" change.case$ "in press" = or
1531 year "l" change.case$ "forthcoming" = or
1532 { "9999" 'year.label := }
1533 { % It is not checked whether the year field
1534 % makes sense.
1535 year sortify remove.spaces 'year.label :=
1536 }
1537 if$
1538 }
1539 if$
1540 }
1541 if$
1542 %
1543 % Push year sort label on the stack
1544 year.label
1545 }
1546
1547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1548
1549 FUNCTION {month.number.day}
1550 { month empty$
1551 { "" }
1552 { month sortify remove.spaces
1553 %
1554 % Add the day when available.
1555 day empty$
1556 'skip$
1557 { "/" *
1558 day sortify remove.spaces *
1559 }
1560 if$
1561 }
1562 if$
1563 }
1564
1565 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1566
1567 FUNCTION {make.name.sort.label}
1568 { %
1569 % Author or editor-acting-as-author available.
1570 % => Make tentative "short cite with initials" author
1571 % label (L1) of one of the forms
1572 % "Last1 F1"
1573 % "Last1 F1 Last2"
1574 % "Last1 F1 zzzz" ("zzzz" representing et al.)
1575 % => If more than 2 'authors': make label (L2) for 2nd-6th authors
1576 % of one of the forms
1577 % "Last2 Last3"
1578 % "Last2 Last3 Last4"
1579 % "Last2 Last3 Last4 Last5"
1580 % "Last2 Last3 Last4 Last5 Last6"
1581 % "Last2 Last3 Last4 Last5 Last6 zzzz"
1582 %
1583 % Then format year label (L3) of one of the forms:
1584 % "0000" (missing year or explicit 'no date')
1585 % "9999" ('in press')
1586 % year (otherwise; don't use originalyear here yet)
1587 %
1588 % From earlier sorting of titles, we have title number. Convert
1589 % to string, which gives title label (L4) .
1590 %
1591 % Then tentative sorting label (author.year.sort.label) is a
1592 % concatenation of
1593 % L1
1594 % " "
1595 % L3
1596 % " "
1597 % L2
1598 % " "
1599 % L4
1600 %
1601 % The name field is on top of the stack.
1602 'field :=
1603 %
1604 % numnames is the total number of names contained in field
1605 field num.names$ 'numnames :=
1606 %
1607 % Format first author
1608 field #1 sort.name.format format.name$
1609 %
1610 % Format the second author if there are two, or else "zzzz" = et al.
1611 numnames #1 =
1612 'skip$
1613 { numnames #2 =
1614 { %
1615 % Two authors: format second author
1616 field #2 "{ll{}}" format.name$ 's :=
1617 s "others" =
1618 { " zzzz" * } % Add "et al."-substitute
1619 { " " * s * } % Add second author
1620 if$
1621 }
1622 { " zzzz" * } % 3 or more authors: add "et al."-substitute
1623 if$
1624 }
1625 if$
1626 " " * % Add spaces
1627 make.tentative.year.sort.label * % Add year (L3).
1628 " " * % Add spaces
1629 %
1630 % Now build up L2 if applicable
1631 numnames #3 <
1632 'skip$
1633 { %
1634 % Treat last author slightly differently
1635 numnames name.max >
1636 { name.max 'lastname :=
1637 " zzzz" % Push "et al."-substitute on stack
1638 }
1639 { numnames 'lastname :=
1640 "" % Push empty string on stack
1641 }
1642 if$
1643 %
1644 % Names 2 to "last" - 1
1645 "" % Push empty string on stack
1646 #2 'nameptr :=
1647 { nameptr lastname < }
1648 { % Add name no. nameptr
1649 field nameptr "{ll{}}" format.name$ *
1650 " " *
1651 nameptr #1 + 'nameptr :=
1652 }
1653 while$
1654 %
1655 % "Last" author
1656 field lastname "{ll{}}" format.name$ 's :=
1657 s "others" =
1658 { "zzzz" * } % Add "et al."-substitute
1659 { s * } % Add last author
1660 if$
1661 %
1662 swap$ * % Add the previously formatted empty string or
1663 % "et al."-substitute if there are many authors.
1664 * % Add L2 to the earlier labels.
1665 }
1666 if$
1667 %
1668 " " * % Add spaces
1669 title.number conv.int.to.str * % Add sorted title number (L4).
1670 sortify % Clean up and convert to lowercase
1671 " " * % Add spaces
1672 month.number.day * % Add month and day when available
1673 'author.year.sort.label := % Assign result to sort label.
1674 }
1675
1676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1677
1678 FUNCTION {make.field.year.sort.label}
1679 { %
1680 % 'field' acts as first author (L1), subsequent authors
1681 % are empty (L2).
1682 %
1683 % Then format year label (L3) of one of the forms:
1684 % "0000" (missing year or explicit 'no date')
1685 % "9999" ('in press')
1686 % year (otherwise; don't use originalyear here yet)
1687 %
1688 % From earlier sorting of titles, we have title number. Convert
1689 % to string, which gives title label (L4) .
1690 %
1691 % Then tentative sorting label (author.year.sort.label) is a
1692 % concatenation of
1693 % L1
1694 % " "
1695 % L3
1696 % " "
1697 % L2
1698 % " "
1699 % L4
1700 %
1701 % 'field' is on top of the stack. It is already supposed to be cleaned
1702 % (i.e., sortified and space-removed), so this is already L1.
1703 " " * % Add spaces to L1
1704 make.tentative.year.sort.label * % Add year (L3).
1705 " " * % Add spaces
1706 " " * % L2 is empty, add spaces
1707 title.number conv.int.to.str * % Add sorted title number (L4).
1708 sortify % Clean up and convert to lowercase
1709 " " * % Add spaces
1710 month.number.day * % Add month and day when available
1711 'author.year.sort.label := % Assign result to sort label.
1712 }
1713
1714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1715
1716 FUNCTION {make.author.editor.sort.label}
1717 { author empty$
1718 { editor empty$
1719 { %
1720 % Use what has previously been stored in title.sort.label
1721 % as author substitute .
1722 title.sort.label make.field.year.sort.label
1723 }
1724 { editor make.name.sort.label }
1725 if$
1726 }
1727 { author make.name.sort.label }
1728 if$
1729 }
1730
1731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1732
1733 FUNCTION {make.author.sort.label}
1734 { author empty$
1735 { %
1736 % Use what has previously been stored in title.sort.label
1737 % as author substitute .
1738 title.sort.label make.field.year.sort.label
1739 }
1740 { author make.name.sort.label }
1741 if$
1742 }
1743
1744 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1745
1746 FUNCTION {make.tentative.sort.label}
1747 { %
1748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1749 % General strategy:
1750 %
1751 % Ordinary situation: author or editor-acting-as-author
1752 % available.
1753 % => Make tentative "short cite with initials" author
1754 % label (L1) of one of the forms
1755 % "Last1 F1"
1756 % "Last1 F1 Last2"
1757 % "Last1 F1 zzzz" ("zzzz" representing et al.)
1758 % => If more than 2 'authors': make label (L2) for 2nd-6th authors
1759 % of one of the forms
1760 % "Last2 Last3"
1761 % "Last2 Last3 Last4"
1762 % "Last2 Last3 Last4 Last5"
1763 % "Last2 Last3 Last4 Last5 Last6"
1764 % "Last2 Last3 Last4 Last5 Last6 zzzz"
1765 % When key is available (overrules author and editor fields):
1766 % => L1 = key, L2 = ""
1767 % No author, editor, and key: define title or substitute as key
1768 % and format as key.
1769 %
1770 % Then format year label (L3) of one of the forms:
1771 % "0000" (missing year or explicit 'no date')
1772 % "9999" ('in press')
1773 % year (otherwise; don't use originalyear here yet)
1774 %
1775 % From earlier sorting of titles, we have title number. Convert
1776 % to string, which gives title label (L4) .
1777 %
1778 % Then tentative sorting label (author.year.sort.label) is a
1779 % concatenation of
1780 % L1
1781 % " "
1782 % L3
1783 % " "
1784 % L2
1785 % " "
1786 % L4
1787 %
1788 % This can then be sorted, from which it can be derived
1789 % whether initials are necessary, how many names must
1790 % be used for short and full citations, and whether "a"'s and
1791 % "b"'s etc. are necessary behind the year labels.
1792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1793 %
1794 % key and firstkey overrule author information
1795 %
1796 firstkey empty$ not
1797 { key empty$ not
1798 { %
1799 % Both key and firstkey available:
1800 % for sorting and checking initials, treat key as last
1801 % name and firstkey as initials.
1802 %
1803 key sortify remove.spaces
1804 " " *
1805 firstkey sortify remove.spaces *
1806 make.field.year.sort.label
1807 }
1808 { firstkey sortify remove.spaces make.field.year.sort.label }
1809 if$
1810 }
1811 { key empty$ not
1812 { key sortify remove.spaces make.field.year.sort.label }
1813 { %
1814 % No key or firstkey, so find out which field
1815 % to use as author.
1816 %
1817 % Check reference type:
1818 % if result is 1 then possibly editor acts as author
1819 % 2 then editor does not act as author
1820 % 3 then key should have been used
1821 % 0 then unknown reference type
1822 ref.type
1823 duplicate$ #1 =
1824 { pop$
1825 make.author.editor.sort.label
1826 }
1827 { duplicate$ #2 =
1828 { pop$
1829 make.author.sort.label
1830 }
1831 { #3 =
1832 { "no key in " cite$ * warning$
1833 make.author.editor.sort.label
1834 }
1835 { make.author.editor.sort.label }
1836 if$
1837 }
1838 if$
1839 }
1840 if$
1841 }
1842 if$
1843 }
1844 if$
1845 %
1846 author.year.sort.label 'sort.key$ :=
1847 }
1848
1849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1850
1851 FUNCTION {make.definitive.name.sort.label}
1852 { %
1853 % Author or editor-acting-as-author available.
1854 % => Make author-with-initials label (L1) of one of the forms
1855 % "Last1 F1 Last2 F2 ... LastN FN"
1856 % "Last1 F1 Last2 F2 ... Last6 F6 zzzz"
1857 % (where N <= 6 is the total number of authors, and
1858 % "zzzz" represents et al. if there are more than 6 authors)
1859 % No author, editor, and key: define title or substitute as sort key.
1860 %
1861 % The name field is on top of the stack.
1862 'field :=
1863 %
1864 % numnames is the total number of names contained in field
1865 field num.names$ 'numnames :=
1866 %
1867 % If there are more than 6 authors, only 6 are mentioned.
1868 numnames name.max >
1869 { name.max 'format.num.names := }
1870 { numnames 'format.num.names := }
1871 if$
1872 % Initialize stack with empty string
1873 ""
1874 %
1875 % Cycle over authors.
1876 #1 'nameptr :=
1877 { nameptr format.num.names < }
1878 { % Format author and add spaces
1879 field nameptr sort.name.format format.name$ *
1880 " " *
1881 nameptr #1 + 'nameptr :=
1882 }
1883 while$
1884 % Format last author that must be formatted
1885 field nameptr sort.name.format format.name$ *
1886 % Add et al. if necessary
1887 nameptr numnames <
1888 { " zzzz" * }
1889 'skip$
1890 if$
1891 sortify % Clean up and change case
1892 " " * % Add spaces
1893 year.label * % Add year
1894 " " * % Add spaces
1895 title.number conv.int.to.str * % Add sorted title number
1896 " " * % Add spaces
1897 month.number.day * % Add month and day when available
1898 'author.year.sort.label := % Assign result to sort label.
1899 }
1900
1901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1902
1903 FUNCTION {make.definitive.field.year.sort.label}
1904 { %
1905 % 'field' acts as author (L1).
1906 %
1907 % Then format year label (L2) of one of the forms:
1908 % "0000" (missing year or explicit `no date')
1909 % "9999" (`in press')
1910 % year (otherwise; don't use originalyear here yet)
1911 %
1912 % From earlier sorting of titles, we have title number. Convert
1913 % to string, which gives title label (L3) .
1914 %
1915 % Then tentative sorting label (author.year.sort.label) is a
1916 % concatenation of
1917 % L1
1918 % " "
1919 % L2
1920 % " "
1921 % L3
1922 %
1923 % 'field' is on top of the stack. It is already supposed to be cleaned
1924 % (i.e., sortified and space-removed), so this is already L1.
1925 " " * % Add spaces
1926 year.label * % Add year
1927 " " * % Add spaces
1928 title.number conv.int.to.str * % Add sorted title number
1929 " " * % Add spaces
1930 month.number.day * % Add month and day when available
1931 'author.year.sort.label := % Assign result to sort label.
1932 }
1933
1934 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1935
1936 FUNCTION {make.definitive.author.editor.sort.label}
1937 { author empty$
1938 { editor empty$
1939 { %
1940 % Use what has previously been stored in title.sort.label
1941 % as author substitute .
1942 title.sort.label make.definitive.field.year.sort.label
1943 }
1944 { editor make.definitive.name.sort.label }
1945 if$
1946 }
1947 { author make.definitive.name.sort.label }
1948 if$
1949 }
1950
1951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1952
1953 FUNCTION {make.definitive.author.sort.label}
1954 { author empty$
1955 { %
1956 % Use what has previously been stored in title.sort.label
1957 % as author substitute .
1958 title.sort.label make.definitive.field.year.sort.label
1959 }
1960 { author make.definitive.name.sort.label }
1961 if$
1962 }
1963 FUNCTION {make.final.sort.key}
1964 { ref.type #2 =
1965 { make.definitive.author.sort.label }
1966 { make.definitive.author.editor.sort.label }
1967 if$
1968 unsorted
1969 { citeorder.sort.label 'sort.key$ := }
1970 { author.year.sort.label 'sort.key$ := }
1971 if$
1972 }
1973
1974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1976
1977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1978
1979 FUNCTION {chop.word}
1980 { 's :=
1981 'len :=
1982 s #1 len substring$ =
1983 { s len #1 + global.max$ substring$ }
1984 { s }
1985 if$
1986 }
1987
1988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1989
1990 FUNCTION {chop.articles}
1991 { 's :=
1992 "a " #2
1993 "an " #3
1994 "the " #4
1995 s
1996 chop.word
1997 chop.word
1998 chop.word
1999 }
2000
2001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2002
2003 FUNCTION {format.sort.title}
2004 { %
2005 % Remove non-alphanumeric characters and change to lower case .
2006 sortify
2007 %
2008 % Remove "a ", "an ", and "the " from the front .
2009 chop.articles #1 entry.max$ substring$
2010 }
2011
2012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2013
2014 FUNCTION {make.sort.title}
2015 { title empty$
2016 { text empty$
2017 { type empty$
2018 { howpublished empty$
2019 { note empty$
2020 { url empty$
2021 { " " }
2022 { url format.sort.title }
2023 if$
2024 }
2025 { note format.sort.title }
2026 if$
2027 }
2028 { howpublished format.sort.title }
2029 if$
2030 }
2031 { type format.sort.title }
2032 if$
2033 }
2034 { text format.sort.title }
2035 if$
2036 }
2037 { title format.sort.title }
2038 if$
2039 remove.spaces
2040 'title.sort.label :=
2041 title.sort.label 'sort.key$ :=
2042 }
2043 FUNCTION {make.title.number}
2044 { title.sort.label old.label =
2045 {
2046 old.number 'title.number :=
2047 }
2048 {
2049 old.number #1 + 'title.number :=
2050 title.number 'old.number :=
2051 title.sort.label 'old.label :=
2052 }
2053 if$
2054 }
2055 FUNCTION {make.citeorder.number}
2056 { old.number #1 + 'cite.order :=
2057 cite.order 'old.number :=
2058 cite.order conv.int.to.str 'citeorder.sort.label :=
2059 }
2060
2061 FUNCTION {last.part.name.format.classic} { "{ll}" }
2062
2063 FUNCTION {von.junior.name.format.classic} { "{ vv}{, jj}" }
2064
2065 FUNCTION {last.part.name.format} { "{vv }{ll}" }
2066
2067 FUNCTION {initials.with.space.name.format} { "{f.}" }
2068
2069 FUNCTION {von.last.junior.name.format} { "{vv }{ll}{ jj}" }
2070
2071 FUNCTION {von.junior.name.format} { "{, jj}" }
2072
2073 FUNCTION {one.complete.name.format} { "{vv }{ll}{, jj}{, ff}" }
2074
2075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2076
2077 FUNCTION {string.length}
2078 { #0 'pos :=
2079 % If the next character exists, i.e., is not empty,
2080 % add 1 to the string length.
2081 % We cannot use empty$ because " " empty$ is true.
2082 { duplicate$ pos #1 + #1 substring$ "" = not }
2083 { pos #1 + 'pos := }
2084 while$
2085 pop$ pos
2086 }
2087
2088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2089
2090 FUNCTION {transform.spaces.and.hyphens}
2091 { 's := % The original string
2092 s string.length 'len := % Its length (no. of characters)
2093 "" 't := % Initialize the transformed string
2094 #1 'pos :=
2095 #0 'brace.level :=
2096 %
2097 % while (pos < len) do
2098 %
2099 { pos len < }
2100 { % First, check whether we are at brace level 0
2101 brace.level #0 =
2102 {
2103 % At least two characters left: check for ". ", ".~", and ".-".
2104 % If so, replace and shift two positions.
2105 s pos #2 substring$ ". " =
2106 s pos #2 substring$ ".~" = or
2107 { t "\BPBI " * 't :=
2108 pos #2 + 'pos :=
2109 }
2110 { s pos #2 substring$ ".-" =
2111 { t "\BHBI " * 't :=
2112 pos #2 + 'pos :=
2113 }
2114 { % neither is true, copy one character and shift one position
2115 t s pos #1 substring$ * 't :=
2116 % Check whether we need to increase brace level.
2117 % Note that this is not sophisticated: it does not capture
2118 % \{, \verb+}+, etc.
2119 % Note also that unbalanced braces cause problems.
2120 s pos #1 substring$ "{" =
2121 { brace.level #1 + 'brace.level := }
2122 'skip$
2123 if$
2124 pos #1 + 'pos :=
2125 }
2126 if$
2127 }
2128 if$
2129 }
2130 { % Not at brace level 0: copy result literally
2131 t s pos #1 substring$ * 't :=
2132 % Check whether we need to increase or decrease brace level.
2133 % Note that this is not sophisticated: it does not capture
2134 % \{, \verb+}+, etc.
2135 s pos #1 substring$ "{" =
2136 { brace.level #1 + 'brace.level := }
2137 { s pos #1 substring$ "}" =
2138 { brace.level #1 - 'brace.level := }
2139 'skip$
2140 if$
2141 }
2142 if$
2143 pos #1 + 'pos :=
2144 }
2145 if$
2146 }
2147 while$
2148 %
2149 pos len =
2150 { % Last character, copy
2151 t s pos #1 substring$ * 't :=
2152 }
2153 { % pos = len + 1, so s ends with ". " or ".-"
2154 % This should not have happened, but make the best out of it.
2155 % Push last two characters of s on the stack, i.e., ". " or ".-".
2156 s len #1 - #2 substring$
2157 % Remove "\BPBI " or "\BHBI " from t
2158 t text.length$ 'len := % Length of t (no. of characters)
2159 t #1 len #6 - substring$
2160 % Concatenate and assign to t
2161 swap$ * 't :=
2162 }
2163 if$
2164 %
2165 % Now push the result back on the stack
2166 t
2167 }
2168
2169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2170
2171 FUNCTION {format.initials.with.hyphen}
2172 { % Format initials.
2173 % Call with
2174 % field authornumber format.initials.with.hyphen
2175 % e.g.
2176 % author #1 format.initials.with.hyphen
2177 % Instead of field, a string may also be used.
2178 %
2179 % First, format initials in the default way, retaining spaces
2180 % and hyphens.
2181 initials.with.space.name.format format.name$
2182 transform.spaces.and.hyphens
2183 }
2184
2185 FUNCTION {format.last.part.name}
2186 { % Format a name with last.part.name.format,
2187 % as part of more complicated things.
2188 % Call with
2189 % field authornumber format.last.part.name
2190 % e.g.
2191 % author #1 format.last.part.name
2192 % Instead of field, a string may also be used.
2193 last.part.name.format format.name$
2194 }
2195
2196 FUNCTION {format.von.last.junior.name}
2197 { % Format a name with von.last.junior.name.format,
2198 % for citing or as part of more complicated things.
2199 % Call with
2200 % field authornumber format.von.last.junior.name
2201 % e.g.
2202 % author #1 format.von.last.junior.name
2203 % Instead of field, a string may also be used.
2204 von.last.junior.name.format format.name$
2205 }
2206
2207 FUNCTION {format.von.junior.name}
2208 { % Format a name with von.last.junior.name.format,
2209 % for citing or as part of more complicated things.
2210 % Call with
2211 % field authornumber format.von.junior.name
2212 % e.g.
2213 % author #1 format.von.junior.name
2214 % Instead of field, a string may also be used.
2215 von.junior.name.format format.name$
2216 }
2217
2218 FUNCTION {format.cite.initials.name}
2219 { % Format a name for citing with initials.
2220 % Call with
2221 % field authornumber format.cite.initials.name
2222 % e.g.
2223 % author #1 format.cite.initials.name
2224 % Instead of field, a string may also be used.
2225 %
2226 % First, extract the complete name, format it in the canonical form,
2227 % and push on the stack.
2228 one.complete.name.format format.name$
2229 %
2230 % Format the initials and push on the stack.
2231 duplicate$ #1 format.initials.with.hyphen
2232 %
2233 % Format the von-last-junior part and push on the stack.
2234 swap$ #1 format.von.last.junior.name
2235 %
2236 % Connect with "~" hyphen (if they're both non-empty).
2237 "~" connect.check
2238 }
2239
2240 FUNCTION {format.author.name}
2241 { % Format an author name for the reference list.
2242 % Call with
2243 % field authornumber format.author.name
2244 % e.g.
2245 % author #1 format.author.name
2246 % Instead of field, a string may also be used.
2247 %
2248 % First, extract the complete name, format it in the canonical form,
2249 % and push on the stack.
2250 one.complete.name.format format.name$
2251 %
2252 % Make two copies of the name, format the last name and push on the stack.
2253 duplicate$ duplicate$ #1 format.last.part.name
2254 %
2255 % Format the initials and push on the stack.
2256 swap$ #1 format.initials.with.hyphen
2257 %
2258 % Connect with last name.
2259 connect.with.comma.check
2260 %
2261 % Format the von-junior part and connect with initials.
2262 swap$ #1 format.von.junior.name "" connect.check
2263 }
2264
2265 FUNCTION {format.editor.name}
2266 { % Format a name for the reference list as an editor.
2267 % Call with
2268 % field authornumber format.editor.name
2269 % e.g.
2270 % author #1 format.editor.name
2271 % Instead of field, a string may also be used.
2272 %
2273 format.cite.initials.name
2274 }
2275
2276 FUNCTION {format.index.name}
2277 { % Format an author name for the index.
2278 % Call with
2279 % field authornumber format.index.name
2280 % e.g.
2281 % author #1 format.index.name
2282 % Instead of field, a string may also be used.
2283 %
2284 format.author.name
2285 }
2286
2287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2289 FUNCTION {comma.between.two} { "\BCBT {}" }
2290
2291 FUNCTION {comma.between.names} { ", " }
2292
2293 FUNCTION {comma.before.last} { "\BCBL {}" }
2294
2295 FUNCTION {dots.before.last} { "\BDBL {}" }
2296
2297 FUNCTION {and.before.last} { "\ \BBA {} " }
2298
2299 FUNCTION {et.al.string.cite} { "\ \protect \BOthers {.}" }
2300
2301 FUNCTION {et.al.string} { "\ \BOthers {.}" }
2302
2303 FUNCTION {et.al.string.period} { "\ \BOthersPeriod {.}" }
2304
2305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2306
2307 FUNCTION {add.name.index}
2308 { %
2309 %
2310 make.index
2311 { "%" * write$ newline$
2312 % Check for corporate author
2313 field is.bibcorporate
2314 { "\corporateAX{" }
2315 { "\AX{" }
2316 if$
2317 write$
2318 field nameptr sort.name.format format.name$ sortify write$ newline$
2319 "@" write$
2320 field nameptr format.index.name
2321 "}%" * write$ newline$
2322 }
2323 { "%" * write$ newline$ }
2324 if$
2325 }
2326
2327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2328
2329 FUNCTION {make.name.cite.label}
2330 { 'field :=
2331 'format.num.names :=
2332 %
2333 field num.names$ 'numnames := % numnames is the total number of names
2334 % contained in field
2335 %
2336 % It is implicit in the APA manual that if "et al." would refer
2337 % to exactly one author, then this author should be named
2338 % instead of "et al."
2339 %
2340 format.num.names numnames #1 - =
2341 { numnames 'format.num.names := }
2342 'skip$
2343 if$
2344 %
2345 % Format first author: with or without initials
2346 %
2347 #1 'nameptr :=
2348 cite.initials #1 =
2349 { field nameptr format.cite.initials.name }
2350 { field nameptr cite.name.format format.name$ }
2351 if$
2352 add.name.index % Add index entry when desired.
2353 %
2354 numnames #1 =
2355 'skip$
2356 { format.num.names #1 =
2357 { %
2358 % First author et al.
2359 %
2360 et.al.string.cite write$
2361 }
2362 { numnames #2 =
2363 { %
2364 % Given that format.num.names > 1, it is 2.
2365 % Format second author.
2366 %
2367 #2 'nameptr :=
2368 field nameptr cite.name.format format.name$ 's :=
2369 %
2370 % Check if 2nd author is explicit "others".
2371 % If so, insert "et al." string.
2372 %
2373 s "others" =
2374 { et.al.string.cite write$ } % First et al.
2375 { %
2376 % First \& Second
2377 %
2378 and.before.last write$
2379 s
2380 add.name.index % Add index entry when desired.
2381 }
2382 if$
2383 }
2384 { %
2385 % 3 or more names, 2 or more must be cited
2386 %
2387 % for nameptr := 2 to format.num.names - 1 do
2388 %
2389 #2 'nameptr :=
2390 { nameptr format.num.names < }
2391 { %
2392 % Put comma between consecutive authors
2393 %
2394 comma.between.names write$
2395 %
2396 % Format and add next author
2397 %
2398 field nameptr cite.name.format format.name$
2399 add.name.index % Add index entry when desired.
2400 %
2401 % Move to next author
2402 %
2403 nameptr #1 + 'nameptr :=
2404 }
2405 while$
2406 %
2407 % nameptr = format.num.names
2408 % Format this author.
2409 %
2410 field nameptr cite.name.format format.name$ 's :=
2411 %
2412 format.num.names numnames =
2413 { %
2414 % This is also the last author. Add (optional) comma.
2415 %
2416 comma.before.last write$
2417 %
2418 % Check if this author is explicit "others".
2419 % If so, insert "et al." string.
2420 %
2421 s "others" =
2422 { et.al.string.cite write$ }
2423 { and.before.last write$
2424 s
2425 add.name.index % Add index entry when desired.
2426 }
2427 if$
2428 }
2429 { %
2430 % This is not the last author.
2431 % Add comma, author name, and "et al."
2432 %
2433 comma.between.names write$
2434 s
2435 add.name.index % Add index entry when desired.
2436 %
2437 comma.before.last et.al.string.cite * write$
2438 }
2439 if$
2440 }
2441 if$
2442 }
2443 if$
2444 }
2445 if$
2446 }
2447
2448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2449
2450 FUNCTION {make.title.cite.label}
2451 { %
2452 % Formatting: check if formatted as article title or
2453 % as book title, and insert this formatting.
2454 %
2455 is.atype
2456 { "\APACciteatitle {" }
2457 { "\APACcitebtitle {" }
2458 if$
2459 %
2460 title empty$
2461 { text empty$
2462 { type empty$
2463 { howpublished empty$
2464 { note empty$
2465 { url empty$
2466 { cite$ }
2467 { url }
2468 if$
2469 }
2470 { note }
2471 if$
2472 }
2473 { howpublished }
2474 if$
2475 }
2476 { type }
2477 if$
2478 }
2479 { text }
2480 if$
2481 }
2482 { title }
2483 if$
2484 %
2485 % Connect with formatting.
2486 %
2487 * "}" *
2488 %
2489 % Write to output
2490 %
2491 write$
2492 }
2493
2494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2495
2496 FUNCTION {make.author.editor.cite.label}
2497 { author empty$
2498 { editor empty$
2499 { %
2500 % No author or editor:
2501 % Use title or other description as citation label.
2502 %
2503 make.title.cite.label
2504 "}{%" write$ newline$
2505 make.title.cite.label
2506 }
2507 { cite.num.names.full editor make.name.cite.label
2508 "}{%" write$ newline$
2509 cite.num.names.short editor make.name.cite.label
2510 }
2511 if$
2512 }
2513 { cite.num.names.full author make.name.cite.label
2514 "}{%" write$ newline$
2515 cite.num.names.short author make.name.cite.label
2516 }
2517 if$
2518 }
2519
2520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2521
2522 FUNCTION {make.author.cite.label}
2523 { author empty$
2524 { %
2525 % No author:
2526 % Use title or other description as citation label.
2527 %
2528 make.title.cite.label
2529 "}{%" write$ newline$
2530 make.title.cite.label
2531 }
2532 { cite.num.names.full author make.name.cite.label
2533 "}{%" write$ newline$
2534 cite.num.names.short author make.name.cite.label
2535 }
2536 if$
2537 }
2538
2539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2540
2541 FUNCTION {make.definitive.year.supplement}
2542 { %
2543 % Add "a", "b", etc. when necessary.
2544 %
2545 add.to.year #0 =
2546 { "" }
2547 { "{\protect "
2548 year empty$
2549 { "\BCntND " * }
2550 { year "\bibnodate" =
2551 year "l" change.case$ "no date" = or
2552 year "l" change.case$ "n.d." = or
2553 { "\BCntND " * }
2554 { year "\BIP" =
2555 year "l" change.case$ "in press" = or
2556 year "l" change.case$ "forthcoming" = or
2557 { "\BCntIP " * }
2558 { "\BCnt " * }
2559 if$
2560 }
2561 if$
2562 }
2563 if$
2564 "{" * add.to.year int.to.str$ * "}}" *
2565 }
2566 if$
2567 }
2568
2569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2570
2571 FUNCTION {protect.year}
2572 { year empty$
2573 { "{\protect \bibnodate {}}" }
2574 { year "\bibnodate" =
2575 year "l" change.case$ "no date" = or
2576 year "l" change.case$ "n.d." = or
2577 { "{\protect \bibnodate {}}" }
2578 { year "\BIP" =
2579 year "l" change.case$ "in press" = or
2580 year "l" change.case$ "forthcoming" = or
2581 { "{\protect \BIP {}}" }
2582 { year }
2583 if$
2584 }
2585 if$
2586 }
2587 if$
2588 }
2589
2590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2591
2592 FUNCTION {make.definitive.year.label}
2593 { "{\protect \APACyear {"
2594 originalyear empty$
2595 { protect.year }
2596 { originalyear "\bibnodate" = % date of original publication unknown
2597 originalyear "l" change.case$ "no date" = or
2598 originalyear "l" change.case$ "n.d." = or
2599 { translator empty$
2600 { protect.year }
2601 { "{\protect \BTRANSL {}}~" protect.year * }
2602 if$
2603 }
2604 { year empty$
2605 { originalyear "/{\protect \bibnodate {}}" * } % 1923/n.d.
2606 { originalyear year =
2607 { protect.year }
2608 { originalyear "/" * protect.year * } % 1923/1961
2609 if$
2610 }
2611 if$
2612 }
2613 if$
2614 }
2615 if$
2616 * "}}%" * write$ newline$
2617 %
2618 % Add "a", "b", etc. when necessary.
2619 %
2620 "{\protect \APACexlab {" "}}"
2621 make.definitive.year.supplement enclose.check
2622 }
2623
2624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2625
2626 FUNCTION {make.cite.labels}
2627 { newline$
2628 %
2629 % Write a few lines for testing purposes.
2630 %
2631 test
2632 { "\bibitem [] {} \fullciteA {" cite$ * "}" * write$ newline$
2633 "\bibitem [] {} \citeA {" cite$ * "}" * write$ newline$
2634 }
2635 'skip$
2636 if$
2637 %
2638 "\bibitem [\protect \citeauthoryear {%" write$ newline$
2639 %
2640 % When key or firstkey is available, this takes precedence.
2641 %
2642 firstkey empty$ not
2643 { %
2644 % Full cite: firstkey.
2645 %
2646 firstkey write$
2647 "}{%" write$ newline$
2648 %
2649 % Short cite: if key is not empty and cite.initials is 0,
2650 % then key, else firstkey.
2651 %
2652 cite.initials #0 =
2653 key empty$ not
2654 and
2655 { key }
2656 { firstkey }
2657 if$
2658 write$
2659 }
2660 { key empty$ not
2661 { %
2662 % No firstkey, but key available:
2663 % Both full and short labels are key.
2664 %
2665 key write$
2666 "}{%" write$ newline$
2667 key write$
2668 }
2669 { % No key or firstkey, so find out which field
2670 % to use as author.
2671 %
2672 % Check reference type:
2673 % if result is 1 then possibly editor acts as author
2674 % 2 then editor does not act as author
2675 % 3 then key should have been used
2676 % 0 then unknown reference type
2677 ref.type #2 =
2678 { make.author.cite.label }
2679 { make.author.editor.cite.label }
2680 if$
2681 }
2682 if$
2683 }
2684 if$
2685 "}{%" write$ newline$
2686 %
2687 % Make year label that's used for citations
2688 %
2689 make.definitive.year.label write$
2690 "}]{%" write$ newline$
2691 cite$ write$
2692 "} " write$ newline$
2693 % author.year.sort.label write$ newline$ % for testing purposes
2694 % year.label write$ newline$ % for testing purposes
2695 %
2696 % If the item is used in a meta-analysis, indicate this with
2697 % a star.
2698 %
2699 "\APACinsertmetastar {%" write$ newline$
2700 cite$ write$
2701 "}%" write$ newline$
2702 }
2703
2704 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2706
2707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2708
2709 FUNCTION {editor.postfix}
2710 { editor num.names$ #1 >
2711 { "(\BEDS)" }
2712 { "(\BED)" }
2713 if$
2714 }
2715
2716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2717
2718 FUNCTION {editor.trans.postfix}
2719 { editor num.names$ #1 >
2720 { "(\BEDS{} \BAnd{} \BTRANSS)" }
2721 { "(\BED{} \BAnd{} \BTRANS)" }
2722 if$
2723 }
2724
2725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2726 %
2727 % "(Trans.)" postfix
2728 % translator must not be empty
2729 %
2730 FUNCTION {trans.postfix}
2731 { translator num.names$ #1 >
2732 { "(\BTRANSS)" }
2733 { "(\BTRANS)" }
2734 if$
2735 }
2736
2737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2738
2739 FUNCTION {authors.editors.reflist.apa5}
2740 { 'field :=
2741 'dot :=
2742 %
2743 field num.names$ 'numnames := % numnames is the total number of names
2744 % contained in field
2745 numnames 'format.num.names := % Format all authors
2746 format.num.names name.max > % Unless this exceeds the maximum of 6.
2747 { dot
2748 { name.max 'format.num.names := } % Format 6 authors
2749 { cite.num.names.full 'format.num.names := } % Format 1 editor
2750 if$
2751 }
2752 'skip$
2753 if$
2754 %
2755 % Enclose authors in APACrefauthors environment to allow crude style
2756 % options in \LaTeX.
2757 "\begin{APACrefauthors}%"
2758 write$ newline$
2759 %
2760 % It is kind of explicit in the APA manual that if "et al." would
2761 % refer to exactly one author (the 7th), then this author should
2762 % still be replaced by "et al.", unlike with citations.
2763 % So format.num.names is not adapted.
2764 %
2765 % Format first author
2766 %
2767 #1 'nameptr :=
2768 field nameptr format.author.name
2769 %
2770 % Add period if required and if this is the only author.
2771 %
2772 numnames #1 =
2773 dot
2774 and
2775 { add.period$ }
2776 'skip$
2777 if$
2778 add.name.index % Add index entry when desired.
2779 %
2780 numnames #1 =
2781 'skip$
2782 { format.num.names #1 =
2783 { %
2784 % First author et al.
2785 %
2786 comma.between.two
2787 %
2788 % Add period if required.
2789 %
2790 dot
2791 { et.al.string.period * }
2792 { et.al.string * }
2793 if$
2794 write$
2795 }
2796 { numnames #2 =
2797 { %
2798 % Given that format.num.names > 1, it is 2.
2799 %
2800 comma.between.two write$
2801 %
2802 % Format second author.
2803 %
2804 #2 'nameptr :=
2805 field nameptr format.author.name 's :=
2806 %
2807 % Check if 2nd author is explicit "others".
2808 % If so, insert "et al." string.
2809 %
2810 s "others" =
2811 { %
2812 % First et al.
2813 % Add period if required.
2814 %
2815 dot
2816 { et.al.string.period }
2817 { et.al.string }
2818 if$
2819 write$
2820 }
2821 { %
2822 % First \& Second
2823 %
2824 and.before.last write$
2825 %
2826 % Add period if required.
2827 %
2828 dot
2829 { s add.period$ }
2830 { s }
2831 if$
2832 add.name.index % Add index entry when desired.
2833 }
2834 if$
2835 }
2836 { %
2837 % 3 or more names, 2 or more must be cited
2838 %
2839 % for nameptr := 2 to format.num.names - 1 do
2840 %
2841 #2 'nameptr :=
2842 { nameptr format.num.names < }
2843 { %
2844 % Put comma between consecutive authors
2845 %
2846 comma.between.names write$
2847 %
2848 % Format and add next author
2849 %
2850 field nameptr format.author.name
2851 add.name.index % Add index entry when desired.
2852 %
2853 % Move to next author
2854 %
2855 nameptr #1 + 'nameptr :=
2856 }
2857 while$
2858 %
2859 % nameptr = format.num.names
2860 % Format this author.
2861 %
2862 field nameptr format.author.name 's :=
2863 %
2864 format.num.names numnames =
2865 { %
2866 % This is also the last author. Add (optional) comma.
2867 %
2868 comma.before.last write$
2869 %
2870 % Check if this author is explicit "others".
2871 % If so, insert "et al." string.
2872 %
2873 s "others" =
2874 { %
2875 % Add period if required.
2876 %
2877 dot
2878 { et.al.string.period }
2879 { et.al.string }
2880 if$
2881 write$
2882 }
2883 { and.before.last write$
2884 %
2885 % Add period if required.
2886 %
2887 dot
2888 { s add.period$ }
2889 { s }
2890 if$
2891 add.name.index % Add index entry when desired.
2892 }
2893 if$
2894 }
2895 { %
2896 % This is not the last author.
2897 % Add comma, author name, and "et al."
2898 %
2899 comma.between.names write$
2900 s
2901 add.name.index % Add index entry when desired.
2902 %
2903 comma.before.last
2904 %
2905 % Add period if required.
2906 %
2907 dot
2908 { et.al.string.period * }
2909 { et.al.string * }
2910 if$
2911 write$
2912 }
2913 if$
2914 }
2915 if$
2916 }
2917 if$
2918 }
2919 if$
2920 %
2921 % End APACrefauthors environment.
2922 "\end{APACrefauthors}%"
2923 write$ newline$
2924 }
2925
2926 FUNCTION {authors.reflist.apa6}
2927 { 'field :=
2928 'dot :=
2929 field num.names$ 'numnames :=
2930 numnames #7 >
2931 { #7 'format.num.names := }
2932 { numnames 'format.num.names := }
2933 if$
2934 "\begin{APACrefauthors}%"
2935 write$ newline$
2936 #1 'nameptr :=
2937 field nameptr format.author.name
2938 numnames #1 =
2939 { dot
2940 { add.period$ }
2941 'skip$
2942 if$
2943 add.name.index
2944 }
2945 { add.name.index
2946 numnames #2 =
2947 { comma.between.two write$
2948 #2 'nameptr :=
2949 field nameptr format.author.name 's :=
2950 s "others" =
2951 { "`others' not consistent with 6th ed. of the APA Manual"
2952 warning$
2953 dot
2954 { et.al.string.period }
2955 { et.al.string }
2956 if$
2957 write$ newline$
2958 }
2959 { and.before.last write$
2960 dot
2961 { s add.period$ }
2962 { s }
2963 if$
2964 add.name.index
2965 }
2966 if$
2967 }
2968 { %% for nameptr := 2 to format.num.names - 1 do
2969 #2 'nameptr :=
2970 { nameptr format.num.names < }
2971 { comma.between.names write$
2972 field nameptr format.author.name
2973 add.name.index
2974 nameptr #1 + 'nameptr :=
2975 }
2976 while$
2977 field numnames format.author.name 's :=
2978 format.num.names numnames =
2979 { comma.before.last write$
2980 s "others" =
2981 { "`others' not consistent with 6th ed. of the APA "
2982 "Manual" *
2983 warning$
2984 dot
2985 { et.al.string.period }
2986 { et.al.string }
2987 if$
2988 write$
2989 }
2990 { and.before.last write$
2991 dot
2992 { s add.period$ }
2993 { s }
2994 if$
2995 add.name.index
2996 }
2997 if$
2998 }
2999 { dots.before.last write$
3000 s
3001 add.name.index
3002 }
3003 if$
3004 }
3005 if$
3006 }
3007 if$
3008 "\end{APACrefauthors}%"
3009 write$ newline$
3010 }
3011
3012 FUNCTION {format.author.names}
3013 { 'field :=
3014 'dot :=
3015 dot
3016 { dot field authors.reflist.apa6 }
3017 { dot field authors.editors.reflist.apa5 }
3018 if$
3019 }
3020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3021
3022 FUNCTION {format.authors}
3023 { #1 author format.author.names }
3024
3025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3026
3027 FUNCTION {format.editors.as.authors}
3028 { #0 editor format.author.names
3029 "\ " editor.postfix * add.period$ write$ newline$
3030 }
3031
3032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3033
3034 FUNCTION {format.ed.trans.as.authors}
3035 { #0 editor format.author.names
3036 "\ " editor.trans.postfix * add.period$ write$ newline$
3037 }
3038
3039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3040
3041 FUNCTION {format.editor.names}
3042 { 'field :=
3043 %
3044 field num.names$ 'numnames := % numnames is the total number of names
3045 % contained in field
3046 numnames 'format.num.names := % Format all authors
3047 format.num.names name.max > % Unless this exceeds the maximum of 6.
3048 { #1 'format.num.names := } % Then it becomes 1 (First et al.)
3049 'skip$
3050 if$
3051 %
3052 % Format first editor
3053 %
3054 field #1 format.editor.name
3055 %
3056 numnames #1 =
3057 'skip$
3058 { format.num.names #1 =
3059 { et.al.string * } % First editor et al., no comma.
3060 { numnames #2 =
3061 { %
3062 % Given that format.num.names > 1, it is 2.
3063 % No comma. Format second editor.
3064 %
3065 field #2 format.editor.name 's :=
3066 %
3067 % Check if 2nd editor is explicit "others".
3068 % If so, insert "et al." string.
3069 %
3070 s "others" =
3071 { et.al.string * } % First et al.
3072 { and.before.last * s * } % First \& Second
3073 if$
3074 }
3075 { %
3076 % 3 or more names, 2 or more must be cited
3077 %
3078 % for nameptr := 2 to format.num.names - 1 do
3079 %
3080 #2 'nameptr :=
3081 { nameptr format.num.names < }
3082 { %
3083 % Put comma between consecutive editors
3084 %
3085 comma.between.names *
3086 %
3087 % Format and add next editor
3088 %
3089 field nameptr format.editor.name *
3090 %
3091 % Move to next editor
3092 %
3093 nameptr #1 + 'nameptr :=
3094 }
3095 while$
3096 %
3097 % nameptr = format.num.names
3098 % Format this editor.
3099 %
3100 field nameptr format.editor.name 's :=
3101 %
3102 format.num.names numnames =
3103 { %
3104 % This is also the last editor. Add (optional) comma.
3105 %
3106 comma.before.last *
3107 %
3108 % Check if this editor is explicit "others".
3109 % If so, insert "et al." string.
3110 %
3111 s "others" =
3112 { et.al.string * }
3113 { and.before.last * s * }
3114 if$
3115 }
3116 { %
3117 % This is not the last editor.
3118 % Add comma, editor name, and "et al."
3119 %
3120 comma.between.names * s *
3121 comma.before.last * et.al.string *
3122 }
3123 if$
3124 }
3125 if$
3126 }
3127 if$
3128 }
3129 if$
3130 }
3131
3132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3133 %
3134 % format editors in case editors do not act as authors
3135 % (such as reference to chapter in edited book)
3136 %
3137 % L. W. Poon (Ed.) (1 editor)
3138 % or
3139 % A. S. Gurman \& D. P. Kniskern (Eds.) (2 editors)
3140 % or
3141 % L. Poon, A. Jones, \& D. P. Smith (Eds.) (>2 editors)
3142 %
3143 % editor must not be empty
3144 %
3145 FUNCTION {format.editors.in.line}
3146 { editor format.editor.names
3147 editor.postfix connect.with.space.check
3148 }
3149
3150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3151 %
3152 % format editors in case editors are also translators
3153 % and do not act as authors
3154 % (such as reference to chapter in edited book
3155 % of translated articles)
3156 %
3157 % L. W. Poon (Ed. and Trans.) (1 editor)
3158 % or
3159 % A. S. Gurman \& D. P. Kniskern (Eds. and Trans.) (2 editors)
3160 % or
3161 % L. Poon, A. Jones, \& D. P. Smith (Eds. and Trans.) (>2 editors)
3162 %
3163 % editor must not be empty
3164 %
3165 FUNCTION {format.editors.trans.in.line}
3166 { editor format.editor.names
3167 editor.trans.postfix connect.with.space.check
3168 }
3169
3170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3171 %
3172 % format translators in case translators act as editors
3173 % (such as reference to chapter in translated book)
3174 %
3175 % L. W. Poon (Trans.) (1 translator)
3176 % or
3177 % A. S. Gurman \& D. P. Kniskern (Trans.) (2 translators)
3178 % or
3179 % L. Poon, A. Jones, \& D. P. Smith (Trans.) (>2 translators)
3180 %
3181 % translator must not be empty
3182 %
3183 FUNCTION {format.translators.in.line}
3184 { translator format.editor.names
3185 trans.postfix connect.with.space.check
3186 }
3187
3188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3189 %
3190 % format translators in case translator does not act as editor
3191 % (such as reference to translated book)
3192 %
3193 % L. Solotaroff, Trans.
3194 %
3195 FUNCTION {format.translators.in.paren.check}
3196 { translator empty$
3197 { "" }
3198 { translator format.editor.names
3199 translator num.names$ #1 >
3200 { ", \BTRANSS{}" * }
3201 { ", \BTRANS{}" * }
3202 if$
3203 }
3204 if$
3205 }
3206
3207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3208 %
3209 % format editors and translators in case neither act as editor
3210 % (such as reference to edited or translated book with a
3211 % a single author)
3212 %
3213 % L. Solotaroff, Ed.
3214 % L. Solotaroff, Ed. \& Trans.
3215 % L. Solotaroff, Trans.
3216 % L. Solotaroff, Ed. \& S. Prokofieff, Trans.
3217 %
3218 FUNCTION {format.editors.translators.in.paren.check}
3219 { editor empty$
3220 { translator empty$
3221 { "" }
3222 { translator format.editor.names
3223 translator num.names$ #1 >
3224 { ", \BTRANSS{}" * }
3225 { ", \BTRANS{}" * }
3226 if$
3227 }
3228 if$
3229 }
3230 { editor format.editor.names
3231 editor num.names$ #1 >
3232 { ", \BEDS{}" * }
3233 { ", \BED{}" * }
3234 if$
3235 translator empty$
3236 'skip$
3237 { editor translator =
3238 { editor num.names$ #1 >
3239 { " \BAnd{} \BTRANSS" * }
3240 { " \BAnd{} \BTRANS" * }
3241 if$
3242 }
3243 { " \BAnd{} " *
3244 translator format.editor.names *
3245 translator num.names$ #1 >
3246 { ", \BTRANSS{}" * }
3247 { ", \BTRANS{}" * }
3248 if$
3249 }
3250 if$
3251 }
3252 if$
3253 }
3254 if$
3255 }
3256
3257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3258 %
3259 % translator of article
3260 %
3261 FUNCTION {format.atrans.check}
3262 { format.translators.in.paren.check parenthesize.check }
3263
3264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3265 %
3266 % format "In editor (Ed.), "
3267 %
3268 FUNCTION {format.in.editors}
3269 { "\BIn{} "
3270 editor empty$
3271 'skip$
3272 { format.editors.in.line * ", " * }
3273 if$
3274 }
3275
3276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3277 %
3278 % format "In translator (Trans.),"
3279 %
3280 FUNCTION {format.in.trans}
3281 { "\BIn{} "
3282 translator empty$
3283 'skip$
3284 { format.translators.in.line * ", " * }
3285 if$
3286 }
3287
3288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3289 %
3290 % format "In editor (Ed. and Trans.)"
3291 % or "In editor (Ed.)" if editor not equal to translator
3292 %
3293 FUNCTION {format.in.editors.trans}
3294 { "\BIn{} "
3295 editor empty$
3296 { translator empty$
3297 'skip$
3298 { format.translators.in.line * ", " * }
3299 if$
3300 }
3301 { translator empty$
3302 { format.editors.in.line * }
3303 { editor translator =
3304 { format.editors.trans.in.line * }
3305 { format.editors.in.line * }
3306 if$
3307 }
3308 if$
3309 ", " *
3310 }
3311 if$
3312 }
3313
3314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3316
3317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3318
3319 FUNCTION {format.year.check}
3320 { "\APACrefYear{"
3321 protect.year *
3322 %
3323 % Add "a", "b", etc. when necessary.
3324 %
3325 make.definitive.year.supplement *
3326 "}" *
3327 }
3328
3329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3330
3331 FUNCTION {format.year.month.day.check}
3332 { "\APACrefYearMonthDay{"
3333 protect.year *
3334 %
3335 % Add "a", "b", etc. when necessary.
3336 %
3337 make.definitive.year.supplement *
3338 "}{" *
3339 %
3340 % Add month and day when present.
3341 %
3342 month empty$
3343 'skip$
3344 { month * }
3345 if$
3346 "}{" *
3347 day empty$
3348 'skip$
3349 { day * }
3350 if$
3351 "}" *
3352 }
3353
3354 FUNCTION {format.atitle.no.dot}
3355 { "{\BBOQ}" swap$
3356 "{\BBCQ}" swap$
3357 duplicate$ empty$
3358 'skip$
3359 { duplicate$
3360 % Two arguments: Title twice: (1) don't change case; (2) change case
3361 "\APACrefatitle {" swap$ * "} {" * swap$
3362 "t" change.case$
3363 * "}" *
3364 }
3365 if$
3366 enclose.check
3367 }
3368
3369 FUNCTION {format.atitle.dot}
3370 { "{\BBOQ}" swap$
3371 "{\BBCQ}" swap$
3372 duplicate$ empty$
3373 'skip$
3374 { duplicate$
3375 % Two arguments: Title twice: (1) don't change case; (2) change case
3376 "\APACrefatitle {" swap$ * "} {" * swap$
3377 "t" change.case$
3378 * "}" * add.period$
3379 }
3380 if$
3381 enclose.check
3382 }
3383
3384 FUNCTION {format.atitle.connect}
3385 { swap$
3386 duplicate$ empty$
3387 { pop$
3388 format.atitle.dot
3389 }
3390 { swap$
3391 format.atitle.no.dot
3392 swap$ connect.with.space.check
3393 add.period$
3394 }
3395 if$
3396 }
3397
3398 FUNCTION {format.btitle.no.dot}
3399 { duplicate$ empty$
3400 { pop$
3401 ""
3402 }
3403 { duplicate$
3404 % Two arguments: Title twice: (1) don't change case; (2) change case
3405 "\APACrefbtitle {" swap$ * "} {" * swap$
3406 "t" change.case$
3407 * "}" *
3408 }
3409 if$
3410 }
3411
3412 FUNCTION {format.btitle.dot}
3413 { duplicate$ empty$
3414 { pop$
3415 ""
3416 }
3417 { add.period$ format.btitle.no.dot }
3418 if$
3419 }
3420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3421 %
3422 % title of book and similar
3423 % field must be on top of stack
3424 % second element on stack must be connected:
3425 % if that is empty, then btitle.dot
3426 % else btitle.no.dot, connect, and add period
3427 %
3428 FUNCTION {format.btitle.connect}
3429 { swap$
3430 duplicate$ empty$
3431 { pop$
3432 format.btitle.dot
3433 }
3434 { swap$
3435 format.btitle.no.dot
3436 swap$ connect.with.space.check
3437 add.period$
3438 }
3439 if$
3440 }
3441
3442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3443 %
3444 % title of book and similar
3445 % field must be on top of stack
3446 % second element on stack must be connected
3447 %
3448 FUNCTION {format.btitle.connect.no.dot}
3449 { swap$
3450 duplicate$ empty$
3451 { pop$
3452 format.btitle.no.dot
3453 }
3454 { swap$
3455 format.btitle.no.dot
3456 swap$ connect.with.space.check
3457 }
3458 if$
3459 }
3460
3461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3462 %
3463 % format englishtitle (of nonenglish article, etc.)
3464 %
3465 FUNCTION {format.aetitle.check}
3466 { englishtitle empty$
3467 { "" }
3468 { % Two arguments: Title twice: (1) don't change case; (2) change case
3469 "\APACrefaetitle {" englishtitle * "} {" *
3470 englishtitle "t" change.case$ * "}" *
3471 }
3472 if$
3473 }
3474
3475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3476 %
3477 % format englishtitle (of nonenglish book, etc.)
3478 %
3479 FUNCTION {format.betitle.check}
3480 { englishtitle empty$
3481 { "" }
3482 { % Two arguments: Title twice: (1) don't change case; (2) change case
3483 "\APACrefbetitle {" englishtitle * "} {" *
3484 englishtitle "t" change.case$ * "}" *
3485 }
3486 if$
3487 }
3488
3489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3490 %
3491 % format type (of article, etc.)
3492 %
3493 FUNCTION {format.atype.check}
3494 { type bracket.check }
3495
3496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3497 %
3498 % format title and englishtitle (of article, etc.)
3499 %
3500 FUNCTION {format.atitle.check}
3501 { format.aetitle.check
3502 title format.atitle.connect
3503 }
3504
3505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3506 %
3507 % format title, englishtitle, and type
3508 % (of article, etc.)
3509 %
3510 FUNCTION {format.atitle.type.check}
3511 { format.aetitle.check
3512 format.atype.check connect.with.space.check
3513 title format.atitle.connect
3514 }
3515
3516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3517 %
3518 % format title, englishtitle,
3519 % and translator (of article, etc.)
3520 %
3521 FUNCTION {format.atitle.trans.check}
3522 { format.aetitle.check
3523 format.atrans.check connect.with.space.check
3524 title format.atitle.connect
3525 }
3526
3527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3528 %
3529 % format title, englishtitle, type,
3530 % and translator (of article, etc.)
3531 %
3532 FUNCTION {format.atitle.type.trans.check}
3533 { format.aetitle.check
3534 format.atype.check connect.with.space.check
3535 format.atrans.check connect.with.space.check
3536 title format.atitle.connect
3537 }
3538
3539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3541
3542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3543 %
3544 % format journal, volume, number and pages
3545 % call with
3546 % formatted.pages format.journal.vol.num.pages.check
3547 %
3548 FUNCTION { format.journal.vol.num.pages.check }
3549 { "journal" journal warning.if.empty
3550 duplicate$ empty$
3551 journal empty$ and
3552 volume empty$ and
3553 number empty$ and
3554 { pop$ "" }
3555 { "\APACjournalVolNumPages{" journal "" connect.check
3556 "}{" * volume "" connect.check
3557 "}{" * number "" connect.check
3558 "}{" * swap$ "" connect.check
3559 "}" *
3560 }
3561 if$
3562 }
3563
3564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3565 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3566
3567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3568 %
3569 % volume of book, checks whether
3570 % "Volume" or "Volumes"
3571 %
3572 % call with
3573 % field format.bvolume.check
3574 %
3575 FUNCTION {format.bvolume.check}
3576 { duplicate$ empty$
3577 'skip$
3578 { duplicate$ multi.result.check
3579 { "\BVOLS" swap$ tie.or.space.connect }
3580 { "\BVOL" swap$ tie.or.space.connect }
3581 if$
3582 }
3583 if$
3584 }
3585
3586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3587 %
3588 % edition of book, must not be empty
3589 % call with
3590 % field format.edition.check
3591 %
3592 FUNCTION {format.edition.check}
3593 { duplicate$ empty$
3594 'skip$
3595 { "\PrintOrdinal{" swap$ * "}" *
3596 "\BEd" connect.with.space.check
3597 }
3598 if$
3599 }
3600
3601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3602 %
3603 % volume and edition of book
3604 %
3605 FUNCTION {format.bvol.edition.check}
3606 { edition format.edition.check
3607 volume format.bvolume.check
3608 connect.with.comma.check
3609 }
3610
3611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3612 %
3613 % volume and edition of book
3614 %
3615 FUNCTION {format.bvol.edition}
3616 { format.bvol.edition.check
3617 parenthesize.check
3618 }
3619
3620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3621 %
3622 % volume and edition and translator of translated book
3623 %
3624 FUNCTION {format.bvol.edition.trans}
3625 { format.bvol.edition.check
3626 format.translators.in.paren.check connect.with.semicolon.check
3627 parenthesize.check
3628 }
3629
3630 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3631 %
3632 % volume, edition, editor, and translator of (translated) book
3633 %
3634 FUNCTION {format.bvol.edition.editor.trans}
3635 { format.bvol.edition.check
3636 format.editors.translators.in.paren.check connect.with.semicolon.check
3637 parenthesize.check
3638 }
3639
3640 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3641 %
3642 % formats pages by first checking if 1 or more pages
3643 % and prefixing pages with "p." or "pp." (these strings
3644 % are given in the commands \BPG and \BPGS, respectively),
3645 % whichever is applicable, and do a tie or space connect
3646 %
3647 % call with
3648 % field format.bpages.check
3649 %
3650 FUNCTION {format.bpages.check}
3651 { duplicate$ empty$
3652 'skip$
3653 { duplicate$ multi.result.check
3654 { "\BPGS" swap$ tie.or.space.connect }
3655 { "\BPG~" swap$ * }
3656 if$
3657 }
3658 if$
3659 }
3660
3661 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3662 %
3663 % formats chapters by first checking if 1 or more chapters
3664 % and prefixing pages with "chap." (this string
3665 % is given in the commands \BCHAP and \BCHAPS, respectively),
3666 % whichever is applicable, and do a tie or space connect
3667 %
3668 % call with
3669 % field format.bchapter.check
3670 %
3671 FUNCTION {format.bchapter.check}
3672 { duplicate$ empty$
3673 'skip$
3674 { duplicate$ multi.result.check
3675 { "\BCHAPS" swap$ tie.or.space.connect }
3676 { "\BCHAP" swap$ tie.or.space.connect }
3677 if$
3678 }
3679 if$
3680 }
3681
3682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3683 %
3684 % volume, edition, and pages or chapter of article in book etc.
3685 %
3686 FUNCTION {format.bvol.edition.pages}
3687 { format.bvol.edition.check
3688 pages empty$
3689 { chapter format.bchapter.check connect.with.comma.check }
3690 { pages format.bpages.check connect.with.comma.check }
3691 if$
3692 parenthesize.check
3693 }
3694
3695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3696 %
3697 % title, volume, edition of book
3698 %
3699 FUNCTION {format.btitle.vol.edition}
3700 { format.betitle.check
3701 format.bvol.edition connect.with.space.check
3702 title format.btitle.connect.no.dot
3703 }
3704
3705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3706 %
3707 % title, volume, edition, and translator of book
3708 %
3709 FUNCTION {format.btitle.vol.edition.trans}
3710 { format.betitle.check
3711 format.bvol.edition.trans connect.with.space.check
3712 title format.btitle.connect.no.dot
3713 }
3714
3715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3716 %
3717 % title, volume, edition, editor, and translator of book
3718 %
3719 FUNCTION {format.btitle.vol.edition.editor.trans}
3720 { format.betitle.check
3721 format.bvol.edition.editor.trans connect.with.space.check
3722 title format.btitle.connect.no.dot
3723 }
3724
3725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3726 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3727
3728 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3729 %
3730 % format address and publisher of book etc.
3731 %
3732 % New York: Wiley
3733 % or
3734 % Wiley (if address empty)
3735 % or
3736 % New York (if publisher empty)
3737 %
3738 FUNCTION {format.address.publisher}
3739 { %
3740 % If publisher = author or publisher = "author" or publisher = "Author"
3741 % then hand over the final choice how to format this to \LaTeX.
3742 % (I could imagine similar code for editors, but the APA manual does
3743 % not mention it and then we'd have to check whether the editor is in
3744 % the author position, so let's keep it simple until someone complains.)
3745 %
3746 author empty$
3747 publisher empty$ or
3748 { publisher "\APACaddressPublisher{" }
3749 { author publisher =
3750 "author" publisher = or
3751 "Author" publisher = or
3752 { author "\APACaddressPublisherEqAuth{" }
3753 { publisher "\APACaddressPublisher{" }
3754 if$
3755 }
3756 if$
3757 address "" connect.check "}{" *
3758 % Recover publisher that was pushed onto the stack previously.
3759 swap$ "" connect.check "}" *
3760 }
3761
3762 FUNCTION {format.address.publisher.check}
3763 { publisher empty$
3764 address empty$
3765 and
3766 'skip$
3767 {
3768 duplicate$ empty$
3769 'skip$
3770 { output.new.block }
3771 if$
3772 format.address.publisher
3773 }
3774 if$
3775 }
3776
3777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3779
3780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3781 %
3782 % format number as in reports: No. 2017
3783 % call with
3784 % field format.rnumber.check
3785 %
3786 FUNCTION {format.rnumber.check}
3787 { duplicate$ empty$
3788 'skip$
3789 { duplicate$ multi.result.check
3790 { "\BNUMS" swap$ tie.or.space.connect }
3791 { "\BNUM" swap$ tie.or.space.connect }
3792 if$
3793 }
3794 if$
3795 }
3796
3797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3798 %
3799 % format type and number of a standalone item
3800 % call with
3801 % format.type.number
3802 %
3803 FUNCTION { format.type.number }
3804 { type empty$
3805 { type.2 }
3806 { type }
3807 if$
3808 number empty$
3809 { bracket.check }
3810 { number format.rnumber.check connect.with.space.check
3811 parenthesize.check
3812 }
3813 if$
3814 }
3815
3816 FUNCTION {format.howpublished}
3817 { howpublished empty$
3818 'skip$
3819 { % clear the stack
3820 duplicate$ empty$
3821 'pop$
3822 { output.dot.new.block }
3823 if$
3824 "\APAChowpublished {" howpublished * "}" *
3825 }
3826 if$
3827 }
3828 FUNCTION {output.howpublished}
3829 { howpublished empty$
3830 'skip$
3831 { "\APAChowpublished {" howpublished * "}" *
3832 output.dot.new.block
3833 }
3834 if$
3835 }
3836 FUNCTION {howpublished.block}
3837 { howpublished empty$
3838 'skip$
3839 { start.new.block
3840 "\APAChowpublished {" howpublished * "}" *
3841 output.dot.end.block
3842 }
3843 if$
3844 }
3845 FUNCTION {begin.end.url.env}
3846 { "\begin{APACrefURL} "
3847 lastchecked empty$
3848 { urldate empty$
3849 'skip$
3850 { "[{" * urldate * "}]" * }
3851 if$
3852 }
3853 { "[{" * lastchecked * "}]" * }
3854 if$
3855 " \end{APACrefURL} "
3856 }
3857
3858 FUNCTION {begin.end.doi.env}
3859 { "\begin{APACrefDOI} "
3860 " \end{APACrefDOI} "
3861 }
3862
3863 FUNCTION {begin.end.msg.env}
3864 { "\begin{APACrefURLmsg} "
3865 " \end{APACrefURLmsg} "
3866 }
3867 FUNCTION {format.url}
3868 { type.2 empty$
3869 { begin.end.url.env }
3870 { type.2 "\bibmessage" =
3871 { begin.end.msg.env }
3872 { begin.end.url.env }
3873 if$
3874 }
3875 if$
3876 "\url{" url * "}" *
3877 enclose.check
3878 }
3879 FUNCTION {url.block}
3880 { doi empty$
3881 { url empty$
3882 'skip$
3883 { start.new.block
3884 format.url
3885 output.end.block
3886 }
3887 if$
3888 }
3889 'skip$
3890 if$
3891 }
3892 FUNCTION {format.doi}
3893 { begin.end.doi.env
3894 "\doi{" doi * "}" *
3895 enclose.check
3896 }
3897 FUNCTION {doi.block}
3898 { doi empty$
3899 'skip$
3900 { start.new.block
3901 format.doi
3902 output.end.block
3903 }
3904 if$
3905 }
3906 FUNCTION {format.note}
3907 { "\APACrefnote{" "}" note enclose.check }
3908 FUNCTION {note.block}
3909 { note empty$
3910 'skip$
3911 { start.new.block
3912 format.note
3913 output.end.block
3914 }
3915 if$
3916 }
3917
3918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3919 %
3920 % format original year of publication and note
3921 % (reprint or translation)
3922 %
3923 FUNCTION {format.orig.year.note}
3924 { originalyear empty$
3925 { format.note }
3926 { "\APACorigyearnote{"
3927 originalyear "" connect.check "}{" *
3928 note "" connect.check "}" *
3929 }
3930 if$
3931 }
3932
3933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3934 %
3935 % format original journal of publication and note
3936 % (reprint or translation)
3937 %
3938 FUNCTION {format.orig.journal.note}
3939 { "\APACorigjournalnote{"
3940 originalyear "" connect.check "}{" *
3941 originaljournal "" connect.check "}{" *
3942 originalvolume "" connect.check "}{" *
3943 originalnumber "" connect.check "}{" *
3944 originalpages "" connect.check "}{" *
3945 note "" connect.check "}" *
3946 }
3947
3948 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3949 %
3950 % format original book of publication and note
3951 % (reprint or translation)
3952 %
3953 FUNCTION {format.orig.book.note}
3954 { "\APACorigbooknote{" originalyear "" connect.check "}{" *
3955 %
3956 originaleditor empty$
3957 'skip$
3958 { originaleditor num.names$ #1 >
3959 { "\APACorigEDS {" * originaleditor format.editor.names * "}" * }
3960 { "\APACorigED {" * originaleditor format.editor.names * "}" * }
3961 if$
3962 }
3963 if$
3964 %
3965 "}{" *
3966 originalbooktitle format.btitle.no.dot "" connect.check "} {" *
3967 originaledition format.edition.check "" connect.check "} {" *
3968 originalvolume format.bvolume.check "" connect.check "} {" *
3969 originalpages format.bpages.check "" connect.check "} {" *
3970 originaladdress "" connect.check "} {" *
3971 originalpublisher "" connect.check "} {" *
3972 note "" connect.check "}" *
3973 }
3974
3975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3976 %
3977 % format information about original publication of reprint
3978 % and format optional note
3979 %
3980 FUNCTION {format.orig.note}
3981 { originaljournal empty$
3982 { originalbooktitle empty$
3983 { note empty$
3984 { originalyear empty$
3985 'skip$
3986 { originalyear "\bibnodate" =
3987 originalyear "l" change.case$ "no date" = or
3988 originalyear "l" change.case$ "n.d." = or
3989 'skip$
3990 { output.new.block
3991 format.orig.year.note
3992 }
3993 if$
3994 }
3995 if$
3996 }
3997 { output.new.block
3998 format.orig.year.note
3999 }
4000 if$
4001 }
4002 { output.new.block
4003 format.orig.book.note
4004 }
4005 if$
4006 }
4007 { output.new.block
4008 format.orig.journal.note
4009 }
4010 if$
4011 }
4012 FUNCTION {fin.entry}
4013 { doi empty$
4014 'skip$
4015 { output.new.block
4016 format.doi
4017 }
4018 if$
4019 output.end.block
4020 "\PrintBackRefs{\CurrentBib}" write$ newline$
4021 test
4022 { "\vspace{\baselineskip}" write$ newline$ }
4023 'skip$
4024 if$
4025 }
4026 FUNCTION {fin.entry.2}
4027 { doi.block
4028 "\PrintBackRefs{\CurrentBib}" write$ newline$
4029 test
4030 { "\vspace{\baselineskip}" write$ newline$ }
4031 'skip$
4032 if$
4033 }
4034 FUNCTION {periodical}
4035 {
4036 author empty$
4037 %
4038 % no author: possibly special issue with editors as authors
4039 % (APA manual, ex. 11, p. 121)
4040 %
4041 { editor empty$
4042 %
4043 % no author or editor: title serves as author.
4044 % title formatted as article title (APA manual not consistent in this,
4045 % compare statement on p. 119: ``treat as book title'' and
4046 % example 8, p. 121: no underlining => article title)
4047 %
4048 { format.atitle.type.trans.check output.new.block
4049 %
4050 % now formatted date on top of stack
4051 %
4052 output.dot.new.block
4053 }
4054 %
4055 % format editor and year, and check if year is present
4056 % format article title and check if title or type present
4057 %
4058 { format.editors.as.authors start.new.block
4059 %
4060 % now formatted date on top of stack
4061 %
4062 output.dot.new.block
4063 format.atitle.type.trans.check output.new.block
4064 }
4065 if$
4066 }
4067 %
4068 % format author and year, and check if year is present
4069 % format article title and check if title or type present
4070 %
4071 { format.authors start.new.block
4072 %
4073 % now formatted date on top of stack
4074 %
4075 output.dot.new.block
4076 format.atitle.type.trans.check output.new.block
4077 }
4078 if$
4079 %
4080 % format journal name, volume and issue number, and pages
4081 % and check if journal not empty
4082 %
4083 format.journal.vol.num.pages.check
4084 %
4085 % if not empty, insert howpublished.
4086 % (used if article is retrieved from the internet)
4087 %
4088 format.howpublished add.period$
4089 %
4090 % format url
4091 %
4092 url empty$
4093 'skip$
4094 { % Clear the stack
4095 duplicate$ empty$
4096 'skip$
4097 { output.new.block }
4098 if$
4099 format.url
4100 }
4101 if$
4102 %
4103 % possible reprint and optional note
4104 %
4105 format.orig.note
4106 fin.entry
4107 }
4108
4109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4110 %
4111 % journal article
4112 %
4113 FUNCTION {article}
4114 { pages format.year.month.day.check periodical }
4115
4116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4117 %
4118 % magazine article
4119 %
4120 FUNCTION {magazine}
4121 { pages format.year.month.day.check periodical }
4122
4123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4124 %
4125 % newspaper article
4126 %
4127 FUNCTION {newspaper}
4128 { pages format.bpages.check format.year.month.day.check periodical }
4129
4130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4131 %
4132 % (translation of) entire book
4133 %
4134 FUNCTION {book}
4135 { %
4136 % author or editor,
4137 % year, title, englishtitle, translator
4138 %
4139 author empty$
4140 %
4141 % no author: possibly edited book with editors as authors
4142 %
4143 { editor empty$
4144 %
4145 % no author or editor: title serves as author.
4146 % title formatted as book title
4147 %
4148 { format.btitle.vol.edition.trans
4149 format.type.number connect.with.space.check
4150 output.dot.new.block
4151 format.year.check add.period$
4152 }
4153 %
4154 % format editor and year, and check if year is present
4155 % format booktitle, volume, and edition and check if title present
4156 %
4157 { translator empty$
4158 { format.editors.as.authors start.new.block
4159 format.year.check output.dot.new.block
4160 format.btitle.vol.edition
4161 }
4162 %
4163 % format translator correctly
4164 %
4165 { translator editor =
4166 not
4167 { format.editors.as.authors start.new.block
4168 format.year.check output.dot.new.block
4169 format.btitle.vol.edition.trans
4170 }
4171 { format.ed.trans.as.authors start.new.block
4172 format.year.check output.dot.new.block
4173 format.btitle.vol.edition
4174 }
4175 if$
4176 }
4177 if$
4178 format.type.number connect.with.space.check
4179 add.period$
4180 }
4181 if$
4182 }
4183 %
4184 % format author and year, and check if year is present
4185 % format booktitle, volume, and edition and check if title present
4186 %
4187 { format.authors start.new.block
4188 format.year.check output.dot.new.block
4189 format.btitle.vol.edition.editor.trans
4190 format.type.number connect.with.space.check
4191 add.period$
4192 }
4193 if$
4194 %
4195 % format address and publisher
4196 %
4197 format.address.publisher.check
4198 %
4199 % if not empty, insert howpublished.
4200 % (used if book is retrieved from the internet)
4201 %
4202 format.howpublished add.period$
4203 %
4204 % format url
4205 %
4206 url empty$
4207 'skip$
4208 { % Clear the stack
4209 duplicate$ empty$
4210 'skip$
4211 { output.new.block }
4212 if$
4213 format.url
4214 }
4215 if$
4216 %
4217 % format original publication (of reprint/translation)
4218 % and optional note
4219 %
4220 format.orig.note
4221 fin.entry
4222 }
4223 FUNCTION {incollection}
4224 { author empty$
4225 { editor.ne.trans
4226 { format.atitle.type.trans.check }
4227 { format.atitle.type.check }
4228 if$
4229 output.new.block
4230 format.year.month.day.check add.period$
4231 }
4232 { format.authors start.new.block
4233 format.year.month.day.check output.dot.new.block
4234 editor.ne.trans
4235 { format.atitle.type.trans.check }
4236 { format.atitle.type.check }
4237 if$
4238 }
4239 if$
4240 editor empty$
4241 translator empty$ and
4242 edition empty$ and
4243 volume empty$ and
4244 pages empty$ and
4245 chapter empty$ and
4246 booktitle empty$ and
4247 'skip$
4248 {
4249 output.new.block
4250 format.in.editors.trans
4251 format.bvol.edition.pages
4252 booktitle format.btitle.connect * add.period$
4253 }
4254 if$
4255 format.address.publisher.check
4256 format.howpublished add.period$
4257 url empty$
4258 'skip$
4259 {
4260 duplicate$ empty$
4261 'skip$
4262 { output.new.block }
4263 if$
4264 format.url
4265 }
4266 if$
4267 format.orig.note
4268 fin.entry
4269 }
4270
4271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4273
4274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4275 %
4276 % technical report number
4277 %
4278 FUNCTION {format.tr.number}
4279 { type empty$
4280 { "\BTR{}" }
4281 { type "\bibnotype" =
4282 { "" }
4283 { type }
4284 if$
4285 }
4286 if$
4287 number format.rnumber.check connect.with.space.check
4288 }
4289
4290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4291 %
4292 % title, volume, edition, report number
4293 %
4294 FUNCTION {format.tr.title.number}
4295 { format.betitle.check
4296 % Single out the situation in which there is no number
4297 % and type = {\bibnotype}, i.e., no type as well.
4298 % (Why not use book then?)
4299 type empty$
4300 { % Now, we're in the regular situation with at least a
4301 % number, a type, a volume, or an edition.
4302 "\APACbVolEdTR{" format.bvol.edition.check * "}{" *
4303 format.tr.number * "}" *
4304 }
4305 { type "\bibnotype" =
4306 number empty$
4307 volume empty$
4308 edition empty$
4309 and
4310 and
4311 and
4312 { "" }
4313 { % Now, we're in the regular situation with at least a
4314 % number, a type, a volume, or an edition.
4315 "\APACbVolEdTR {" format.bvol.edition.check * "}{" *
4316 format.tr.number * "}" *
4317 }
4318 if$
4319 }
4320 if$
4321 connect.with.space.check
4322 title format.btitle.connect
4323 }
4324
4325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4326 %
4327 % format address and institution of reports etc.
4328 %
4329 % Washington, DC: National Institute of Education
4330 % or
4331 % National Institute of Education (if address empty)
4332 %
4333 % warning if no institution
4334 %
4335 FUNCTION {format.address.institution.check}
4336 { url empty$
4337 doi empty$ and
4338 { "institution" institution warning.if.empty
4339 "address" address warning.if.empty
4340 }
4341 'skip$
4342 if$
4343 institution empty$
4344 address empty$
4345 and
4346 'skip$
4347 { % Clear the stack
4348 duplicate$ empty$
4349 'skip$
4350 { output.new.block }
4351 if$
4352 %
4353 % If institution = author or institution = "author"
4354 % or institution = "Author" then hand over the final choice how to
4355 % format this to \LaTeX. See also format.address.publisher
4356 %
4357 author empty$
4358 institution empty$ or
4359 { institution "\APACaddressInstitution{" }
4360 { author institution =
4361 "author" institution = or
4362 "Author" institution = or
4363 { author "\APACaddressInstitutionEqAuth{" }
4364 { institution "\APACaddressInstitution{" }
4365 if$
4366 }
4367 if$
4368 address "" connect.check "}{" *
4369 % Recover institution that was pushed onto the stack previously.
4370 swap$ "" connect.check "}" *
4371 }
4372 if$
4373 }
4374
4375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4376 %
4377 % reports
4378 %
4379 FUNCTION {techreport}
4380 { author empty$
4381 %
4382 % no author: possibly edited report with editors as authors
4383 %
4384 { editor empty$
4385 %
4386 % no author or editor: title serves as author.
4387 % title formatted as book title
4388 %
4389 { format.tr.title.number output.dot.new.block
4390 format.year.month.day.check add.period$
4391 }
4392 %
4393 % format editor and year, and check if year is present
4394 % format report title and check if title present
4395 % format volume, edition, type, and number
4396 %
4397 { format.editors.as.authors start.new.block
4398 format.year.month.day.check output.dot.new.block
4399 format.tr.title.number add.period$
4400 }
4401 if$
4402 }
4403 %
4404 % format author and year, and check if year is present
4405 % format report title and check if title present
4406 % format volume, edition, type, and number
4407 %
4408 { format.authors start.new.block
4409 format.year.month.day.check output.dot.new.block
4410 format.tr.title.number add.period$
4411 }
4412 if$
4413 %
4414 % format address and institution, check if institution present
4415 %
4416 format.address.institution.check
4417 %
4418 % if not empty, insert howpublished.
4419 % (used if report is retrieved from the internet)
4420 %
4421 format.howpublished add.period$
4422 %
4423 % format url
4424 %
4425 url empty$
4426 'skip$
4427 { % Clear the stack
4428 duplicate$ empty$
4429 'skip$
4430 { output.new.block }
4431 if$
4432 format.url
4433 }
4434 if$
4435 %
4436 % format optional note
4437 %
4438 note empty$
4439 'skip$
4440 { % Clear the stack
4441 duplicate$ empty$
4442 'skip$
4443 { output.new.block }
4444 if$
4445 format.note
4446 }
4447 if$
4448 fin.entry
4449 }
4450
4451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4452 %
4453 % (translated) article or chapter in report
4454 %
4455 FUNCTION {intechreport}
4456 { author empty$
4457 %
4458 % no author: title serves as author.
4459 % title formatted as article title (APA manual not consistent in this,
4460 % compare statement on p. 119: ``treat as book title'' and
4461 % example 8, p. 121: no underlining => article title)
4462 %
4463 { editor.ne.trans
4464 { format.atitle.trans.check }
4465 { format.atitle.check }
4466 if$
4467 output.new.block
4468 format.year.month.day.check output.dot.new.block
4469 }
4470 %
4471 % format author and year, and check if year is present
4472 % format article title and check if title or type present
4473 %
4474 { format.authors start.new.block
4475 format.year.month.day.check output.dot.new.block
4476 editor.ne.trans
4477 { format.atitle.trans.check }
4478 { format.atitle.check }
4479 if$
4480 output.new.block
4481 }
4482 if$
4483 %
4484 % format "In " editor " (Ed. \& Trans.), "
4485 % booktitle, volume, edition, pages
4486 %
4487 format.in.editors.trans
4488 %
4489 % volume, edition, report type and number, pages
4490 %
4491 "\APACbVolEdTRpgs {" format.bvol.edition.check * "} {" *
4492 format.tr.number *
4493 "} {" * pages format.bpages.check *
4494 "}" *
4495 %
4496 booktitle format.btitle.connect *
4497 add.period$
4498 %
4499 % format address and publisher
4500 %
4501 format.address.institution.check
4502 %
4503 % if not empty, insert howpublished.
4504 % (used if report is retrieved from the internet)
4505 %
4506 format.howpublished add.period$
4507 %
4508 % format url
4509 %
4510 url empty$
4511 'skip$
4512 { % Clear the stack
4513 duplicate$ empty$
4514 'skip$
4515 { output.new.block }
4516 if$
4517 format.url
4518 }
4519 if$
4520 %
4521 % format original publication (of reprint/translation)
4522 % and optional note
4523 %
4524 format.orig.note
4525 fin.entry
4526 }
4527
4528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4529 %
4530 % papers presented at conferences etc.
4531 %
4532 FUNCTION {lecture}
4533 { author empty$
4534 { "author" author warning.if.empty }
4535 { format.authors start.new.block }
4536 if$
4537 %
4538 % format year, month, and day, and check if year present
4539 % format title and check if title present
4540 % format howpublished and check if howpublished present
4541 %
4542 format.year.month.day.check output.dot.new.block
4543 symposium empty$
4544 { format.betitle.check
4545 title format.btitle.connect output.new.block
4546 howpublished empty$
4547 { "symposium and howpublished missing in " cite$ * warning$
4548 ""
4549 }
4550 { "\APAChowpublished {" howpublished * "}" * }
4551 if$
4552 address connect.with.comma.check
4553 }
4554 { format.atitle.type.check output.new.block
4555 "\BIn{} "
4556 chair empty$
4557 'skip$
4558 { chair format.editor.names
4559 chair num.names$ #1 >
4560 { "(\BCHAIRS)" }
4561 { "(\BCHAIR)" }
4562 if$
4563 connect.with.space.check * ", " *
4564 }
4565 if$
4566 symposium format.btitle.no.dot *
4567 format.howpublished
4568 address connect.with.comma.check
4569 }
4570 if$
4571 add.period$
4572 %
4573 % format url
4574 %
4575 url empty$
4576 'skip$
4577 { % Clear the stack
4578 duplicate$ empty$
4579 'skip$
4580 { output.new.block }
4581 if$
4582 format.url
4583 }
4584 if$
4585 %
4586 % format optional note
4587 %
4588 note empty$
4589 'skip$
4590 { % Clear the stack
4591 duplicate$ empty$
4592 'skip$
4593 { output.new.block }
4594 if$
4595 format.note
4596 }
4597 if$
4598 fin.entry
4599 }
4600
4601 FUNCTION {format.ttitle.type.school}
4602 { doi empty$ not
4603 url empty$ not or
4604 howpublished empty$ not or
4605 { pop$ }
4606 { swap$ pop$ }
4607 if$
4608 type empty$
4609 'skip$
4610 { type "\bibnotype" =
4611 { pop$
4612 ""
4613 }
4614 { pop$
4615 type
4616 }
4617 if$
4618 }
4619 if$
4620 duplicate$ empty$
4621 doi empty$
4622 url empty$ and
4623 howpublished empty$ and
4624 address empty$
4625 school empty$ and or and
4626 { 'pop$
4627 title empty$ not
4628 englishtitle empty$ not or
4629 { start.new.block }
4630 'skip$
4631 if$
4632 ""
4633 }
4634 { start.new.block
4635 "\APACtypeAddressSchool {" swap$ * "}{" *
4636 doi empty$
4637 url empty$ and
4638 howpublished empty$ and
4639 { "}{}" * }
4640 { address "" connect.check "}{" *
4641 school "" connect.check "}" *
4642 }
4643 if$
4644 }
4645 if$
4646 format.betitle.check swap$
4647 connect.with.space.check
4648 "title" title warning.if.empty
4649 title format.btitle.connect
4650 }
4651 FUNCTION {unpub.address.school.block}
4652 { doi empty$
4653 url empty$ and
4654 howpublished empty$ and
4655 { "school" school warning.if.empty
4656 school empty$
4657 address empty$ and
4658 'skip$
4659 { start.new.block
4660 "\APACaddressSchool {" address "" connect.check "}{" *
4661 school "" connect.check "}" *
4662 output.dot.end.block
4663 }
4664 if$
4665 }
4666 'skip$
4667 if$
4668 }
4669 FUNCTION {thesis}
4670 { journal empty$ not
4671 { pop$ pop$
4672 article
4673 }
4674 { author empty$
4675 { "author" author warning.if.empty }
4676 { format.authors start.new.block }
4677 if$
4678 format.year.check output.dot.end.block
4679 format.ttitle.type.school output.dot.end.block
4680 unpub.address.school.block
4681 howpublished.block
4682 url.block
4683 note.block
4684 fin.entry.2
4685 }
4686 if$
4687 }
4688 FUNCTION {phdthesis}
4689 { "\BPhD" "\BUPhD" thesis }
4690 FUNCTION {mastersthesis}
4691 { "\BMTh" "\BUMTh" thesis }
4692
4693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4695
4696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4697 %
4698 % title of something (used in unpublished and misc)
4699 % english translation of title
4700 % type and number of something
4701 %
4702 FUNCTION {format.btitle.type.num}
4703 { format.betitle.check
4704 format.bvol.edition connect.with.space.check
4705 format.type.number
4706 connect.with.space.check
4707 title empty$
4708 { add.period$ }
4709 { title format.btitle.connect }
4710 if$
4711 }
4712
4713 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4714 %
4715 % title of message or software-related thing (used in misc)
4716 % english translation of title
4717 % type and number of something
4718 %
4719 FUNCTION {format.mtitle.type.num}
4720 { format.aetitle.check
4721 format.bvol.edition connect.with.space.check
4722 type.2 "\bibmessage" =
4723 { number empty$
4724 'skip$
4725 { type.2 number tie.or.space.connect
4726 bracket.check
4727 connect.with.space.check
4728 }
4729 if$
4730 }
4731 { format.type.number
4732 connect.with.space.check
4733 }
4734 if$
4735 title empty$
4736 { add.period$ }
4737 { title format.atitle.connect }
4738 if$
4739 }
4740
4741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4742 %
4743 % title, english translation of title,
4744 % type and number of something (used in misc)
4745 %
4746 FUNCTION {output.misctitle.type.num}
4747 { type.2 empty$
4748 { format.btitle.type.num }
4749 { type.2 "\bibmessage" =
4750 type.2 "\bibcomputerprogram" = or
4751 type.2 "\bibcomputerprogrammanual" = or
4752 type.2 "\bibcomputerprogramandmanual" = or
4753 type.2 "\bibcomputersoftware" = or
4754 type.2 "\bibcomputersoftwaremanual" = or
4755 type.2 "\bibcomputersoftwareandmanual" = or
4756 type.2 "\bibprogramminglanguage" = or
4757 { format.mtitle.type.num }
4758 { format.btitle.type.num }
4759 if$
4760 }
4761 if$
4762 }
4763
4764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4765 %
4766 % unpublished manuscripts, etc.
4767 %
4768 FUNCTION {unpublished}
4769 { check.relevant.fields
4770 author empty$
4771 %
4772 % no author: possibly edited book with editors as authors
4773 %
4774 { editor empty$
4775 %
4776 % no author or editor: title serves as author.
4777 % title formatted as book title
4778 %
4779 { format.btitle.type.num output.new.block
4780 format.year.month.day.check add.period$
4781 }
4782 %
4783 % format editor and year, and check if year is present
4784 % format book title, volume, and edition and check if title present
4785 %
4786 { format.editors.as.authors start.new.block
4787 format.year.month.day.check output.dot.new.block
4788 format.btitle.type.num
4789 }
4790 if$
4791 }
4792 %
4793 % format author and year, and check if year is present
4794 % format book title, volume, and edition
4795 % and check if title or type present
4796 %
4797 { format.authors start.new.block
4798 format.year.month.day.check output.dot.new.block
4799 format.btitle.type.num
4800 }
4801 if$
4802 howpublished empty$
4803 organization empty$ and
4804 address empty$ and
4805 'skip$
4806 { output.new.block
4807 "\APAChowpublished{" "}" howpublished enclose.check
4808 organization connect.with.comma.check
4809 address connect.with.comma.check
4810 add.period$
4811 }
4812 if$
4813 %
4814 % format url
4815 %
4816 url empty$
4817 'skip$
4818 { % Clear the stack
4819 duplicate$ empty$
4820 'skip$
4821 { output.new.block }
4822 if$
4823 format.url
4824 }
4825 if$
4826 %
4827 % format optional note
4828 %
4829 note empty$
4830 'skip$
4831 { % Clear the stack
4832 duplicate$ empty$
4833 'skip$
4834 { output.new.block }
4835 if$
4836 format.note
4837 }
4838 if$
4839 fin.entry
4840 }
4841
4842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4843 %
4844 % nonprint media and other things that don't fit
4845 %
4846 FUNCTION {misc}
4847 { %
4848 % To handle @manual: use type.2 instead of type.
4849 type.2 empty$
4850 type empty$ not and
4851 { type 'type.2 := }
4852 'skip$
4853 if$
4854 %
4855 author empty$
4856 %
4857 % no author: possibly edited item with editors as authors
4858 %
4859 { editor empty$
4860 %
4861 % no author or editor: title/type serves as author.
4862 % title formatted as book title
4863 %
4864 % if no title and no type, howpublished is title
4865 %
4866 { title empty$
4867 type.2 empty$ and
4868 { howpublished empty$
4869 { "No author, editor, title, type, and howpublished in "
4870 cite$ * warning$
4871 ""
4872 }
4873 { "\APAChowpublished{" howpublished * "}" * add.period$ }
4874 if$
4875 format.year.month.day.check add.period$
4876 }
4877 { output.misctitle.type.num output.new.block
4878 format.year.month.day.check add.period$
4879 format.howpublished add.period$
4880 }
4881 if$
4882 }
4883 %
4884 % format editor and year, and check if year is present
4885 % format book title, volume, and edition and check if title present
4886 %
4887 { format.editors.as.authors start.new.block
4888 format.year.month.day.check output.dot.new.block
4889 output.misctitle.type.num
4890 format.howpublished add.period$
4891 }
4892 if$
4893 }
4894 %
4895 % format author and year, and check if year is present
4896 % format book title, volume, and edition
4897 % and check if title or type present
4898 %
4899 { format.authors start.new.block
4900 format.year.month.day.check output.dot.new.block
4901 output.misctitle.type.num
4902 format.howpublished add.period$
4903 }
4904 if$
4905 %
4906 address empty$
4907 publisher empty$ and
4908 'skip$
4909 { % Clear the stack
4910 duplicate$ empty$
4911 'skip$
4912 { output.new.block }
4913 if$
4914 format.address.publisher add.period$
4915 }
4916 if$
4917 %
4918 % format url
4919 %
4920 url empty$
4921 'skip$
4922 { % Clear the stack
4923 duplicate$ empty$
4924 'skip$
4925 { output.new.block }
4926 if$
4927 format.url
4928 }
4929 if$
4930 %
4931 % format optional note
4932 %
4933 note empty$
4934 'skip$
4935 { % Clear the stack
4936 duplicate$ empty$
4937 'skip$
4938 { output.new.block }
4939 if$
4940 format.note
4941 }
4942 if$
4943 fin.entry
4944 }
4945
4946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4947 %
4948 % for legal cases and other cases that need to be
4949 % done by hand
4950 %
4951 FUNCTION {literal}
4952 { "key" key warning.if.empty
4953 "text" text warning.if.empty
4954 text empty$
4955 { "" }
4956 { text }
4957 if$
4958 fin.entry
4959 }
4960
4961 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4962 %
4963 % technical documentation
4964 %
4965 FUNCTION {manual}
4966 { %
4967 % If type is empty, assume that it is a computer software manual.
4968 %
4969 type empty$
4970 { "\bibcomputersoftwaremanual" 'type.2 := }
4971 'skip$
4972 if$
4973 misc
4974 }
4975
4976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4977 %
4978 % booklet
4979 %
4980 FUNCTION {booklet}
4981 { misc }
4982
4983 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4984 %
4985 % part of a book
4986 %
4987 FUNCTION {inbook}
4988 { incollection }
4989
4990 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4991 %
4992 % article in proceedings
4993 %
4994 FUNCTION {inproceedings}
4995 { incollection }
4996
4997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4998 %
4999 % article in proceedings (Kopka & Daly, 2004, p. 230)
5000 %
5001 FUNCTION {conference}
5002 { inproceedings }
5003
5004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5005 %
5006 % proceedings
5007 %
5008 FUNCTION {proceedings}
5009 { misc }
5010
5011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5012 %
5013 % unknown types
5014 %
5015 FUNCTION {default.type}
5016 { misc }
5017
5018 FUNCTION {initialize}
5019 {
5020 #6 'name.max :=
5021 %% #250 'entry.max$ :=
5022 %% #5000 'global.max$ :=
5023 }
5024 FUNCTION {init.old.number}
5025 { #0 'old.number := }
5026 FUNCTION {init.old.label}
5027 { "zzzzzz" 'old.label := }
5028 FUNCTION {init.cite.initials.add.to.year}
5029 { #0 'cite.initials :=
5030 #0 'add.to.year :=
5031 }
5032 FUNCTION {move.forward}
5033 { #1 'forward := }
5034 FUNCTION {move.backward}
5035 { #0 'forward := }
5036 FUNCTION {begin.bib}
5037 { preamble$ empty$
5038 'skip$
5039 { preamble$ write$ newline$ }
5040 if$
5041 "\begin{thebibliography}{}" write$ newline$
5042 }
5043 FUNCTION {end.bib}
5044 { newline$
5045 "\end{thebibliography}" write$ newline$
5046 }
5047 FUNCTION {write.bbl.entry}
5048 {
5049 make.cite.labels
5050 call.type$
5051 }
5052 READ
5053 EXECUTE { identify.apacite.version }
5054 EXECUTE { initialize }
5055 EXECUTE { init.old.number }
5056 ITERATE { make.citeorder.number }
5057 ITERATE { make.sort.title }
5058 SORT
5059 EXECUTE { init.old.number }
5060 EXECUTE { init.old.label }
5061 ITERATE { make.title.number }
5062 ITERATE { make.tentative.sort.label }
5063 SORT
5064 ITERATE { init.cite.initials.add.to.year }
5065 EXECUTE { init.initials }
5066 ITERATE { check.add.initials }
5067 EXECUTE { init.initials }
5068 REVERSE { check.add.initials }
5069 ITERATE { tentative.cite.num.names }
5070 EXECUTE { init.cite.num.names }
5071 EXECUTE { move.forward }
5072 ITERATE { definitive.cite.num.names }
5073 EXECUTE { init.cite.num.names }
5074 EXECUTE { move.backward }
5075 REVERSE { definitive.cite.num.names }
5076 ITERATE { make.final.sort.key }
5077 SORT
5078 EXECUTE { begin.bib }
5079 ITERATE { write.bbl.entry }
5080 EXECUTE { end.bib }
5081
5082 %%
5083 %% End of file `apacite.bst'.