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