publ-imp-apa.mkvi /size: 45 Kb    last modification: 2023-12-21 09:44
1%D \modul
2%D   [       file=publ-imp-apa,
3%D        version=2013.12.12,
4%D          title=APA bibliography style,
5%D       subtitle=Publications,
6%D         author=Alan Braslau and Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is therefore copyrighted
11%D by \PRAGMA. See mreadme.pdf for details.
12
13\startbtxrenderingdefinitions[apa]
14
15\ifdefined\c!translate \else \def\c!translate{translate} \fi
16
17%D Reference:
18%D \startTEX
19%D @Book{APA2010,
20%D     title    ={Publication Manual of the American Psychological Association},
21%D     year     ={2010},
22%D     edition  ={Sixth},
23%D     address  ={Washington, DC},
24%D     publisher={American Psychological Association},
25%D     Xpages   ={291},
26%D     url      ={http://www.apa.org/books/},
27%D }
28%D \stopTEX
29
30% set ALL specific APA compliant values
31
32\definebtx
33  [apa]
34  [\c!default=default,
35   \c!specification=apa,
36   \c!otherstext={\btxspace\btxlabeltext{others}},
37  %\c!journalconversion=\v!normal,
38   \c!monthconversion=\v!month,
39  %\c!separator:firstnames={\btxnobreakspace}, % ?
40   \c!stopper:initials={\btxperiod}, % TODO: nobreak between multiple initials
41   \c!separator:invertedinitials={\btxcomma\btxnobreakspace},
42   \c!separator:names:2={\btxcomma}, % aka namesep - in this namespace
43   \c!separator:names:3={\btxcomma\btxnobreakspace\textampersand\space},
44   \c!separator:names:4={\btxnobreakspace\textampersand\space}] % last of two, no comma!
45
46% First, define list and rendering parameters
47
48% The APA style sorts the unnumbered rendered list by authoryear
49
50\definebtxrendering
51  [apa]
52  [\c!specification=apa,
53   \c!sorttype=authoryear,
54   \c!numbering=\v!no]
55
56\setupbtxlist
57  [apa]
58  [\c!alternative=\v!paragraph,
59   \c!align={normal,verytolerant,stretch},
60  %\c!width=\v!fit,
61  %\c!distance=.5\emwidth,
62   \c!margin=3.5\emwidth]
63
64\definebtx
65  [apa:\s!list]
66  [apa]
67  [\c!otherstext={\btxcomma\btxnobreakspace\textellipsis\space},
68   \c!etallimit=7,
69   \c!etaldisplay=6,
70   \c!etaloption=last,
71   \c!authorconversion=invertedshort]
72
73% First, we define a namespace for a few special fields
74
75\definebtx
76  [apa:\s!list:author]
77  [apa:\s!list]
78
79\definebtx
80  [apa:\s!list:withauthor]
81  [apa:\s!list:author]
82
83\definebtx
84  [apa:\s!list:editor]
85  [apa:\s!list:author]
86
87\definebtx
88  [apa:\s!list:ineditor]
89  [apa:\s!list:editor]
90  [\c!authorconversion=normalshort]
91
92\definebtx
93  [apa:\s!list:translator]
94  [apa:\s!list:author]
95  [\c!authorconversion=normalshort]
96
97\definebtx
98  [apa:\s!list:director]
99  [apa:\s!list:author]
100
101\definebtx
102  [apa:\s!list:producer]
103  [apa:\s!list:author]
104
105\definebtx
106  [apa:\s!list:suffix]
107  [apa:\s!list]
108
109\definebtx
110  [apa:\s!list:url]
111  [apa:\s!list]
112
113\definebtx
114  [apa:\s!list:doi]
115  [apa:\s!list]
116
117\definebtx
118  [apa:\s!list:isbn]
119  [apa:\s!list]
120
121\definebtx
122  [apa:\s!list:issn]
123  [apa:\s!list]
124
125\definebtx
126  [apa:\s!list:\s!page]
127  [apa:\s!list]
128  [\c!separator:2={\btxcomma},
129   \c!separator:3={\btxcomma\btxlabeltext{and}\space},
130   \c!separator:4={\btxspace\btxlabeltext{and}\space},
131   \c!left={\btxleftparenthesis},
132   \c!right={\btxrightparenthesis},
133   \c!command={\wordright}]
134
135\definebtx
136  [apa:\s!list:numbering]
137  [apa:\s!list]
138  [\c!right={\btxspace}]
139
140\definebtx
141  [apa:\s!list:numbering:default]
142  [apa:\s!list:numbering]
143
144\definebtx
145  [apa:\s!list:numbering:num]
146  [apa:\s!list:numbering]
147  [\c!stopper={.}]
148
149\definebtx
150  [apa:\s!list:numbering:short]
151  [apa:\s!list:numbering]
152
153\definebtx
154  [apa:\s!list:numbering:tag]
155  [apa:\s!list:numbering]
156
157\definebtx
158  [apa:\s!list:numbering:index]
159  [apa:\s!list:numbering]
160
161% Next, we define a namespace for each category
162
163%D In order to be able to get journals expanded (or normalized or abbreviated) you need
164%D to load a list:
165%D
166%D \starttyping
167%D \btxloadjournallist[journals.txt] % the jabref list
168%D \stoptyping
169
170\definebtx
171  [apa:\s!list:journal]
172  [apa:\s!list]
173  [\c!style=\v!italic]
174  %command=\btxexpandedjournal] % btxabbreviatedjournal
175
176\definebtx
177  [apa:\s!list:volume]
178  [apa:\s!list]
179  [\c!style=\v!italic]
180
181\definebtx
182  [apa:\s!list:title]
183  [apa:\s!list]
184  [\c!style=\v!italic,
185   \c!command=\Word,
186  ] %\c!translate=\v!yes]
187
188\definebtx
189  [apa:\s!list:title:article]
190  [apa:\s!list:title]
191  [\c!style=] % journal is set in italics
192
193\definebtx
194  [apa:\s!list:title:magazine]
195  [apa:\s!list:title]
196
197\definebtx
198  [apa:\s!list:title:newspaper]
199  [apa:\s!list:title]
200
201\definebtx
202  [apa:\s!list:title:periodical]
203  [apa:\s!list:title]
204
205\definebtx
206  [apa:\s!list:title:standard]
207  [apa:\s!list:title]
208
209\definebtx
210  [apa:\s!list:title:book]
211  [apa:\s!list:title]
212
213\definebtx
214  [apa:\s!list:booktitle:inbook]
215  [apa:\s!list:title]
216
217\definebtx
218  [apa:\s!list:title:inbook]
219  [apa:\s!list:title]
220  [\c!style=] % booktitle is set in italics
221
222\definebtx
223  [apa:\s!list:booktitle:incollection]
224  [apa:\s!list:title]
225
226\definebtx
227  [apa:\s!list:title:incollection]
228  [apa:\s!list:title]
229  [\c!style=] % booktitle is set in italics
230
231\definebtx
232  [apa:\s!list:title:proceedings]
233  [apa:\s!list:title]
234
235\definebtx
236  [apa:\s!list:booktitle:inproceedings]
237  [apa:\s!list:title]
238
239\definebtx
240  [apa:\s!list:title:inproceedings]
241  [apa:\s!list:title]
242  [\c!style=] % booktitle is set in italics
243
244\definebtx
245  [apa:\s!list:booktitle:conference]
246  [apa:\s!list:title]
247
248\definebtx
249  [apa:\s!list:title:conference]
250  [apa:\s!list:title]
251  [\c!style=] % booktitle is set in italics
252
253\definebtx
254  [apa:\s!list:title:thesis]
255  [apa:\s!list:title]
256
257\definebtx
258  [apa:\s!list:title:phdthesis]
259  [apa:\s!list:title]
260
261\definebtx
262  [apa:\s!list:title:mastersthesis]
263  [apa:\s!list:title]
264
265\definebtx
266  [apa:\s!list:title:booklet]
267  [apa:\s!list:title]
268
269\definebtx
270  [apa:\s!list:title:manual]
271  [apa:\s!list:title]
272
273\definebtx
274  [apa:\s!list:title:techreport]
275  [apa:\s!list:title]
276
277\definebtx
278  [apa:\s!list:title:unpublished]
279  [apa:\s!list:title]
280
281\definebtx
282  [apa:\s!list:title:patent]
283  [apa:\s!list:title]
284
285\definebtx
286  [apa:\s!list:title:electronic]
287  [apa:\s!list:title]
288
289\definebtx
290  [apa:\s!list:title:music]
291  [apa:\s!list:title]
292
293\definebtx
294  [apa:\s!list:title:film]
295  [apa:\s!list:title]
296
297\definebtx
298  [apa:\s!list:title:other]
299  [apa:\s!list:title]
300
301\definebtx
302  [apa:\s!list:title:misc]
303  [apa:\s!list:title]
304
305\definebtx
306  [apa:\s!list:title:literal]
307  [apa:\s!list:title]
308
309\definebtx
310  [apa:\s!list:type]
311  [\c!command=\Word]
312
313% Then define and set cite parameters.
314
315\definebtx
316  [apa:\s!cite]
317  [apa]
318  [\c!alternative=authoryear,
319   \c!otherstext={\btxcomma\btxlabeltext{others}},
320   \c!etallimit=5,
321   \c!etaldisplay=1, % TODO: when 2-4, show all first time, etaldisplay subsequently...
322   \c!authorconversion=\v!name,
323   \c!sorttype=normal, % \v!normal ?
324   \c!style=, % hyjacked below:
325   \c!style={\texdefinition{btx:apa:setlanguage}{\mainbtxlanguage}},
326   \c!compress=\v!yes, % note that cite sorts only work with compress=yes.
327   \c!separator:names:3={\btxcomma\btxlabeltext{and}\space}, % not \textampersand
328   \c!separator:names:4={\btxspace\btxlabeltext{and}\space}] % not \textampersand
329
330\definebtx
331  [apa:\s!cite:name]
332  [apa:\s!cite]
333  [\c!authorconversion=\v!name]
334
335\definebtx
336  [apa:\s!cite:inverted]
337  [apa:\s!cite]
338  [\c!authorconversion=\v!invertedshort]
339
340\definebtx
341  [apa:\s!cite:invertedshort]
342  [apa:\s!cite]
343  [\c!authorconversion=\v!invertedshort]
344
345\definebtx
346  [apa:\s!cite:normalshort]
347  [apa:\s!cite]
348  [\c!authorconversion=\v!normalshort]
349
350\definebtx
351  [apa:\s!cite:normal]
352  [apa:\s!cite]
353  [\c!authorconversion=\v!normal]
354
355\definebtx
356  [apa:\s!cite:author]
357  [apa:\s!cite]
358
359\definebtx
360  [apa:\s!cite:editor]
361  [apa:\s!cite:author]
362
363\definebtx
364  [apa:\s!cite:translator]
365  [apa:\s!cite:author]
366
367\definebtx
368  [apa:\s!cite:organization]
369  [apa:\s!cite]
370
371\definebtx
372  [apa:\s!cite:authoryear]
373  [apa:\s!cite:author]
374  [\c!left={(},
375   \c!right={)},
376   \c!inbetween={\btxcomma},
377   \c!separator:names:3={\btxcomma\textampersand\space},
378   \c!separator:names:4={\btxspace\textampersand\space}]
379
380\definebtx
381  [apa:\s!cite:default]
382  [apa:\s!cite:authoryear]
383
384\definebtx
385  [apa:\s!cite:authoryears]
386  [apa:\s!cite:author]
387  [\c!left=, % these two settings are perhaps redundant?
388   \c!right=,
389   \c!inbetween={\btxspace}]
390
391\definebtx
392  [apa:\s!cite:authornum]
393  [apa:\s!cite:author]
394  [\c!left={(},
395   \c!right={)},
396   \c!separator:names:3={\btxcomma\textampersand\space},
397   \c!separator:names:4={\btxspace\textampersand\space}]
398
399\definebtx
400  [apa:\s!cite:author:num] % todo
401  [apa:\s!cite:authornum]
402  [\c!left={\btxspace[},
403   \c!right={]}]
404
405\definebtx
406  [apa:\s!cite:author:year] % todo
407  [apa:\s!cite]
408  [\c!separator:2={\btxcomma},
409   \c!separator:3={\btxcomma}]
410
411\definebtx
412  [apa:\s!cite:author:years] % todo
413  [apa:\s!cite:authoryears]
414  [\c!inbetween=,
415   \c!left={\btxspace(},
416   \c!right={)},
417   \c!separator:2={\btxcomma},
418   \c!separator:3={\btxcomma}]
419
420\definebtx
421  [apa:\s!cite:lefttext]
422  [apa:\s!cite]
423  [\c!left=,
424   \c!right={\btxspace}]
425
426\definebtx
427  [apa:\s!cite:righttext]
428  [apa:\s!cite]
429  [\c!left={\btxcomma},
430   \c!right=]
431
432\definebtx
433  [apa:\s!cite:year]
434  [apa:\s!cite]
435  [\c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
436   \c!separator:3={\btxcomma\btxlabeltext{and}\space}, % not \textampersand
437   \c!separator:4={\btxspace\btxlabeltext{and}\space}] % not \textampersand
438
439\definebtx
440  [apa:\s!cite:title]
441  [apa:\s!cite]
442  [\c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
443   \c!separator:3={\btxcomma\btxlabeltext{and}\space}, % not \textampersand
444   \c!separator:4={\btxspace\btxlabeltext{and}\space}, % not \textampersand
445   \c!sorttype=none,
446   \c!style=\v!italic]
447
448\definebtx
449  [apa:\s!cite:subtitle]
450  [apa:\s!cite:title]
451
452\definebtx
453  [apa:\s!cite:booktitle]
454  [apa:\s!cite:title]
455
456\definebtx
457  [apa:\s!cite:subbooktitle]
458  [apa:\s!cite:booktitle]
459
460% Will these get used?
461
462\definebtx
463  [apa:\s!cite:title:inbook]
464  [apa:\s!cite:title]
465  [\c!style=] % not italic
466
467\definebtx
468  [apa:\s!cite:title:incollection]
469  [apa:\s!cite:title:inbook]
470
471\definebtx
472  [apa:\s!cite:title:inproceedings]
473  [apa:\s!cite:title:inbook]
474
475\definebtx
476  [apa:\s!cite:subtitle:inbook]
477  [apa:\s!cite:title:inbook]
478
479\definebtx
480  [apa:\s!cite:subtitle:incollection]
481  [apa:\s!cite:title:incollection]
482
483\definebtx
484  [apa:\s!cite:subtitle:inproceedings]
485  [apa:\s!cite:title:inproceedings]
486
487
488\definebtx
489  [apa:\s!cite:tag]
490  [apa:\s!cite]
491  [\c!left={[},
492   \c!right={]}]
493
494\definebtx
495  [apa:\s!cite:index]
496  [apa:\s!cite]
497  [\c!left={[},
498   \c!right={]}]
499
500\definebtx
501  [apa:\s!cite:page]
502  [apa:\s!cite]
503  [\c!left=,
504   \c!right=,
505   \c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
506   \c!separator:3={\btxcomma\btxlabeltext{and}\space}, % not \textampersand
507   \c!separator:4={\btxspace\btxlabeltext{and}\space}] % not \textampersand
508
509\definebtx
510  [apa:\s!cite:pages]
511  [apa:\s!cite:page]
512
513\definebtx
514  [apa:\s!cite:keywords]
515  [apa:\s!cite]
516
517\definebtx
518  [apa:\s!cite:short]
519  [apa:\s!cite]
520  [\c!left={[},
521   \c!right={]}]
522
523\definebtx
524  [apa:\s!cite:category]
525  [apa:\s!cite]
526
527\definebtx
528  [apa:\s!cite:url]
529  [apa:\s!cite]
530  [\c!left={(},
531   \c!right={)}]
532
533\definebtx
534  [apa:\s!cite:doi]
535  [apa:\s!cite:url]
536
537\definebtx
538  [apa:\s!cite:isbn]
539  [apa:\s!cite]
540
541\definebtx
542  [apa:\s!cite:issn]
543  [apa:\s!cite]
544
545\definebtx
546  [apa:\s!cite:num]
547  [apa:\s!cite]
548  [\c!left={[},
549   \c!right={]},
550   \c!separator:2={,}, % no space
551   \c!separator:3=\btxparameter{\c!separator:2},
552   \c!separator:4=\btxparameter{\c!separator:2}]
553
554\definebtx
555  [apa:\s!cite:textnum]
556  [apa:\s!cite:num]
557  [\c!left={Ref.\nbsp},
558   \c!right=,
559   \c!separator:2={\btxcomma},
560   \c!separator:3={\btxspace\btxlabeltext{and}\space},
561   \c!separator:4={\btxspace\btxlabeltext{and}\space}]
562
563\definebtx
564  [apa:\s!cite:entry]
565  [apa:\s!cite]
566  [\c!left=,
567   \c!right=,
568   \c!inbetween={\btxspace},
569   \c!separator:2={\btxcomma},
570   \c!separator:3={\btxsemicolon},
571   \c!separator:4={\btxsemicolon}]
572
573% Now we setup for the details of the renderings
574
575%D Sometimes we have verbose injections in an entry and these can be language
576%D dependent, so we use labels.
577%D
578%D Because we want to mix rendering (in the manual) we need a namespace in label
579%D texts:
580
581\setupbtxlabeltext
582  [en]
583  [apa:number={No.},
584   apa:edition={ed.},
585   apa:Editor={Ed.},
586   apa:Editors={Eds.},
587   apa:Volume={Vol.},
588   apa:Volumes={Vols.},
589   apa:nd={n.d.},     % no date
590   apa:supplement={Suppl.},           % Supplement (not used?)
591   apa:MotionPicture={Motion picture},
592   apa:Writer=Writer,
593   apa:Writers=Writers,
594   apa:Producer=Producer,
595   apa:Producers=Producers,
596   apa:Director=Director,
597   apa:Directors=Directors,
598   apa:Recordedby={Recorded by},
599   apa:Author=Author,
600   apa:Translator={Trans.},           % Translator(s)
601   apa:Advanced={Advanced online publication},
602   apa:Retrieved={Retrieved from}] % {Available from}]
603
604\setupbtxlabeltext
605  [nl]
606  [apa:number={Nr.},
607   apa:edition={ed.}, % editie
608   apa:Editor=Editor, % Ed./Eds.
609   apa:Editors=Editors,
610   apa:Volume={Vol.},
611   apa:Volumes={Vols.},
612   apa:nd={g.d.}      % geen datum
613   apa:supplement=Supplement,
614   apa:MotionPicture=Film, % ?
615   apa:Writer=Scenarioschrijver, % ?
616   apa:Writers=Schrijvers, % ?
617   apa:Producer=Producent,   % ?
618   apa:Producers=Producents, % ?
619   apa:Director=Directeur,
620   apa:Directors=Directeurs,
621   apa:Recordedby={Opgenomen door}, % ?
622   apa:Author=Auteur,
623   apa:Translator=Vertaler,
624   apa:Advanced={Geavanceerde online publicatie},
625   apa:Retrieved={Ontvangen van}] % {Beschikbaar vanaf}]
626
627\setupbtxlabeltext
628  [fr]
629  [apa:number={N\high{o}},
630   apa:edition={édition},
631   apa:Editor=Éditeur,
632   apa:Editors=Éditeurs,
633   apa:Volume=Volume,
634   apa:Volumes=Volumes,
635   apa:nd={s.d.},     % sans date
636   apa:supplement=Supplément,
637   apa:MotionPicture={Film cinématographique},
638   apa:Writer=Scénariste,
639   apa:Writers=Scénaristes,
640   apa:Producer=Producteur,
641   apa:Producers=Producteurs,
642   apa:Director=Réalisateur,
643   apa:Directors=Réalisateurs,
644   apa:Recordedby={Enregistré par},
645   apa:Author=Auteur,
646   apa:Translator=Traducteur,
647   apa:Advanced={Publication en ligne anticipée},
648   apa:Retrieved={Téléchargé de}] % {Disponible à}]
649
650\setupbtxlabeltext
651  [de]
652  [apa:number={Nr.},
653   apa:edition=Auf\/lage,
654   apa:Editor=Herausgeber, % Hrsg./Hg.
655   apa:Editors=Herausgeber,
656   apa:Volume=Band,        % Bd.
657   apa:Volumes={Bände},
658   apa:nd={o.D.},          % ohne Datum (mostly: o.J. / ohne Jahr)
659   apa:supplement={Beilage},          % Supplement
660   apa:MotionPicture=Kinofilm, % ?
661   apa:Writer=Drehbuchautor,   % ?
662   apa:Writers=Schriftsteller, % ?
663   apa:Producer=Producer,      % ?
664   apa:Producers=Produzenten,  % ?
665   apa:Director=Director,      % ?
666   apa:Directors=Directors,    % ?
667   apa:Recordedby={per Einschreiben}, % ?
668   apa:Author=Autor,
669   apa:Translator={Übersetzer},       % Übers.
670   apa:Advanced={Erweiterte Online-Publikation},
671   apa:Retrieved={heruntergeladen von}]
672
673% thanks: Andrea Valle
674
675\setupbtxlabeltext
676  [it]
677  [apa:number={},
678   apa:edition={ed.}, % edizione
679   apa:Editor={A cura di},
680   apa:Editors={A cura di},
681   apa:Volume={Vol.},  % Volume
682   apa:Volumes={Vol.}, % Volumi
683   apa:nd={s.d.},     % senza data
684   apa:supplement={Supplemento},
685   apa:MotionPicture=Film, % ?
686   apa:Writer=Sceneggiatore, % ?
687   apa:Writers=Scrittori, % ?
688   apa:Producer=Produttore,
689   apa:Producers=Produttori,
690   apa:Director=Direttore,
691   apa:Directors=Direttori,
692   apa:Recordedby={Registrato da},
693   apa:Author=Autore,
694   apa:Translator={Trad.},                        % Translator(s)
695   apa:Advanced={Pre-pubblicazione on line},
696   apa:Retrieved={Accessible online}]
697
698\setupbtxlabeltext
699  [es]
700  [apa:number={},
701   apa:edition={ed.}, % edición
702   apa:Editor=Editor, % Ed./Eds.
703   apa:Editors=Editores,
704   apa:Volume={Vol.},   % Volumen
705   apa:Volumes={Vols.}, % Volúmenes
706   apa:nd={s.f.},     % sin fecha
707   apa:supplement=Suplemento,
708   apa:MotionPicture=Cinematográfica,
709   apa:Writer=Guionista, % ?
710   apa:Writers=Escritores, % ?
711   apa:Producer=Productor,
712   apa:Producers=Productores,
713   apa:Director=Director,
714   apa:Directors=Directores,
715   apa:Recordedby={Grabada por},
716   apa:Author=Autor,
717   apa:Translator=Traductor,
718   apa:Advanced={Publicación en línea avanzada},
719   apa:Retrieved={Obtenido de}] % {Disponible desde}]
720
721
722\setupbtxlabeltext
723  [sv]
724  [apa:number={nr.},
725   apa:edition={Utgåva},
726   apa:Editor=Redaktör,
727   apa:Editors=Redaktörer,
728   apa:Volume=Band,
729   apa:Volumes=Band,
730   apa:nd={u.å.},                  % utan årtal
731   apa:supplement=Bilaga,          % Supplement
732   apa:MotionPicture=Spelfilm,     % ?
733   apa:Writer={Manusförfattare},   % Assuming for a movie
734   apa:Writers={Manusförfattare},  %
735   apa:Producer=Producent,         % Assuming for a movie
736   apa:Producers=Producenter,      %
737   apa:Director={Regissör},        % Assuming for a movie
738   apa:Directors={Regissörer},     %
739   apa:Recordedby={Inspelad av},   % Assuming for a movie
740   apa:Author={Författare},
741   apa:Translator={Översättare},
742   apa:Advanced={Avancerad onlinepublikation}, % ?
743   apa:Retrieved={Hämtad från}]
744
745% cite setups
746
747% The following differs from the default returning n.d. if year is empty
748
749\startsetups btx:apa:cite:author:year
750    \ifx\currentbtxfirst\empty
751        \def\currentbtxfirst{\fastsetup{\s!btx:apa:nd}}
752    \fi
753    \fastsetup{\s!btx:\s!cite:author:year}
754\stopsetups
755
756\startsetups btx:apa:cite:author:years
757    \ifx\currentbtxfirst\empty
758        \def\currentbtxfirst{\fastsetup{\s!btx:apa:nd}}
759    \fi
760    \fastsetup{\s!btx:\s!cite:author:years}
761\stopsetups
762
763% these setups need to be explicitly defined in order to get cite rendering
764
765\startsetups \s!btx:apa:\s!cite:organization
766    \fastsetup{\s!btx:\s!cite:normal}
767\stopsetups
768
769\startsetups \s!btx:apa:\s!cite:subtitle
770    \fastsetup{\s!btx:\s!cite:normal}
771\stopsetups
772
773\startsetups \s!btx:apa:\s!cite:booktitle
774    \fastsetup{\s!btx:\s!cite:normal}
775\stopsetups
776
777\startsetups \s!btx:apa:\s!cite:subbooktitle
778    \fastsetup{\s!btx:\s!cite:normal}
779\stopsetups
780
781% are these needed?
782
783\startsetups \s!btx:apa:\s!cite:title:inbook
784    \fastsetup{\s!btx:\s!cite:normal}
785\stopsetups
786
787\startsetups \s!btx:apa:\s!cite:title:incollection
788    \fastsetup{\s!btx:\s!cite:normal}
789\stopsetups
790
791\startsetups \s!btx:apa:\s!cite:title:inproceedings
792    \fastsetup{\s!btx:\s!cite:normal}
793\stopsetups
794
795\startsetups \s!btx:apa:\s!cite:subtitle:inbook
796    \fastsetup{\s!btx:\s!cite:normal}
797\stopsetups
798
799\startsetups \s!btx:apa:\s!cite:subtitle:incollection
800    \fastsetup{\s!btx:\s!cite:normal}
801\stopsetups
802
803\startsetups \s!btx:apa:\s!cite:subtitle:inproceedings
804    \fastsetup{\s!btx:\s!cite:normal}
805\stopsetups
806
807% used in publ-imp-page.mkvi
808
809\startsetups btx:apa:list:page-or-pages
810    \ifx\currentbtxlastpage\empty
811        \btxlabeltext{p}
812    \else
813        \btxlabeltext{pp}
814    \fi
815    \btxnbsp
816\stopsetups
817
818% The sameauthor feature may not be APA compliant
819% (there is nothing in the manual cited above).
820% It can be removed using the command:
821% \resetsetups [apa:list:sameauthor]
822
823% :rule, :empty or :ditto ...
824
825\startsetups apa:list:sameauthor
826    \fastsetup{apa:list:sameauthor:rule}
827\stopsetups
828
829\startsetups apa:list:sameauthor:rule
830    \blackrule
831      [\c!width=\dimexpr\listparameter\c!margin-\interwordspace\relax,
832       \c!height=1.5\linewidth]% \linewidth is just too thin with respect to font strokes...
833\stopsetups
834
835\startsetups [apa:list:sameauthor:\v!empty]
836    \kern\dimexpr\listparameter\c!margin-\interwordspace\relax
837\stopsetups
838
839% horrible !
840
841\startsetups apa:list:sameauthor:ditto
842    \inframed
843      [\c!width=\dimexpr\listparameter\c!margin-\interwordspace\relax,
844       \c!frame=\v!off,
845       \c!align=\v!middle]
846      {\doubleprime}
847\stopsetups
848
849%D Instead of texdefinitions without arguments, we could have used setups but in my
850%D editor (hh, scite) the commands stand out better. It also saves an additional
851%D component in the name (e.g. common:) because commands and setups have a different
852%D namespace, so similar calls don't clash. Performance of definitions is somewhat
853%D better.
854
855%D We use "texdefinitions" (with eventual arguments) for helpers that are used
856%D in the rendering "setups" defined for each category below.
857
858%D Note that \btxdoif... and \btxflush rely on the definitions in
859%D publ-imp-apa.lua: fields that are not listed as required nor optional are
860%D IGNORED. We also make heavy use of the notion of sets - comma-separated lists
861%D of alternative fields to be used in hierarchal order. For example:
862%D author = { "author", "editor", "publisher", "title" }, will return the
863%D author field if it exists; if not, the editor field will be returned, if it
864%D exists; if not, the publisher field will be returned, if it exists; if not,
865%D the title field will be returned, it it exists; if not, nothing will be
866%D returned. In lua syntax, it can be understood as
867%D author or editor or publisher or title or ""
868
869\starttexdefinition mutable protected btx:apa:setlanguage #language
870    \language[#language]
871    \doifelse{#language}{french}
872        {\setcharacterspacing[frenchpunctuation]}
873        {\doifelse{#language}{fr}
874          {\setcharacterspacing[frenchpunctuation]}
875          {\setcharacterspacing[nofrenchpunctuation]}
876        }
877\stoptexdefinition
878
879% #title can be title or booktitle
880
881\starttexdefinition mutable protected btx:apa:translated-title #title
882    \ifx\currentbtxlanguage\empty
883        % no need for an extra
884    \else\ifx\mainbtxlanguage\currentbtxlanguage
885        % no need for an extra
886    \else
887        \btxdoif {#title:\mainbtxlanguage} {
888            \begingroup % does this limit scope?
889                \texdefinition{btx:apa:setlanguage}{\mainbtxlanguage}
890                \btxleftbracket
891                \btxusecommand [apa:\s!list:#title:\currentbtxcategory] {
892                    \btxflush{#title:\mainbtxlanguage}
893                }
894                \btxrightbracket
895                \texdefinition{btx:apa:setlanguage}{\currentbtxlanguage}
896            \endgroup
897        }
898    \fi\fi
899\stoptexdefinition
900
901\starttexdefinition mutable protected btx:apa:composed-title #title
902    \btxstartstyleandcolor[apa:\s!list:#title:\currentbtxcategory]
903        \begingroup
904            \texdefinition{btx:apa:setlanguage}{\currentbtxlanguage}
905            \btxusecommand [apa:\s!list:#title:\currentbtxcategory] {
906                \btxflush{#title}
907                \btxdoif {sub#title} {
908                    \btxcolon
909                    \btxflush{sub#title}
910                }
911            }
912            \texdefinition{btx:apa:setlanguage}{\mainbtxlanguage}
913        \endgroup
914        % which namespace?
915        %\doif{\btxparameter{translate}}\v!yes {
916        %
917        % An option is unnecessary because the translated title
918        % only gets placed if the user includes a title:xx field
919        % for the entry - not standard for bibtex...
920        %
921            \texdefinition{btx:apa:translated-title}{#title}
922        %}
923    \btxstopstyleandcolor
924\stoptexdefinition
925
926\starttexdefinition mutable protected btx:apa:title
927    \setmode{btx:apa:title-placed}
928    % we make the title active, opening "file"
929    \btxdoifelse {file} {
930        \texdefinition{btx:format:goto}
931            {url(file:\btxflush{file})}
932            {
933                \texdefinition{btx:apa:composed-title}{title}
934            }
935    } {
936        \texdefinition{btx:apa:composed-title}{title}
937    }
938    \btxdoif {title} {
939        % A book might have an editor AND an author
940        \doif {\currentbtxcategory} {book} {
941            \doifnot {\btxfoundname{author}} {editor} {
942                \btxdoif {ineditor} { % ineditor specific authorconversion
943                    \btxleftparenthesis
944                    \btxflush{ineditor}
945                    \btxcomma
946                    \btxsingularorplural {ineditor} {
947                        \btxlabeltext{apa:Editor}
948                    } {
949                        \btxlabeltext{apa:Editors}
950                    }
951                    \btxrightparenthesis
952                }
953            }
954        }
955        \btxdoif {translator} {
956            \btxleftparenthesis
957                \btxflush{translator}
958                \btxcomma
959                \btxlabeltext{apa:Translator}
960            \btxrightparenthesis
961        }
962    }
963\stoptexdefinition
964
965\starttexdefinition mutable protected btx:apa:title-if-not-placed
966    \doifelsemode {btx:apa:title-placed} {
967        \resetmode{btx:apa:title-placed}
968    } {
969        \btxdoif {title} {
970            \btxperiod
971            \texdefinition {btx:apa:title}
972        }
973    }
974\stoptexdefinition
975
976\startsetups btx:apa:nd
977    \btxlabeltext{apa:nd}
978\stopsetups
979
980\starttexdefinition mutable protected btx:apa:suffixedyear
981    \btxdoifelse {year} {
982        \btxflush{year}
983        \btxflushsuffix
984        \btxdoif {month} { % month and day optional in publ-imp-apa.lua
985            \btxcomma
986            \btxflush{month}
987            \btxdoif {day} {
988                \btxspace
989                \btxflush{day}
990            }
991        }
992    } {
993        \fastsetup{btx:apa:nd}
994        % Hans: the following won't work but should.
995        \btxdoif {suffix} {
996            \btxspace
997            \btxflushsuffix
998            % Hans: similarly, why can't \btxflush{suffix} be made to work?
999        }
1000    }
1001\stoptexdefinition
1002
1003% #author may be author(set) or editor
1004
1005\starttexdefinition mutable protected btx:apa:author-or-editor #author
1006    \btxdoifelse {#author} {
1007        \btxstartstyleandcolor[apa:\s!list:#author]
1008            \btxusecommand[apa:\s!list:#author]{
1009                \btxflush{#author}
1010            }
1011        \btxstopstyleandcolor
1012        % use \processaction [] [] here?
1013        \doifelse {\btxfoundname{#author}} {editor} {
1014            \btxleftparenthesis
1015            \btxsingularorplural {editor} {
1016                \btxlabeltext{apa:Editor}
1017            } {
1018                \btxlabeltext{apa:Editors}
1019            }
1020            \btxrightparenthesis
1021        } {\doif {\btxfoundname{#author}} {ineditor} {
1022            \btxleftparenthesis
1023            \btxsingularorplural {ineditor} {
1024                \btxlabeltext{apa:Editor}
1025            } {
1026                \btxlabeltext{apa:Editors}
1027            }
1028            \btxrightparenthesis
1029        } }
1030        \doif {\currentbtxcategory} {film} {
1031            \btxleftparenthesis
1032            \doifelse {\btxfoundname{#author}} {director} {
1033                \btxsingularorplural {director} {
1034                    \btxlabeltext{apa:Director}
1035                } {
1036                    \btxlabeltext{apa:Directors}
1037                }
1038            } {
1039                \doif {\btxfoundname{#author}} {author} {
1040                    \btxsingularorplural {author} {
1041                        \btxlabeltext{apa:Writer}
1042                    } {
1043                        \btxlabeltext{apa:Writers}
1044                    }
1045                }
1046                \doif {\btxfoundname{#author}} {producer} {
1047                    \btxsingularorplural {producer} {
1048                        \btxlabeltext{apa:Producer}
1049                    } {
1050                        \btxlabeltext{apa:Producers}
1051                    }
1052                }
1053                \btxdoif {director} {
1054                    \btxrightparenthesis
1055                    \removeunwantedspaces
1056                    \btxparameter{\c!separator:names:3}
1057                    \btxstartstyleandcolor[apa:\s!list:director]
1058                        \btxusecommand[apa:\s!list:director]{
1059                            \btxflush{director}
1060                        }
1061                    \btxstopstyleandcolor
1062                    \btxleftparenthesis
1063                    \btxsingularorplural {director} {
1064                        \btxlabeltext{apa:Director}
1065                    } {
1066                        \btxlabeltext{apa:Directors}
1067                    }
1068                }
1069            }
1070            \btxrightparenthesis
1071        }
1072        \btxdoif {withauthor} {
1073            \btxleftparenthesis
1074            \btxlabeltext{with}
1075            \btxspace
1076            \btxstartstyleandcolor[apa:\s!list:withauthor]
1077                \btxusecommand[apa:\s!list:withauthor]{
1078                    \btxflush{withauthor}
1079                }
1080            \btxstopstyleandcolor
1081            \btxrightparenthesis
1082        }
1083    } {
1084        \texdefinition{btx:apa:title}
1085    }
1086\stoptexdefinition
1087
1088\starttexdefinition mutable protected btx:apa:authoryear
1089    % we make the authoryear active, pointing to the citation
1090    \texdefinition{btx:format:gotointernal}
1091        {
1092            \doifelsesetups{apa:list:sameauthor} {
1093                \btxdoifelsesameasprevious {author} {
1094                    \fastsetup{apa:list:sameauthor}
1095                } {
1096                    \texdefinition{btx:apa:author-or-editor} {author}
1097                }
1098            } {
1099                \texdefinition{btx:apa:author-or-editor} {author}
1100            }
1101            \btxleftparenthesis
1102            \texdefinition{btx:apa:suffixedyear}
1103            \btxrightparenthesis
1104        }
1105    % outside of interaction
1106    \doif {\btxfoundname{author}} {title} {
1107        \setmode{btx:apa:title-placed}
1108    }
1109\stoptexdefinition
1110
1111\starttexdefinition mutable protected btx:apa:editor-in
1112    \btxdoif {booktitle} {
1113        \btxperiod
1114        \btxlabeltext{In}
1115        \btxspace
1116        \doifnot {\btxfoundname{author}} {editor} {
1117            \btxdoif {ineditor} {
1118                \texdefinition{btx:apa:author-or-editor} {ineditor}
1119                \btxcomma
1120            }
1121        }
1122        \texdefinition{btx:apa:composed-title}{booktitle}
1123    }
1124\stoptexdefinition
1125
1126\starttexdefinition mutable protected btx:apa:organization-if-not-author
1127    \btxdoif {organization} {
1128        \doifnot {\btxfoundname{author}} {organization} {
1129            \btxspace
1130            \btxflush{organization}
1131            \btxcomma
1132        }
1133    }
1134\stoptexdefinition
1135
1136\starttexdefinition mutable protected btx:apa:leftparenthesis-or-comma
1137    \doifelsemode {btx:apa:editionset-is-empty} {
1138        \btxleftparenthesis
1139        \resetmode{btx:apa:editionset-is-empty}
1140    } {
1141        \btxcomma
1142    }
1143\stoptexdefinition
1144
1145\starttexdefinition mutable protected btx:apa:editionset
1146    \setmode{btx:apa:editionset-is-empty}
1147    \doif {\currentbtxcategory} {techreport} {
1148        \texdefinition{btx:apa:leftparenthesis-or-comma}
1149        \btxdoifelse {type} {
1150            \btxusecommand [apa:\s!list:type] {
1151                \btxflush{type}
1152            }
1153        } {
1154            \btxlabeltext{technicalreport}
1155        }
1156    }
1157    \btxdoif {volume} {
1158        \texdefinition{btx:apa:leftparenthesis-or-comma}
1159        \btxoneorrange {volume} {
1160            \btxlabeltext{apa:Volume}
1161        } {
1162            \btxlabeltext{apa:Volumes}
1163        }
1164        \btxspace
1165        \btxflush{volume}
1166    }
1167    \btxdoif {number} {
1168        \texdefinition{btx:apa:leftparenthesis-or-comma}
1169        \btxlabeltext{apa:number}
1170        \btxspace
1171        \btxflush{number}
1172    }
1173    \btxdoif {edition} {
1174        \texdefinition{btx:apa:leftparenthesis-or-comma}
1175        % the edition= field is often language-dependent
1176        % (i.e. second, 2nd, revised, etc.)
1177        % so we handle an optional edition:xx= field:
1178        \btxdoifelse  {edition:\mainbtxlanguage}
1179            {\btxflush{edition:\mainbtxlanguage}}
1180            {\btxflush{edition}}
1181        \btxspace
1182        \btxlabeltext{apa:edition}
1183    }
1184    \btxdoif {pages} {
1185        \texdefinition{btx:apa:leftparenthesis-or-comma}
1186        \btxoneorrange {pages} {
1187            \btxlabeltext{p}
1188        } {
1189            \btxlabeltext{pp}
1190        }
1191        \btxnbsp
1192        \btxflush{pages}
1193    }
1194    \doifnotmode {btx:apa:editionset-is-empty} {
1195        \btxrightparenthesis
1196    }
1197    \btxperiod
1198\stoptexdefinition
1199
1200\starttexdefinition mutable protected btx:apa:journal
1201    \btxstartstyleandcolor[apa:\s!list:journal]
1202        \btxusecommand [apa:\s!list:journal] {
1203            \btxflush{journal}
1204        }
1205    \btxstopstyleandcolor
1206\stoptexdefinition
1207
1208\starttexdefinition mutable protected btx:apa:volume
1209    \btxstartstyleandcolor[apa:\s!list:volume]
1210        \btxflush{volume}
1211    \btxstopstyleandcolor
1212\stoptexdefinition
1213
1214 % this could be simplified!
1215
1216\starttexdefinition mutable protected btx:apa:journal-volume-number-pages
1217    \btxdoif {journal} {
1218        \btxspace
1219        \texdefinition{btx:apa:journal}
1220        \btxdoifelse {volume} {
1221            \btxcomma
1222            \texdefinition{btx:apa:volume}
1223            \btxdoif {number} {
1224                %\btxleftparenthesis
1225                (\btxflush{number}
1226                \btxrightparenthesis
1227            }
1228        } {
1229            \btxdoif {number} {
1230                \btxcomma
1231                \btxleftparenthesis
1232                \btxflush{number}
1233                \btxrightparenthesis
1234            }
1235        }
1236        \btxdoif {pages} {
1237            \btxcomma
1238            \doif {\currentbtxcategory} {newspaper} {
1239                \btxoneorrange {pages} {
1240                    \btxlabeltext{p}
1241                } {
1242                    \btxlabeltext{pp}
1243                }
1244                \btxnbsp
1245            }
1246            \btxflush{pages}
1247        }
1248        \btxperiod
1249        \doifnot {\currentbtxcategory} {newspaper} {
1250            \btxdoifnot {volume} {
1251                \btxdoifnot {number} {
1252                    \btxdoifnot {pages} {
1253                        \btxdoif {doi} {%set: doi or url
1254                            \btxspace
1255                            \btxlabeltext{apa:Advanced}
1256                            \btxperiod
1257                        }
1258                    }
1259                }
1260            }
1261        }
1262    }
1263\stoptexdefinition
1264
1265\starttexdefinition mutable protected btx:apa:wherefrom-publisher
1266    \btxdoifelse {address} {
1267        \btxflush{address}
1268        \btxdoif {country} {
1269            \btxcomma
1270            \btxflush{country}
1271        }
1272        \btxcolon
1273    } {
1274        \btxdoif {country} {
1275            \btxflush{country}
1276            \btxcolon
1277        }
1278    }
1279    \doifelse {\btxfoundname{author}} {\btxfoundname{publisher}} {
1280        \btxlabeltext{apa:Author}
1281    } {
1282        \btxdoifelse {publisher} {
1283            \btxflush{publisher}
1284        } {
1285            \btxlabeltext{apa:Author}
1286        }
1287    }
1288    \btxperiod
1289\stoptexdefinition
1290
1291% use \btxentry here?
1292
1293% Alan's editor does not want lines to begin with these characters:
1294\sethyphenatedurlafter{:./-_}
1295
1296\starttexdefinition mutable protected btx:apa:url
1297    \texdefinition {btx:format:goto} {
1298        url(\btxflush{url})
1299    } {
1300        \hyphenatedurl{\btxflush{url}}
1301    }
1302\stoptexdefinition
1303
1304% use \btxentry here?
1305
1306\starttexdefinition mutable protected btx:apa:doi
1307    \texdefinition {btx:format:goto} {
1308        url(http://dx.doi.org/\btxflush{doi})
1309    } {
1310       \hyphenatedurl{doi:\btxflush{doi}}
1311    }
1312\stoptexdefinition
1313
1314\starttexdefinition mutable protected btx:apa:note
1315    \btxdoif {note} {
1316        \btxleftparenthesis
1317        \btxflush{note}
1318        \btxrightparenthesis
1319    }
1320\stoptexdefinition
1321
1322\starttexdefinition mutable protected btx:apa:url-doi-note
1323    \doif {\btxfoundname{doi}} {url} {
1324        \btxspace
1325        \btxlabeltext{apa:Retrieved}
1326        \btxspace
1327        \texdefinition{btx:apa:url}
1328    }
1329    \doif {\btxfoundname{doi}} {doi} {
1330        \btxspace
1331        \texdefinition{btx:apa:doi}
1332    }
1333    % should the following be hyperlinks? To where?
1334    \btxdoif {issn} {
1335        \btxspace
1336        \hyphenatedurl{issn:\btxflush{issn}}
1337    }
1338    \btxdoif {isbn} {
1339        \btxspace
1340        \hyphenatedurl{isbn:\btxflush{isbn}}
1341    }
1342    \texdefinition{btx:apa:note}
1343    \removeunwantedspaces
1344\stoptexdefinition
1345
1346\starttexdefinition mutable protected btx:apa:type
1347    \btxdoif {type} {
1348        \btxleftbracket
1349        \btxflush{type}
1350        \btxrightbracket
1351    }
1352\stoptexdefinition
1353
1354% Then setups, by category
1355
1356% An article from a journal
1357% Required fields: author or organization or editor or title, journal, (year).
1358% Optional fields: volume, number, pages, type, doi, url, note.
1359% Note that bibtex (and tools) do not include editor (e.g. special issue or section)
1360
1361\startsetups btx:apa:list:article
1362    \texdefinition{btx:apa:authoryear}
1363    \texdefinition{btx:apa:title-if-not-placed}
1364    \texdefinition{btx:apa:type}
1365    \btxperiod
1366    \texdefinition{btx:apa:journal-volume-number-pages}
1367    \texdefinition{btx:apa:url-doi-note}
1368\stopsetups
1369
1370% An article from a magazine.
1371% Required fields: author or title, journal, (year).
1372% Optional fields: number, pages, type, month, day, doi, url, note.
1373
1374\startsetups btx:apa:list:magazine
1375    \fastsetup{btx:apa:list:article}
1376\stopsetups
1377
1378% An article from a newspaper.
1379% Required fields: author or title, journal, (year).
1380% Optional fields: volume, number, pages, type, month, day, doi, url, note.
1381
1382\startsetups btx:apa:list:newspaper
1383    \fastsetup{btx:apa:list:article}
1384\stopsetups
1385
1386% A complete issue of a periodical, such as a special issue of a journal.
1387% Required fields: title, year
1388% Optional fields: editor, publisher, subtitle, series, volume, number, month, organization, doi, url, issn, note
1389
1390% needs to be tuned...
1391
1392\startsetups btx:apa:list:periodical
1393    \fastsetup{btx:apa:list:article}
1394\stopsetups
1395
1396% National and international standards issued by a standards body
1397% Required fields: author, institution, or organization, year, title
1398% Optional fields: subtitle, doi, url, note
1399
1400\startsetups btx:apa:list:standard
1401    \texdefinition{btx:apa:authoryear}
1402    \texdefinition{btx:apa:title-if-not-placed}
1403    \btxperiod
1404    \texdefinition{btx:apa:url-doi-note}
1405\stopsetups
1406
1407% A book with an explicit publisher.
1408% Required fields: author or editor or publisher, title, (year).
1409% Optional fields: volume or number, series, address, edition, month, day, note.
1410% APA ignores: month, day
1411
1412% todo: series?
1413
1414\startsetups btx:apa:list:book
1415    \texdefinition{btx:apa:authoryear}
1416    \texdefinition{btx:apa:title-if-not-placed}
1417    \texdefinition{btx:apa:type}
1418    \texdefinition{btx:apa:editionset}
1419    \texdefinition{btx:apa:wherefrom-publisher}
1420    \texdefinition{btx:apa:url-doi-note}
1421\stopsetups
1422
1423% There is some debate about how inbook should differ from incollection
1424
1425% A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.
1426% (note that inbook is handled differently by bibtex and biblatex)
1427% Required fields: author or editor, title, chapter and/or pages, publisher, year.
1428% Optional fields: volume or number, series, type, address, edition, month, note.
1429% We add optional: booktitle.
1430% APA ignores: chapter, month
1431
1432\startsetups btx:apa:list:inbook
1433    \texdefinition{btx:apa:authoryear}
1434    \texdefinition{btx:apa:title-if-not-placed}
1435    \texdefinition{btx:apa:type}
1436    \texdefinition{btx:apa:editor-in}
1437    \texdefinition{btx:apa:editionset}
1438    \texdefinition{btx:apa:wherefrom-publisher}
1439    \texdefinition{btx:apa:url-doi-note}
1440\stopsetups
1441
1442% A part of a book having its own title.
1443% Required fields: author, title, booktitle, publisher, year.
1444% Optional fields: editor, volume or number, series, type, chapter, pages, address, edition, month, note.
1445% APA ignores: chapter, month
1446
1447\startsetups btx:apa:list:incollection
1448    \fastsetup{btx:apa:list:inbook}
1449\stopsetups
1450
1451% The proceedings of a conference.
1452% Required fields: title, year.
1453% Optional fields: editor, volume or number, series, address, month, organization, publisher, note.
1454% todo: series?
1455
1456\startsetups btx:apa:list:proceedings
1457    \fastsetup{btx:apa:list:book}
1458\stopsetups
1459
1460% An article in a conference proceedings.
1461% Required fields: author, title, booktitle, year.
1462% Optional fields: editor, volume or number, series, pages, address, month, organization, publisher, note.
1463
1464\startsetups btx:apa:list:inproceedings
1465    \texdefinition{btx:apa:authoryear}
1466    \texdefinition{btx:apa:title-if-not-placed}
1467    \texdefinition{btx:apa:editor-in}
1468    \texdefinition{btx:apa:editionset}
1469    \texdefinition{btx:apa:organization-if-not-author}
1470    \texdefinition{btx:apa:wherefrom-publisher}
1471    \texdefinition{btx:apa:url-doi-note}
1472\stopsetups
1473
1474\startsetups btx:apa:list:conference
1475    \fastsetup{btx:apa:list:inproceedings}
1476\stopsetups
1477
1478% A thesis.
1479% Required fields: author, title, school, year.
1480% Optional fields: type, address, month, note.
1481
1482\startsetups btx:apa:list:thesis
1483    \texdefinition{btx:apa:authoryear}
1484    \texdefinition{btx:apa:title-if-not-placed}
1485    \btxleftparenthesis
1486    \btxdoifelse {type} {
1487        \btxusecommand [apa:\s!list:type] {
1488            \btxflush{type}
1489        }
1490    } {
1491        \btxlabeltext{\currentbtxcategory}
1492    }
1493    \btxrightparenthesis
1494    \btxdoif {school} {
1495        \btxperiod
1496        \btxflush{school}
1497    }
1498    \btxdoif {address} {
1499        \btxdoifelse {school} {
1500            \btxcomma
1501        } {
1502            \btxperiod
1503        }
1504        \btxflush{address}
1505        \btxdoif {country} {
1506            \btxcomma
1507            \btxflush{country}
1508        }
1509    }
1510    \btxperiod
1511    \texdefinition{btx:apa:url-doi-note}
1512\stopsetups
1513
1514\startsetups btx:apa:list:phdthesis
1515    \fastsetup{btx:apa:list:thesis}
1516\stopsetups
1517
1518\startsetups btx:apa:list:mastersthesis
1519    \fastsetup{btx:apa:list:thesis}
1520\stopsetups
1521
1522% A work that is printed and bound, but without a named publisher or sponsoring institution.
1523% Required field: title.
1524% Optional fields: author, howpublished, address, month, year, note.
1525
1526\startsetups btx:apa:list:booklet
1527    \fastsetup{btx:apa:list:book}
1528\stopsetups
1529
1530% Technical documentation.
1531% Required field: title.
1532% Optional fields: author, organization, address, edition, month, year, note.
1533
1534\startsetups btx:apa:list:manual
1535    \fastsetup{btx:apa:list:book}
1536\stopsetups
1537
1538% A report published by a school or other institution, usually numbered within a series.
1539% Required fields: author, title, institution, year.
1540% Optional fields: type, number, address, month, note.
1541
1542\startsetups btx:apa:list:techreport
1543    \fastsetup{btx:apa:list:book}
1544\stopsetups
1545
1546% A document having an author and title, but not formally published.
1547% Required fields: author, title, note.
1548% Optional fields: month, year.
1549
1550\startsetups btx:apa:list:unpublished
1551    \fastsetup{btx:apa:list:book}
1552\stopsetups
1553
1554% A patent. Note that this category was not defined with BIBTEX. Below from JabRef:
1555% Required fields: nationality, number, year, yearfiled
1556% Optional fields: author, title, assignee, address, type, number, day, dayfiled, month, monthfiled, note, url
1557% Also optional: publisher
1558
1559% todo: yearfiled, monthfiled, dayfiled
1560
1561\startsetups btx:apa:list:patent
1562    \texdefinition{btx:apa:authoryear}
1563    \texdefinition{btx:apa:title-if-not-placed}
1564    \begingroup
1565        \it
1566        \btxdoif {nationality} {
1567            \btxspace
1568            \btxflush{nationality}
1569        }
1570        \btxspace
1571        \btxdoifelse{type}{
1572            \btxflush{type}
1573        }{
1574            \btxlabeltext{patent}
1575        }
1576        \btxdoif {number} {
1577            \btxspace
1578            \btxlabeltext{apa:number}
1579            \btxspace
1580            \btxflush{number}
1581        }
1582        \btxperiod
1583        \italiccorrection
1584    \endgroup
1585    \texdefinition{btx:apa:wherefrom-publisher}
1586    \texdefinition{btx:apa:url}
1587    \texdefinition{btx:apa:note}
1588\stopsetups
1589
1590% Electronic. Note that this category was not defined with BIBTEX. Below from JabRef:
1591% Required fields: title
1592% Optional fields: address, author, howpublished, month, note, organization, url, year, doi
1593% Also optional: type
1594
1595% Like Misc below but includes organization.
1596
1597\startsetups btx:apa:list:electronic
1598    \texdefinition{btx:apa:authoryear}
1599    \texdefinition{btx:apa:title-if-not-placed}
1600    \texdefinition{btx:apa:type}
1601    \texdefinition{btx:apa:organization-if-not-author}
1602    \btxdoif {howpublished} {
1603        \btxspace
1604        \btxflush{howpublished}
1605        \btxperiod
1606    }
1607    \texdefinition{btx:apa:url-doi-note}
1608\stopsetups
1609
1610% Film. Note that this category was not defined with BIBTEX.
1611% Required fields: producer, director, title, year, address, publisher
1612% Optional fields: subtitle, type, note, url, doi
1613
1614\startsetups btx:apa:list:film
1615    \texdefinition{btx:apa:authoryear}
1616    \texdefinition {btx:apa:title}
1617    \btxleftbracket
1618        \btxdoifelse {type} {
1619            \btxflush{type}
1620        } {
1621            \btxlabeltext{apa:MotionPicture}
1622        }
1623    \btxrightbracketperiod
1624    \texdefinition{btx:apa:wherefrom-publisher}
1625    \texdefinition{btx:apa:url-doi-note}
1626\stopsetups
1627
1628% Music. Note that this category was not defined with BIBTEX.
1629% Required fields: composer, artist, title, album, year, address, publisher
1630% Optional fields: subtitle, type, note, url, doi
1631
1632\startsetups btx:apa:list:music
1633    \texdefinition{btx:apa:authoryear}
1634    \texdefinition{btx:apa:title-if-not-placed}
1635    \doifnot {\btxfoundname{author}} {artist} {
1636        \btxdoif {artist} {
1637            \btxleftbracket
1638            \btxlabeltext{apa:Recordedby}
1639            \btxspace
1640            \btxflush{artist}
1641            \btxrightbracketperiod
1642        }
1643    }
1644    \doifnot {\btxfoundname{title}} {album} {
1645        \btxdoif {album} {
1646            \btxperiod
1647            \btxlabeltext{In}
1648            \btxspace
1649            \btxflush{album}
1650        }
1651    }
1652    \texdefinition{btx:apa:type}
1653    \texdefinition{btx:apa:wherefrom-publisher}
1654    \texdefinition{btx:apa:url-doi-note}
1655\stopsetups
1656
1657% Other. Note that this category was not defined with BIBTEX. Below from JabRef:
1658% Required fields: author or title, year
1659% Optional fields: note, doi, url
1660
1661\startsetups btx:apa:list:other
1662    \fastsetup{btx:apa:list:book}
1663\stopsetups
1664
1665% Use this category when nothing else fits.
1666% Required fields: none.
1667% Optional fields: author, title, howpublished, month, year, note.
1668
1669\startsetups btx:apa:list:misc
1670    \texdefinition{btx:apa:authoryear}
1671    \texdefinition{btx:apa:title-if-not-placed}
1672    \btxperiod
1673    \btxdoif {howpublished} {
1674        \btxspace
1675        \btxflush{howpublished}
1676        \btxperiod
1677    }
1678    \texdefinition{btx:apa:url-doi-note}
1679\stopsetups
1680
1681% If all else fails to match:
1682
1683\startsetups btx:apa:list:literal
1684    %\btxleftparenthesis
1685    \removeunwantedspaces(
1686    \btxflush{tag}
1687    \btxrightparenthesis
1688    \btxdoif {text} {
1689        \btxflush{text}
1690    }
1691\stopsetups
1692
1693% HH: an example of setting up translations using a sub rendering. Keep it here
1694% till we find another spot as otherwise I forget about it and I don't want to
1695% waste hours reinventing a wheel when something like this is needed.
1696%
1697% \definebtx
1698%   [apa:cite:title:translated]
1699%   [apa:cite:title]
1700%   [left=\btxleftbracket,
1701%    right=\btxrightbracket,
1702%    style=\v!bolditalic]
1703%
1704% \startsetups btx:apa:cite:title
1705%     % need to add concat, etc.
1706%     \btxcitereference
1707%     \currentbtxfirst
1708%     \doifmode {btx:apa:translatedtitles} {
1709%         \ifx\currentbtxlanguage\empty
1710%             % no need for an extra
1711%         \else\ifx\mainbtxlanguage\currentbtxlanguage
1712%             % no need for an extra
1713%         \else
1714%             \btxdoif {title:\mainbtxlanguage} {
1715%                 \btxstartciterendering[title:translated]
1716%                     \language[\mainbtxlanguage]
1717%                     \btxflush{title:\mainbtxlanguage}
1718%                 \btxstopciterendering
1719%             }
1720%         \fi\fi
1721%     }
1722% \stopsetups
1723
1724\stopbtxrenderingdefinitions
1725