publ-imp-aps.mkvi /size: 27 Kb    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=publ-imp-aps,
3%D        version=2015.03.22,
4%D          title=APS 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[aps]
14
15%D Reference:
16%D \startTEX
17%D @Book{APS2011,
18%D     title    ={Physical Review Style and Notation Guide}
19%D     year     ={2011},
20%D     month    ={June}
21%D     edition  ={Revised},
22%D     editor   ={Waldron, A and Judd, P. and Miller, V.},
23%D     address  ={Ridge, NY},
24%D     publisher={American Physical Society},
25%D     Xpages   ={26},
26%D     url      ={http://journals.aps.org/files/styleguide-pr.pdf}
27%D }
28%D \stopTEX
29
30% set ALL specific APS compliant values
31
32\definebtx
33  [aps]
34  [\c!default=default,
35   \c!specification=aps,
36   \c!otherstext={\btxspace{\it\btxlabeltext{others}}},
37   \c!etallimit=10,
38   \c!etaldisplay=\btxparameter\c!etallimit,
39   %c!journalconversion=\v!normal,
40   \c!monthconversion=\v!month,
41   \c!title=\v!yes,
42   \c!separator:names:2={\btxcomma},
43   \c!separator:names:3={\btxcomma\btxlabeltext{and}\space},
44   \c!separator:names:4={\btxspace\btxlabeltext{and}\space}]
45
46% First, define and set list and rendering parameters
47
48\definebtxrendering
49  [aps]
50  [\c!specification=aps,
51   \c!sorttype=\v!default,
52   \c!numbering=num]
53
54\setupbtxlist
55  [aps]
56  [\c!alternative=b, % spaces
57   \c!align={normal,verytolerant,stretch}]
58
59\definebtx
60  [aps:\s!list]
61  [aps]
62  [\c!authorconversion=normalshort]
63
64\definebtx
65  [aps:\s!list:author]
66  [aps:\s!list]
67
68\definebtx
69  [aps:\s!list:editor]
70  [aps:\s!list:author]
71
72\definebtx
73  [aps:\s!list:suffix]
74  [aps:\s!list]
75
76\definebtx
77  [aps:\s!list:url]
78  [aps:\s!list]
79
80\definebtx
81  [aps:\s!list:doi]
82  [aps:\s!list]
83
84\definebtx
85  [aps:\s!list:\s!page]
86  [aps:\s!list]
87  [\c!separator:2={\btxcomma},
88   \c!separator:3={\btxcomma\btxlabeltext{and}\space},
89   \c!separator:4={\btxspace\btxlabeltext{and}\space},
90   \c!left={\btxleftparenthesis},
91   \c!right={\btxrightparenthesis},
92   \c!command={\wordright}]
93
94\definebtx
95  [aps:\s!list:numbering]
96  [aps:\s!list]
97  [left={[},
98   right={]}]
99
100\definebtx
101  [aps:\s!list:numbering:default]
102  [aps:\s!list:numbering]
103
104\definebtx
105  [aps:\s!list:numbering:num]
106  [aps:\s!list:numbering]
107
108\definebtx
109  [aps:\s!list:numbering:short]
110  [aps:\s!list:numbering]
111
112\definebtx
113  [aps:\s!list:numbering:tag]
114  [aps:\s!list:numbering]
115
116\definebtx
117  [aps:\s!list:numbering:index]
118  [aps:\s!list:numbering]
119
120%D In order to be able to get journals expanded (or normalized or abbreviated) you need
121%D to load a list:
122%D
123%D \starttyping
124%D \btxloadjournallist[journals.txt] % the jabref list
125%D \stoptyping
126
127% TODO
128
129\definebtx
130  [aps:\s!list:journal]
131  [aps:\s!list]
132  [\c!style=\v!italic]
133  %command=\btxexpandedjournal] % btxabbreviatedjournal
134
135\definebtx
136  [aps:\s!list:volume]
137  [aps:\s!list]
138  [\c!style=\v!bold]
139
140\definebtx
141  [aps:\s!list:title]
142  [aps:\s!list]
143  [\c!style=\v!italic,
144   \c!command=\Word]
145
146\definebtx
147  [aps:\s!list:title:article]
148  [aps:\s!list:title]
149  [\c!style=] % journal is set in italics
150
151\definebtx
152  [aps:\s!list:title:magazine]
153  [aps:\s!list:title]
154
155\definebtx
156  [aps:\s!list:title:newspaper]
157  [aps:\s!list:title]
158
159\definebtx
160  [aps:\s!list:title:periodical]
161  [aps:\s!list:title]
162
163\definebtx
164  [aps:\s!list:title:standard]
165  [aps:\s!list:title]
166
167\definebtx
168  [aps:\s!list:title:book]
169  [aps:\s!list:title]
170
171\definebtx
172  [aps:\s!list:title:inbook]
173  [aps:\s!list:title]
174
175\definebtx
176  [aps:\s!list:title:incollection]
177  [aps:\s!list:title]
178  [\c!style=] % booktitle is set in italics
179
180\definebtx
181  [aps:\s!list:title:proceedings]
182  [aps:\s!list:title]
183
184\definebtx
185  [aps:\s!list:title:inproceedings]
186  [aps:\s!list:title]
187  [\c!style=] % booktitle is set in italics
188
189\definebtx
190  [aps:\s!list:title:conference]
191  [aps:\s!list:title]
192  [\c!style=] % booktitle is set in italics
193
194\definebtx
195  [aps:\s!list:title:thesis]
196  [aps:\s!list:title]
197
198\definebtx
199  [aps:\s!list:title:phdthesis]
200  [aps:\s!list:title]
201
202\definebtx
203  [aps:\s!list:title:mastersthesis]
204  [aps:\s!list:title]
205
206\definebtx
207  [aps:\s!list:title:booklet]
208  [aps:\s!list:title]
209
210\definebtx
211  [aps:\s!list:title:manual]
212  [aps:\s!list:title]
213
214\definebtx
215  [aps:\s!list:title:techreport]
216  [aps:\s!list:title]
217
218\definebtx
219  [aps:\s!list:title:unpublished]
220  [aps:\s!list:title]
221
222\definebtx
223  [aps:\s!list:title:patent]
224  [aps:\s!list:title]
225
226\definebtx
227  [aps:\s!list:title:electronic]
228  [aps:\s!list:title]
229
230\definebtx
231  [aps:\s!list:title:other]
232  [aps:\s!list:title]
233
234\definebtx
235  [aps:\s!list:title:misc]
236  [aps:\s!list:title]
237
238\definebtx
239  [aps:\s!list:title:literal]
240  [aps:\s!list:title]
241
242\definebtx
243  [aps:\s!list:type]
244  [\c!command=\Word]
245
246% Then define and set all cite parameters
247
248\definebtx
249  [aps:\s!cite]
250  [aps]
251  [\c!alternative=num,
252   \c!authorconversion=\v!name,
253   \c!compress=\v!yes,
254   \c!sorttype=normal]
255
256\definebtx
257  [aps:\s!cite:name]
258  [aps:\s!cite]
259  [\c!authorconversion=\v!name]
260
261\definebtx
262  [aps:\s!cite:inverted]
263  [aps:\s!cite]
264  [\c!authorconversion=\v!invertedshort]
265
266\definebtx
267  [aps:\s!cite:invertedshort]
268  [aps:\s!cite]
269  [\c!authorconversion=\v!invertedshort]
270
271\definebtx
272  [aps:\s!cite:normalshort]
273  [aps:\s!cite]
274  [\c!authorconversion=\v!normalshort]
275
276\definebtx
277  [aps:\s!cite:normal]
278  [aps:\s!cite]
279  [\c!authorconversion=\v!normal]
280
281\definebtx
282  [aps:\s!cite:author]
283  [aps:\s!cite]
284
285\definebtx
286  [aps:\s!cite:organization]
287  [aps:\s!cite]
288
289\definebtx
290  [aps:\s!cite:authoryear]
291  [aps:\s!cite:author]
292  [\c!left={(},
293   \c!right={)},
294   \c!inbetween={\btxcomma}]
295
296\definebtx
297  [aps:\s!cite:authoryears]
298  [aps:\s!cite:authoryear]
299  [\c!left=,
300   \c!right=,
301   \c!inbetween={\btxspace}]
302
303\definebtx
304  [aps:\s!cite:authornum]
305  [aps:\s!cite:author]
306  [\c!left={(},
307   \c!right={)}]
308
309\definebtx
310  [aps:\s!cite:author:num] % todo
311  [aps:\s!cite:authornum]
312  [\c!left={\btxspace[},
313   \c!right={]}]
314
315\definebtx
316  [aps:\s!cite:author:year] % todo
317  [aps:\s!cite:authoryear]
318  [\c!left=,
319   \c!right=]
320
321\definebtx
322  [aps:\s!cite:author:years] % todo
323  [aps:\s!cite:authoryears]
324  [\c!inbetween=,
325   \c!left={\btxspace(},
326   \c!right={)}]
327
328\definebtx
329  [aps:\s!cite:year]
330  [aps:\s!cite]
331
332\definebtx
333  [aps:\s!cite:title]
334  [aps:\s!cite]
335  [\c!command={\language[\currentbtxlanguage]}, % BAH
336   \c!sorttype=none,
337   \c!style=\v!italic]
338
339\definebtx
340  [aps:\s!cite:booktitle]
341  [aps:\s!cite:title]
342
343\definebtx
344  [aps:\s!cite:tag]
345  [aps:\s!cite]
346  [\c!left={[},
347   \c!right={]}]
348
349\definebtx
350  [aps:\s!cite:index]
351  [aps:\s!cite]
352  [\c!left={[},
353   \c!right={]}]
354
355\definebtx
356  [aps:\s!cite:page]
357  [aps:\s!cite]
358  [\c!left=,
359   \c!right=,
360   \c!separator:2={\btxcomma}, % :0 and :1 - between items of a list
361   \c!separator:3={\btxcomma\btxlabeltext{and}\space},
362   \c!separator:4={\btxspace\btxlabeltext{and}\space}]
363
364\definebtx
365  [aps:\s!cite:pages]
366  [aps:\s!cite:page]
367
368\definebtx
369  [aps:\s!cite:keywords]
370  [aps:\s!cite]
371  [\c!left={(},
372   \c!right={)}]
373
374\definebtx
375  [aps:\s!cite:short]
376  [aps:\s!cite]
377  [\c!left={[},
378   \c!right={]}]
379
380\definebtx
381  [aps:\s!cite:category]
382  [aps:\s!cite]
383
384\definebtx
385  [aps:\s!cite:url]
386  [aps:\s!cite]
387  [\c!left={(},
388   \c!right={)}]
389
390\definebtx
391  [aps:\s!cite:doi]
392  [aps:\s!cite:url]
393
394\definebtx
395  [aps:\s!cite:num]
396  [aps:\s!cite]
397  [\c!left={[},
398   \c!right={]},
399  %\c!left=,   % TODO: PRB uses superscript references...
400  %\c!right=,  % and after punctuation, PRA, C, D, E, and L are before!
401  %\c!command={\high},
402   \c!separator:2={\btxcommabreak},
403   \c!separator:3=\btxparameter{\c!separator:2},
404   \c!separator:4=\btxparameter{\c!separator:2}]
405
406\definebtx
407  [aps:\s!cite:default]
408  [aps:\s!cite:num]
409
410\definebtx
411  [aps:\s!cite:textnum]
412  [aps:\s!cite:num]
413  [\c!left={Ref.\nbsp},
414   \c!command=,
415   \c!separator:2={\btxcomma},
416   \c!separator:3={\btxspace\btxlabeltext{and}\space},
417   \c!separator:4={\btxspace\btxlabeltext{and}\space}]
418
419\definebtx
420  [aps:\s!cite:entry]
421  [aps:\s!cite]
422  [\c!left=,
423   \c!right=,
424   \c!inbetween={\btxspace},
425   \c!separator:2={\btxsemicolon},
426   \c!separator:3=\btxparameter{\c!separator:2},
427   \c!separator:4=\btxparameter{\c!separator:2}]
428
429%D Sometimes we have verbose injections in an entry and these can be language
430%D dependent, so we use labels.
431%D
432%D Because we want to mix rendering (in the manual) we need a namespace in label
433%D texts:
434
435\setupbtxlabeltext
436  [en]
437  [aps:number={no.},
438   aps:edition={ed.},
439   aps:Editor={Ed.},
440   aps:Editors={Eds.},
441   aps:Volume={Vol.},
442   aps:Volumes={Vols.},
443   aps:supplement={Suppl.},           % Supplement (not used?)
444   aps:inpress={in press},
445   aps:tobe={to be published},
446   aps:unpublished={unpublished}]
447
448% Check this (google translate!!):
449
450\setupbtxlabeltext
451  [nl]
452  [aps:number={nr.},
453   aps:edition={ed.}, % editie
454   aps:Editor=Editor, % Ed./Eds.
455   aps:Editors=Editors,
456   aps:Volume={Vol.},
457   aps:Volumes={Vols.},
458   aps:supplement=Supplement,
459   aps:inpress={in press}, % CHECK THESE!
460   aps:tobe={worden gepubliceerd},
461   aps:unpublished={onuitgegeven}]
462
463\setupbtxlabeltext
464  [fr]
465  [aps:number={n\high{o}},
466   aps:edition={édition},
467   aps:Editor=Éditeur,
468   aps:Editors=Éditeurs,
469   aps:Volume=Volume,
470   aps:Volumes=Volumes,
471   aps:supplement=Supplément,
472   aps:inpress={sous impression},
473   aps:tobe={à paraître},
474   aps:unpublished={inédit}]          % pour un livre
475
476\setupbtxlabeltext
477  [de]
478  [aps:number={nr.},
479   aps:edition=Auf\/lage,
480   aps:Editor=Herausgeber, % Hrsg./Hg.
481   aps:Editors=Herausgeber,
482   aps:Volume=Band,        % Bd.
483   aps:Volumes={Bände},
484   aps:supplement={Beilage},          % Supplement
485   aps:inpress={in der Presse}, % CHECK THESE!
486   aps:tobe={veröffentlicht werden},
487   aps:unpublished={unveröffentlicht}]
488
489% thanks: Andrea Valle
490
491\setupbtxlabeltext
492  [it]
493  [aps:number={},
494   aps:edition={ed.}, % edizione
495   aps:Editor={A cura di},
496   aps:Editors={A cura di},
497   aps:Volume={Vol.},  % Volume
498   aps:Volumes={Vol.}, % Volumi
499   aps:supplement={Supplemento},
500   aps:inpress={in press}, % CHECK THESE!
501   aps:tobe={da pubblicare},
502   aps:unpublished={inedito}]
503
504\setupbtxlabeltext
505  [es]
506  [aps:number={},
507   aps:edition={ed.}, % edición
508   aps:Editor=Editor, % Ed./Eds.
509   aps:Editors=Editores,
510   aps:Volume={Vol.},   % Volumen
511   aps:Volumes={Vols.}, % Volúmenes
512   aps:supplement=Suplemento,
513   aps:inpress={en prensa}, % CHECK THESE!
514   aps:tobe={que se publicará},
515   aps:unpublished={inédito}]
516
517\setupbtxlabeltext
518  [sv]
519  [aps:number={nr.},
520   aps:edition={Utgåva},
521   aps:Editor=Redaktör,
522   aps:Editors=Redaktörer,
523   aps:Volume=Band,
524   aps:Volumes=Band,
525   aps:supplement=Bilaga,
526   aps:inpress={under tryckning},
527   aps:tobe={att publiceras},
528   aps:unpublished={opublicerat}]
529
530
531% cite setups
532
533\startsetups btx:aps:nd
534    \doifelse {\currentbtxcategory} {article} {
535        \btxlabeltext{aps:tobe}
536    } {
537        \doifelse {\currentbtxcategory} {book} {
538            \btxlabeltext{aps:inpress}
539        } {
540            \btxlabeltext{aps:unpublished}
541        }
542    }
543\stopsetups
544
545\startsetups btx:aps:cite:author:year
546    \texdefinition{\s!btx:\s!cite:concat}
547    \ifx\currentbtxfirst\empty
548        \fastsetup{btx:aps:nd}
549    \else
550        \texdefinition {\s!btx:\s!cite:inject} {
551            \btxcitereference
552            \currentbtxfirst
553        }
554        \ifx\currentbtxsecond\empty \else
555            \btxparameter\c!inbetween
556            \texdefinition {\s!btx:\s!cite:inject} {
557                \currentbtxsecond
558            }
559        \fi
560        \btxflushsuffix
561    \fi
562\stopsetups
563
564\startsetups btx:aps:cite:author:years
565    \fastsetup{btx:aps:cite:author:year}
566\stopsetups
567
568% used in publ-imp-page.mkvi
569
570\startsetups [btx:aps:list:page-or-pages]
571    \ifx\currentbtxlastpage\empty
572        \btxlabeltext{p}
573    \else
574        \btxlabeltext{pp}
575    \fi
576    \btxnbsp
577\stopsetups
578
579%D Instead of texdefinitions without arguments, we could have used setups but in my
580%D editor (hh, scite) the commands stand out better. It also saves an additional
581%D component in the name (e.g. common:) because commands and setups have a different
582%D namespace, so similar calls don't clash. Performance of definitions is somewhat
583%D better.
584
585%D We use "texdefinitions" (with eventual arguments) for helpers that are used
586%D in the rendering "setups" defined for each category below.
587
588%D Note that \btxdoif... and \btxflush rely on the definitions in
589%D publ-imp-aps.lua: fields that are not listed as required nor optional are
590%D IGNORED. We also make heavy use of the notion of sets - comma-separated lists
591%D of alternative fields to be used in hierarchal order. For example:
592%D author = { "author", "editor", "publisher", "title" }, will return the
593%D author field if it exists; if not, the editor field will be returned, if it
594%D exists; if not, the publisher field will be returned, if it exists; if not,
595%D the title field will be returned, it it exists; if not, nothing will be
596%D returned. In lua syntax, it can be understood as
597%D author or editor or publisher or title or ""
598
599\starttexdefinition mutable protected btx:aps:composed-title #title
600    \btxstartstyleandcolor [aps:\s!list:title:\currentbtxcategory]
601        \begingroup
602            \language[\currentbtxlanguage]
603            \btxusecommand [aps:\s!list:title:\currentbtxcategory] {
604                \btxflush{#title}
605                \btxdoif {sub#title} {
606                    \btxcolon
607                    \btxflush{sub#title}
608                }
609            }
610        \endgroup
611    \btxstopstyleandcolor
612\stoptexdefinition
613
614\starttexdefinition mutable protected btx:aps:title
615    \btxdoif {title} {
616        % we make the title active, opening file
617        \btxdoifelse {file} {
618            \texdefinition{btx:format:goto}
619                {url(file:\btxflush{file})}
620                {
621                    \texdefinition{btx:aps:composed-title}{title}
622                }
623        } {
624            \texdefinition{btx:aps:composed-title}{title}
625        }
626        \btxcomma
627    }
628\stoptexdefinition
629
630\starttexdefinition mutable protected btx:aps:optional-title
631    \doif{\btxparameter{\c!title}}\v!yes {
632        \texdefinition {btx:aps:title}
633    }
634\stoptexdefinition
635
636\starttexdefinition mutable protected btx:aps:year
637    \btxdoifelse {year} {
638        \btxflush{year}
639    } {
640        \fastsetup{btx:aps:nd}
641    }
642\stoptexdefinition
643
644% #author may be author(set) or editor
645
646\starttexdefinition mutable protected btx:aps:author-or-editor #author
647    \btxdoif {#author} {
648        \btxflush{#author}
649        \doifelse {\btxfoundname{#author}} {editor} {
650            \btxleftparenthesis
651            \btxsingularorplural {editor} {
652                \btxlabeltext{aps:Editor}
653            } {
654                \btxlabeltext{aps:Editors}
655            }
656            \btxrightparenthesis
657        } {
658            \btxdoif {collaboration} {
659                \btxleftparenthesis
660                \btxflush{collaboration}
661                \btxrightparenthesis
662            }
663        }
664    }
665\stoptexdefinition
666
667\starttexdefinition mutable protected btx:aps:author
668    \btxdoif {author} {
669        \btxflush{author}
670        \btxcomma
671    }
672\stoptexdefinition
673
674\starttexdefinition mutable protected btx:aps:organization-if-not-author
675    \btxdoif {organization} {
676        \doifnot {\btxfoundname{author}} {organization} {
677            \btxspace
678            \btxflush{organization}
679            \btxcomma
680        }
681    }
682\stoptexdefinition
683
684\starttexdefinition mutable protected btx:aps:editor-in
685    \btxdoif {booktitle} {
686        \btxlabeltext{In}
687        \doifnot {\btxfoundname{author}} {editor} {
688            \btxspace
689            \texdefinition{btx:aps:author-or-editor} {editor}
690        }
691        \btxspace
692        \texdefinition{btx:aps:composed-title}{booktitle}
693        \btxcomma
694    }
695\stoptexdefinition
696
697\starttexdefinition mutable protected btx:aps:editionset
698    \doif {\currentbtxcategory} {techreport} {
699        \btxdoifelse {type} {
700            \btxusecommand [\currentbtx:type] {
701                \btxflush{type}
702            }
703        } {
704            \btxlabeltext{technicalreport}
705        }
706        \btxcomma
707    }
708    \btxdoif {volume} {
709        \btxoneorrange {volume} {
710            \btxlabeltext{aps:Volume}
711        } {
712            \btxlabeltext{aps:Volumes}
713        }
714        \btxspace
715        \btxflush{volume}
716        \btxcomma
717    }
718    \btxdoif {number} {
719        \btxlabeltext{aps:number}
720        \btxspace
721        \btxflush{number}
722        \btxcomma
723    }
724    \btxdoif {edition} {
725        \btxflush{edition}
726        \btxspace
727        \btxlabeltext{aps:edition}
728        \btxcomma
729    }
730    \btxdoif {pages} {
731        \btxoneorrange {pages} {
732            \btxlabeltext{p}.
733        } {
734            \btxlabeltext{pp}.
735        }
736        \btxnbsp
737        \btxflush{pages}
738        \btxcomma
739    }
740\stoptexdefinition
741
742\starttexdefinition mutable protected btx:aps:journal-volume-year
743    \btxdoif {journal} {
744        \btxspace
745        \btxstartstyleandcolor [aps:\s!list:journal]
746            % expandedjournal abbreviatedjournal
747            \btxflush{expandedjournal -> journal}
748        \btxstopstyleandcolor
749        \btxdoifelse {volume} {
750            \btxspace
751            \btxstartstyleandcolor [aps:\s!list:volume]
752                \btxflush{volume}
753            \btxstopstyleandcolor
754            \btxdoif {number} {
755                \removeunwantedspaces(
756                \btxflush{number}
757                \btxrightparenthesiscomma
758            }
759        } {
760            \btxdoif {number} {
761                \btxspace
762                \btxflush{number}
763                \btxcomma
764            }
765        }
766        \btxdoif {pages} {
767            \btxspace
768            \btxflush{pages}
769        }
770    }
771    \btxleftparenthesis
772    \texdefinition{btx:aps:year}
773    \btxrightparenthesis
774\stoptexdefinition
775
776\starttexdefinition mutable protected btx:aps:publisher-wherefrom-year
777    \removeunwantedspaces
778    \removepunctuation
779    \btxleftparenthesis
780    \btxflush{publisher}
781    \btxdoifelse {address} {
782        \btxdoif {publisher} {
783            \btxcomma
784        }
785        \btxflush{address}
786        \btxdoif {country} {
787            \btxcomma
788            \btxflush{country}
789        }
790        \btxcomma
791    } {
792        \btxdoif {publisher} {
793            \btxcomma
794        }
795    }
796    \texdefinition{btx:aps:year}
797    \btxrightparenthesis
798\stoptexdefinition
799
800\starttexdefinition mutable protected btx:aps:note
801    \btxperiod
802    \btxdoif {note} {
803        \btxleftparenthesis
804        \btxflush{note}
805        \btxrightparenthesis
806    }
807\stoptexdefinition
808
809\starttexdefinition mutable protected btx:aps:doi-url #text
810    % no: \texdefinition {btx:format:goto} because different test
811    \ifconditional\btxinteractive
812        \btxdoifelse {doi} {
813            \goto {#text} [url(http://dx.doi.org/\btxflush{doi})]
814        } {
815            \btxdoifelse {url} {
816                \goto {#text} [url(\btxflush{url})]
817            } {
818                #text
819            }
820        }
821    \else
822        #text
823    \fi
824\stoptexdefinition
825
826% Then setups, by category
827
828% An article from a journal
829% Required fields: author or editor or title, journal, (year).
830% Optional fields: volume, number, pages, type, doi, url, note.
831% Note that bibtex (and tools) do not include editor (e.g. special issue or section)
832
833\startsetups btx:aps:list:article
834    \texdefinition{btx:aps:author}
835    \texdefinition{btx:aps:optional-title}
836    \texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:journal-volume-year}}
837    \texdefinition{btx:aps:note}
838\stopsetups
839
840% An article from a magazine.
841% Required fields: author or title, journal, (year).
842% Optional fields: number, pages, type, month, day, doi, url, note.
843
844\startsetups btx:aps:list:magazine
845    \fastsetup{btx:aps:list:article}
846\stopsetups
847
848% An article from a newspaper.
849% Required fields: author or title, journal, (year).
850% Optional fields: number, pages, type, month, day, doi, url, note.
851
852\startsetups btx:aps:list:newspaper
853    \fastsetup{btx:aps:list:article}
854\stopsetups
855
856% A complete issue of a periodical, such as a special issue of a journal.
857% Required fields: title, year
858% Optional fields: editor, publisher, subtitle, series, volume, number, month, organization, doi, url, issn, note
859
860% needs to be tuned...
861\startsetups btx:aps:list:periodical
862    \fastsetup{btx:aps:list:article}
863\stopsetups
864
865% National and international standards issued by a standards body
866% Required fields: author, institution, or organization, year, title
867% Optional fields: subtitle, doi, url, note
868
869\startsetups btx:aps:list:standard
870    \texdefinition{btx:aps:author}
871    \texdefinition{btx:aps:title}
872    \texdefinition{btx:aps:note}
873\stopsetups
874% year?
875
876% A book with an explicit publisher.
877% Required fields: author or editor or publisher, title, (year).
878% Optional fields: volume or number, series, address, edition, month, day, note.
879% APS? ignores: month, day
880
881% todo: series?
882
883\startsetups btx:aps:list:book
884    \texdefinition{btx:aps:author}
885    \texdefinition{btx:aps:title}
886    \texdefinition{btx:aps:editionset}
887    \texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:publisher-wherefrom-year}}
888    \texdefinition{btx:aps:note}
889\stopsetups
890
891% There is some debate about how inbook should differ from incollection
892
893% A part of a book, which may be a chapter (or section or whatever) and/or a range of pages.
894% (note that inbook is handled differently by bibtex and biblatex)
895% Required fields: author or editor, title, chapter and/or pages, publisher, year.
896% Optional fields: volume or number, series, type, address, edition, month, note.
897% We add optional: booktitle.
898% APS? ignores: chapter, month
899
900\startsetups btx:aps:list:inbook
901    \texdefinition{btx:aps:author}
902    \texdefinition{btx:aps:title}
903    \texdefinition{btx:aps:editor-in}
904    \texdefinition{btx:aps:editionset}
905    \texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:publisher-wherefrom-year}}
906    \texdefinition{btx:aps:note}
907\stopsetups
908% chapter?
909
910% A part of a book having its own title.
911% Required fields: author, title, booktitle, publisher, year.
912% Optional fields: editor, volume or number, series, type, chapter, pages, address, edition, month, note.
913% APS? ignores: chapter, month
914
915\startsetups btx:aps:list:incollection
916    \fastsetup{btx:aps:list:inbook}
917\stopsetups
918
919% The proceedings of a conference.
920% Required fields: title, year.
921% Optional fields: editor, volume or number, series, address, month, organization, publisher, note.
922% todo: series?
923
924\startsetups btx:aps:list:proceedings
925    \fastsetup{btx:aps:list:book}
926\stopsetups
927
928% An article in a conference proceedings.
929% Required fields: author, title, booktitle, year.
930% Optional fields: editor, volume or number, series, pages, address, month, organization, publisher, note.
931
932\startsetups btx:aps:list:inproceedings
933    \texdefinition{btx:aps:author}
934    \texdefinition{btx:aps:title}
935    \texdefinition{btx:aps:editor-in}
936    \texdefinition{btx:aps:editionset}
937   %\texdefination{btx:aps:organization-if-not-author}% first check publ-imp-aps.lua
938    \btxdoif {organization} {
939        \btxspace
940        \btxflush{organization}
941        \btxcomma
942    }
943    \texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:publisher-wherefrom-year}}
944    \texdefinition{btx:aps:note}
945\stopsetups
946
947\startsetups btx:aps:list:conference
948    \fastsetup{btx:aps:list:inproceedings}
949\stopsetups
950
951% A thesis.
952% Required fields: author, title, school, year.
953% Optional fields: type, address, month, note.
954
955\startsetups btx:aps:list:thesis
956    \texdefinition{btx:aps:author}
957    \texdefinition{btx:aps:title}
958    \btxleftparenthesis
959    \btxdoifelse {type} {
960        \btxusecommand [aps:list:type] {
961            \btxflush{type}
962        }
963    } {
964        \btxlabeltext{\currentbtxcategory}
965    }
966    \btxrightparenthesis
967    \btxdoif {school} {
968        \btxperiod
969        \btxflush{school}
970    }
971    \btxdoif {address} {
972        \btxdoifelse {school} {
973            \btxcomma
974        } {
975            \btxperiod
976        }
977        \btxflush{address}
978        \btxdoif {country} {
979            \btxcomma
980            \btxflush{country}
981        }
982    }
983    \btxleftparenthesis
984    \texdefinition{btx:aps:year}
985    \btxrightparenthesis
986    \texdefinition{btx:aps:note}
987\stopsetups
988
989\startsetups btx:aps:list:phdthesis
990    \fastsetup{btx:aps:list:thesis}
991\stopsetups
992
993\startsetups btx:aps:list:mastersthesis
994    \fastsetup{btx:aps:list:thesis}
995\stopsetups
996
997% A work that is printed and bound, but without a named publisher or sponsoring institution.
998% Required field: title.
999% Optional fields: author, howpublished, address, month, year, note.
1000
1001\startsetups btx:aps:list:booklet
1002    \fastsetup{btx:aps:list:book}
1003\stopsetups
1004
1005% Technical documentation.
1006% Required field: title.
1007% Optional fields: author, organization, address, edition, month, year, note.
1008
1009\startsetups btx:aps:list:manual
1010    \fastsetup{btx:aps:list:book}
1011\stopsetups
1012
1013% A report published by a school or other institution, usually numbered within a series.
1014% Required fields: author, title, institution, year.
1015% Optional fields: type, number, address, month, note.
1016
1017\startsetups btx:aps:list:techreport
1018    \fastsetup{btx:aps:list:book}
1019\stopsetups
1020
1021% A document having an author and title, but not formally published.
1022% Required fields: author, title, note.
1023% Optional fields: month, year.
1024
1025\startsetups btx:aps:list:unpublished
1026    \fastsetup{btx:aps:list:book}
1027\stopsetups
1028
1029% A patent. Note that this category was not defined with BIBTEX. Below from JabRef:
1030% Required fields: nationality, number, year, yearfiled
1031% Optional fields: author, title, assignee, address, type, number, day, dayfiled, month, monthfiled, note, url
1032% Also optional: publisher
1033
1034% todo: yearfiled, monthfiled, dayfiled
1035
1036\startsetups btx:aps:list:patent
1037    \texdefinition{btx:aps:author}
1038    \texdefinition{btx:aps:title}
1039    \begingroup
1040        \it
1041        \btxdoif {nationality} {
1042            \btxspace
1043            \btxflush{nationality}
1044        }
1045        \btxspace
1046        \btxlabeltext{patent}
1047        \btxdoif {number} {
1048            \btxspace
1049            \btxlabeltext{aps:number}
1050            \btxspace
1051            \btxflush{number}
1052        }
1053        \btxperiod
1054        \italiccorrection
1055    \endgroup
1056    \texdefinition{btx:aps:doi-url} {\texdefinition{btx:aps:publisher-wherefrom-year}}
1057    \texdefinition{btx:aps:note}
1058\stopsetups
1059
1060% Electronic. Note that this category was not defined with BIBTEX. Below from JabRef:
1061% Required fields: title
1062% Optional fields: address, author, howpublished, month, note, organization, url, year, doi
1063% Also optional: type
1064
1065% Like Misc below but includes organization.
1066
1067\startsetups btx:aps:list:electronic
1068    \texdefinition{btx:aps:author}
1069    \texdefinition{btx:aps:title}
1070    \texdefinition{btx:aps:organization-if-not-author}
1071    \btxdoif {howpublished} {
1072        \texdefinition{btx:aps:doi-url} {\btxspace\btxflush{howpublished}}
1073    }
1074    \btxleftparenthesis
1075    \texdefinition{btx:aps:year}
1076    \btxrightparenthesis
1077    \texdefinition{btx:aps:note}
1078\stopsetups
1079
1080% Other. Note that this category was not defined with BIBTEX. Below from JabRef:
1081% Required fields: author or title, year
1082% Optional fields: note, doi, url
1083
1084\startsetups btx:aps:list:other
1085    \fastsetup{btx:aps:list:book}
1086\stopsetups
1087
1088% Use this type when nothing else fits.
1089% Required fields: none.
1090% Optional fields: author, title, howpublished, month, year, note.
1091
1092\startsetups btx:aps:list:misc
1093    \fastsetup{btx:aps:list:electronic}
1094    % Note that organization is an "ignored" field.
1095\stopsetups
1096
1097% If all else fails to match:
1098
1099\startsetups btx:aps:list:literal
1100    %\btxleftparenthesis
1101    \removeunwantedspaces(
1102    \btxflush{tag}
1103    \btxrightparenthesis
1104    \btxdoif {text} {
1105        \btxflush{text}
1106    }
1107\stopsetups
1108
1109\stopbtxrenderingdefinitions
1110