Debian Codegraph @

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

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