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