1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33\writestatus{loading}{ConTeXt Bibliography Support BibTeX}
34
35\definefilesynonym[bib][obsolete]
36
37\registerctxluafile{bibltra}{}
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185\unprotect
186
187\def\biblistname{pubs}
188
189\definelist
190 [pubs]
191
192\setuplist
193 [pubs]
194 [\c!state=\v!start,
195 \c!criterium=\@@pbcriterium,
196 \c!headnumber=\v!always,
197 \c!width=]
198
199\installstructurelistprocessor{pubs:userdata}
200 {\ctxlua{bibtex.hacks.add(structures.lists.uservalue("\currentlist",\currentlistindex,"bibref"),\currentlistindex)}}
201
202\ifdefined\bibtexblock \else \newcount\bibtexblock \fi \bibtexblock\plusone
203\ifdefined\bibtexcounter \else \newcount\bibtexcounter \fi
204
205
206
207
208
209
210\unexpanded\def\bibdoifelse#1
211 {\expandafter\def\expandafter\!!stringa\expandafter{#1}
212 \ifx\!!stringa\empty
213 \expandafter\secondoftwoarguments
214 \else
215 \expandafter\firstoftwoarguments
216 \fi}
217
218\unexpanded\def\bibdoifnot#1
219 {\expandafter\def\expandafter\!!stringa\expandafter{#1}
220 \ifx\!!stringa\empty
221 \expandafter\firstofoneargument
222 \else
223 \expandafter\gobbleoneargument
224 \fi}
225
226\unexpanded\def\bibdoif#1
227 {\expandafter\def\expandafter\!!stringa\expandafter{#1}
228 \ifx\!!stringa\empty
229 \expandafter\gobbleoneargument
230 \else
231 \expandafter\firstofoneargument
232 \fi}
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252\newtoks\everysetupbibtex
253
254\unexpanded\def\setupbibtex
255 {\dosingleempty\dosetupbibtex}
256
257\unexpanded\def\dosetupbibtex[#1]
258 {\let\@@pbdatabase\empty
259 \getparameters[\??pb][#1]
260 \the\everysetupbibtex}
261
262\unexpanded\def\installbibtexsorter#1#2
263 {\setvalue{\??pb:\c!sort:#1}{#2}}
264
265\installbibtexsorter\v!no {no}
266\installbibtexsorter\v!author {au}
267\installbibtexsorter\v!title {ti}
268\installbibtexsorter\v!short {ab}
269\installbibtexsorter\empty {no}
270\installbibtexsorter\s!default{no}
271
272\def\thebibtexsorter{\executeifdefined{\??pb:\c!sort:\@@pbsort}\@@pbsort}
273
274\appendtoks
275 \ifx\@@pbdatabase\empty\else
276 \doifmode{*\v!first}{\ctxlua{bibtex.hacks.process { style="\thebibtexsorter", database="\@@pbdatabase" }}}
277 \fi
278\to \everysetupbibtex
279
280\setupbibtex
281 [\c!sorttype=\v!cite,
282 \c!sort=no]
283
284
285
286
287
288\newtoks\everysetuppublications
289
290\unexpanded\def\setuppublications
291 {\dosingleargument\dosetuppublications}
292
293\unexpanded\def\dosetuppublications[#1]
294 {\getparameters[\??pb][\c!alternative=,#1]
295 \doifsomething\@@pbalternative
296 {\readsysfile{bibl\@@pbalternative.tex}
297 {\showmessage\m!publications{6}{bibl\@@pbalternative}}
298 {\showmessage\m!publications{1}{bibl\@@pbalternative}}
299 \let\@@pbalternative\empty}
300 \let\setuppublicationlayout\normalsetuppublicationlayout
301 \getparameters[\??pb][#1]
302 \the\everysetuppublications
303 \ignorespaces}
304
305
306
307
308\setnewconstant\bibtexoncemode\plusone
309
310\appendtoks
311 \doifelse\@@pbmethod\v!local
312 {\bibtexoncemode\plusone}
313 {\bibtexoncemode\plustwo}
314\to \everysetuppublications
315
316
317
318\newif\ifbibcitecompress\bibcitecompresstrue
319
320\def\@@pbinumbercommand{\executeifdefined{\??pb:\c!numbercommand:\@@pbnumbering}\firstofoneargument}
321
322\setvalue{\??pb:\c!numbercommand:\v!yes }#1{#1}
323\setvalue{\??pb:\c!numbercommand:\v!no }#1{}
324\setvalue{\??pb:\c!numbercommand:\v!short}#1{\bibgetvars\currentpublicationkey}
325\setvalue{\??pb:\c!numbercommand:\v!bib }#1{\bibgetvarn\currentpublicationkey}
326
327
328
329
330
331
332\appendtoks
333 \processaction
334 [\@@pbrefcommand]
335 [\s!default=>\edef\@@citedefault{\@@pbrefcommand},
336 \s!unknown=>\edef\@@citedefault{\@@pbrefcommand}]
337\to \everysetuppublications
338
339\unexpanded\def\bibleftnumber#1{#1\hfill}
340
341
342
343
344
345
346
347
348\unexpanded\def\usepublications[#1]
349 {\processcommalist[#1]\dousepublications}
350
351\unexpanded\def\dousepublications#1
352 {\doonlyonce{#1.\f!bibextension}{\dodousepublications{#1}}}
353
354\unexpanded\def\dodousepublications#1
355 {\let\@@savedpar\par
356 \let\par\ignorespaces
357 \ifhmode\kern\zeropoint\fi
358 \pushcatcodetable
359 \setcatcodetable\ctxcatcodes
360 \readfile{#1.\f!bibextension}
361 {\showmessage\m!publications{4}{#1.\f!bibextension}}
362 {\showmessage\m!publications{2}{#1.\f!bibextension}}
363 \popcatcodetable
364 \ifhmode\removeunwantedspaces\fi
365 \let\par\@@savedpar}
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380\def\publicationlistparameter#1{\csname\??pv:l:#1\endcsname}
381
382\unexpanded\def\setuppublicationlist
383 {\dosingleempty\dosetuppublicationlist}
384
385\unexpanded\def\dosetuppublicationlist[#1]
386 {\getparameters[\??pv:l:][#1]
387 \setuplist[pubs][\c!samplesize={AA99},\c!alternative=a,\c!interaction=,\c!pagenumber=\v!no,#1,\c!command=]}
388
389\unexpanded\def\setuppublicationlayout[#1]#2
390 {\setvalue{\??pv:l:#1}{#2}}
391
392\let\normalsetuppublicationlayout\setuppublicationlayout
393
394\setuppublicationlist
395 [\c!title=,
396 \c!command=\dospecialbibinsert,
397 \c!maybeyear=\v!on]
398
399
400
401
402
403
404\def\bibalternative#1
405 {\csname\??pv\@@currentalternative#1\endcsname}
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425\newtoks\initializebibdefinitions
426
427\unexpanded\def\simplebibdef#1
428 {\expandafter\def\csname bib@#1\endcsname##1
429 {\setvalue{\??pb @#1}{##1}\ignorespaces}
430 \expandafter \appendtoks
431 \expandafter\let\csname insert#1\expandafter\endcsname\csname bibinsert#1\endcsname
432 \to \initializebibdefinitions
433 \expandafter\unexpanded\expandafter\def\csname bibinsert#1\endcsname##1##2##3
434 {\expandafter\bibdoifelse\expandafter{\csname\??pb @#1\endcsname}{##1\csname\??pb @#1\endcsname##2}{##3}}}
435
436\def\bibcommandlist
437 {abstract, annotate, arttitle, assignee, bibnumber, bibtype, biburl, chapter, city,
438 comment, country, day, dayfiled, doi, edition, eprint, howpublished, isbn, issn,
439 issue, journal, keyword, keywords, lastchecked, month, monthfiled, names, nationality,
440 note, notes, organization, pages, pubname, pubyear, revision, series, size, thekey,
441 title, volume, yearfiled}
442
443\processcommacommand[\bibcommandlist]\simplebibdef
444
445\unexpanded\def\bibinsertdoi#1#2#3
446 {\bibdoifelse{\@@pb@doi}{#1\expanded{\bibgotoDOI{\@@pb@thekey}{\@@pb@doi}}#2}{#3}}
447
448\unexpanded\def\bibinsertbiburl#1#2#3
449 {\bibdoifelse{\@@pb@biburl}{#1\expanded{\bibgotoURL{\@@pb@thekey}{\@@pb@biburl}}#2}{#3}}
450
451\unexpanded\def\bibinsertmonth#1#2#3
452 {\bibdoifelse\@@pb@month
453 {#1\doifelsenumber\@@pb@month
454 {\doifelseconversiondefined\@@pbmonthconversion
455 {\convertnumber\@@pbmonthconversion\@@pb@month}{\@@pb@month}}
456 {\@@pb@month}#2}
457 {#3}}
458
459\appendtoks
460 \let\inserturl \bibinsertbiburl
461 \let\inserttype\bibinsertbibtype
462\to\initializebibdefinitions
463
464\unexpanded\def\newbibfield[#1]
465 {\simplebibdef{#1}
466 \edef\bibcommandlist{\bibcommandlist,#1}}
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495\unexpanded\def\docomplexbibdef#1
496 {\dodoubleempty\dodocomplexbibdef[#1]}
497
498\unexpanded\def\dodocomplexbibdef[#1][#2]#3
499 {\doquadrupleempty\dododocomplexbibdef[#1][#2][#3]}
500
501\unexpanded\def\dododocomplexbibdef[#1][#2][#3][#4]#5#6
502 {\expandafter\increment\csname#1@num\endcsname
503 \setevalue{\??pb @#1\csname#1@num\endcsname}{{#3}{#5}{#6}{#4}{#2}}\ignorespaces}
504
505\unexpanded\def\complexbibdef#1
506 {\expandafter\newcounter\csname #1@num\endcsname
507 \expandafter\def\csname bib@#1\endcsname{\docomplexbibdef{#1}}
508 \expandafter \appendtoks
509 \expandafter\let\csname insert#1s\expandafter\endcsname\csname bibinsert#1s\endcsname
510 \to \initializebibdefinitions
511 \expandafter\def\csname bibinsert#1s\endcsname##1##2##3{\specialbibinsert{#1}{\csname #1@num\endcsname}{##1}{\unskip ##2}{##3}}}
512
513\processcommalist[author,artauthor,editor]\complexbibdef
514
515
516
517
518\newcount\etallimitcounter
519\newcount\etaldisplaycounter
520\newcount\todocounter
521
522\unexpanded\def\specialbibinsert#1#2#3#4#5
523 {\bgroup
524 \ifnum#2>\zerocount
525 \etallimitcounter =0\bibalternative{#1etallimit}\relax
526 \etaldisplaycounter=0\bibalternative{#1etaldisplay}\relax
527 \ifnum #2>\etallimitcounter
528 \todocounter\etaldisplaycounter
529
530 \ifnum\todocounter>\etallimitcounter
531 \todocounter\etallimitcounter
532 \fi
533 \else
534 \todocounter#2\relax
535 \fi
536 \ifnum\todocounter>\zerocount
537
538 \let\templist\empty
539 \dorecurse{#2}
540 {\scratchtoks\doubleexpandafter{\csname\??pb @#1\recurselevel\endcsname}
541 \edef\templist{\ifx\templist\empty\else\templist,\fi\the\scratchtoks}}
542 #3\publicationlistparameter\c!command{#1}{\todocounter}{\templist}#4\relax
543 \else
544 #5
545 \fi
546 \else
547 #5
548 \fi
549 \egroup}
550
551
552
553
554
555
556
557
558
559\unexpanded\def\doprocessauthoritem#1#2#3
560 {\advance\scratchcounter\plusone
561 \ifnum\numexpr\scratchcounter\plusone\relax<#2\relax
562 \publicationlistparameter{#1}#3
563 \ifnum\scratchcounter=#2\relax
564 \ifnum\etallimitcounter<\commalistsize\relax
565 \bibalternative{#1etaltext}
566 \fi
567 \else\ifnum\numexpr\scratchcounter\plusone\relax=#2\relax
568 \ifnum\commalistsize>\plustwo
569 \bibalternative\c!finalnamesep
570 \else
571 \bibalternative\c!lastnamesep
572 \fi
573 \else
574 \bibalternative\c!namesep
575 \fi\fi
576 \fi}
577
578\unexpanded\def\dospecialbibinsert#1#2#3
579 {\getcommacommandsize[#3]
580 \scratchcounter\zerocount
581 \processcommacommand[#3]{\doprocessauthoritem{#1}{#2}}}
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600\unexpanded\def\normalauthor#1#2#3#4#5
601 {\bibdoif{#1}{#1\bibalternative\c!firstnamesep}
602 \bibdoif{#2}{#2\bibalternative\c!vonsep}
603 #3
604 \bibdoif{#5}{\bibalternative\c!surnamesep#5\unskip}}
605
606\unexpanded\def\normalshortauthor#1#2#3#4#5
607 {\bibdoif{#4}{#4\bibalternative\c!firstnamesep}
608 \bibdoif{#2}{#2\bibalternative\c!vonsep}
609 #3
610 \bibdoif{#5}{\bibalternative\c!surnamesep#5\unskip}}
611
612\unexpanded\def\invertedauthor#1#2#3#4#5
613 {\bibdoif{#2}{#2\bibalternative\c!vonsep}
614 #3
615 \bibdoif{#5}{\bibalternative\c!juniorsep#5}
616 \bibdoif{#1}{\bibalternative\c!surnamesep#1\unskip}}
617
618\unexpanded\def\invertedshortauthor#1#2#3#4#5
619 {\bibdoif{#2}{#2\bibalternative\c!vonsep}
620 #3
621 \bibdoif{#5}{\bibalternative\c!juniorsep#5}
622 \bibdoif{#4}{\bibalternative\c!surnamesep#4\unskip}}
623
624
625
626
627
628
629\unexpanded\def\clearbibitem#1{\setvalue{\??pb @#1}{}}
630
631\unexpanded\def\clearbibitemtwo#1
632 {
633 \letvalue{#1@num}\!!zerocount}
634
635\unexpanded\def\bibitemdefs#1
636 {\expandafter\let\csname#1\expandafter\endcsname\csname bib@#1\endcsname}
637
638\unexpanded\def\presetbibvariables
639 {\processcommacommand[\bibcommandlist,crossref]\clearbibitem
640 \processcommalist [artauthor,author,editor]\clearbibitemtwo
641 \processcommacommand[\bibcommandlist]\bibitemdefs
642 \processcommalist [artauthor,author,editor,crossref]\bibitemdefs}
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668\unexpanded\def\startpublication
669 {\dosingleempty\dostartpublication}
670
671\let\stoppublication\relax
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687\unexpanded\def\dostartpublication[#1]
688 {\begingroup
689 \doifelseassignment{#1}
690 {\getparameters[\??pb][k=\s!unknown,t=article,n=,s=,a=,y=,o=,u=,#1]}
691 {\getparameters[\??pb][k=#1,t=article,n=,s=,a=,y=,o=,u=]}
692 \ctxlua{bibtex.hacks.register(\!!bs\@@pbk\!!es,\!!bs\@@pbs\!!es)}
693 \catcode\commentasciicode\othercatcode
694 \dodostartpublication}
695
696\unexpanded\def\dodostartpublication#1\stoppublication
697 {\setxvalue{pbd:\@@pbk}##1{\noexpand\ifcase##1\noexpand\or
698 \@@pbk\noexpand\or
699 \@@pba\noexpand\or
700 \@@pby\noexpand\or
701 \@@pbs\noexpand\or
702 \@@pbn\noexpand\or
703 \@@pbt\noexpand\or
704 \@@pbo\noexpand\or
705 \@@pbu\noexpand\or
706 \normalunexpanded{#1}\noexpand\fi}
707 \endgroup
708 \ignorespaces}
709
710\def\bibgetvark#1{\csname pbd:#1\endcsname\plusone }
711\def\bibgetvara#1{\csname pbd:#1\endcsname\plustwo }
712\def\bibgetvary#1{\csname pbd:#1\endcsname\plusthree}
713\def\bibgetvars#1{\csname pbd:#1\endcsname\plusfour }
714\def\bibgetvarn#1{\csname pbd:#1\endcsname\plusfive }
715\def\bibgetvart#1{\csname pbd:#1\endcsname\plussix }
716\def\bibgetvaro#1{\csname pbd:#1\endcsname\plusseven}
717\def\bibgetvaru#1{\csname pbd:#1\endcsname\pluseight}
718\def\bibgetvard#1{\csname pbd:#1\endcsname\plusnine }
719
720\unexpanded\def\doifelsebibreferencefound#1
721 {\preloadbiblist
722 \doifelsedefined{pbd:#1}
723 \firstoftwoarguments
724 {\showmessage\m!publications{5}{#1,\the\inputlineno}\secondoftwoarguments}}
725
726\let\doifbibreferencefoundelse\doifelsebibreferencefound
727
728
729
730
731
732
733
734
735
736
737
738\unexpanded\def\bib@crossref#1
739 {\setvalue{\??pb @crossref}{#1}\ignorespaces}
740
741\unexpanded\def\bibinsertcrossref#1#2#3
742 {\bibdoifelse\@@pb@crossref{#1\cite[\@@pb@crossref]#2}{#3}}
743
744\let\insertcrossref\gobblethreearguments
745
746\appendtoks\let\insertcrossref\bibinsertcrossref\to\initializebibdefinitions
747
748
749
750
751
752
753\unexpanded\def\doprocessbibtexentry#1{\typesetapublication{#1}}
754
755\unexpanded\def\typesetpubslist
756 {\begingroup
757 \startpacked[\v!blank]
758 \preloadbiblist
759
760 \edef\currentlist{pubs}
761 \ctxlua{bibtex.hacks.reset(\number\bibtexoncemode)}
762 \doifelse{\listparameter\c!criterium}\v!all
763 {\showmessage\m!publications{7}{}
764 \ctxlua{bibtex.hacks.filterall()}}
765 {\doif{\listparameter\c!criterium}\v!cite
766 {\setuplist[pubs][\c!criterium=\v!here]}
767 \strc_lists_place_current
768 {pubs}
769 {\listparameter\c!criterium}
770 {}
771 {\listparameter\c!extras}
772 {\listparameter\c!order}}
773 \ctxlua{bibtex.hacks.flush("\@@pbsorttype")}
774 \stoppacked
775 \endgroup}
776
777\newif\ifinpublist
778
779\unexpanded\def\initializepubslist
780 {\def\currentlist{pubs}
781 \edef\@@pbnumbering{\@@pbnumbering}
782 \doifelse\@@pbautohang\v!yes
783 {\ifx\@@pbnumbering\v!short
784 \setbox\scratchbox\hbox{\@@pbnumbercommand{\listparameter\c!samplesize}}
785 \else
786 \doifelse{\listparameter\c!criterium}\v!all
787 {\setbox\scratchbox\hbox{\@@pbnumbercommand{\ctxlua{tex.write{bibtex.hacks.nofregistered()}}}}}
788 {\determinelistcharacteristics[pubs]
789 \setbox\scratchbox\hbox{\@@pbnumbercommand{\structurelistsize}}}
790 \fi
791 \edef\publistnumberbox{\hbox to \the\wd\scratchbox}
792 \expanded{\setuplist[pubs][\c!width=\the\wd\scratchbox,\c!distance=\zeropoint]}
793 \ifx\@@pbnumbering\v!short
794 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}
795 \else\ifx\@@pbnumbering\v!bib
796 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}
797 \else
798 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}
799 \fi\fi}
800 {\doifelsenothing{\listparameter\c!width}
801 {\let \publistnumberbox \hbox}
802 {\edef\publistnumberbox{\hbox to \listparameter\c!width}}
803 \ifx\@@pbnumbering\v!short
804 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}
805 \else\ifx\@@pbnumbering\v!bib
806 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}
807 \else
808 \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}
809 \fi\fi}
810 \ifx\@@pbnumbering\v!no
811 \setuplist[pubs][\c!numbercommand=,\c!symbol=\v!none,\c!textcommand=\outdented]
812 \else
813 \setuplist[pubs][\c!numbercommand=\@@pblimitednumber]
814 \fi
815 \doifelse{\publicationlistparameter\c!maybeyear}{\v!off}{\def\maybeyear##1{}}{\def\maybeyear##1{##1}}
816 \forgetall}
817
818
819
820\unexpanded\def\completepublications
821 {\dosingleempty\docompletepublications}
822
823\unexpanded\def\docompletepublications[#1]
824 {\begingroup
825 \setuplist[pubs][#1]
826 \edef\currentbibtexsessiontitle{\publicationlistparameter\c!title}
827 \ifx\currentbibtexsessiontitle\empty
828 \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\headtext{pubs}}]}
829 \else
830 \normalexpanded{\startnamedsection[\v!chapter][\c!reference=pubs,\c!title={\currentbibtexsessiontitle}]}
831 \fi
832 \dodoplacepublications
833 \stopnamedsection
834 \endgroup}
835
836
837
838\def\bibrefprefix{\number\bibtexblock:}
839
840\unexpanded\def\placepublications
841 {\dosingleempty\doplacepublications}
842
843\unexpanded\def\doplacepublications[#1]
844 {\begingroup
845 \setuplist[pubs][#1]
846 \dodoplacepublications
847 \endgroup}
848
849\unexpanded\def\dodoplacepublications
850 {\determinelistcharacteristics[pubs]
851 \initializepubslist
852 \doifnot{\namedlistparameter{pubs}\c!option}\v!continue
853 {\global\bibtexcounter\zerocount}
854 \inpublisttrue
855 \typesetpubslist
856 \inpublistfalse
857 \global\advance\bibtexblock\plusone}
858
859
860
861
862
863
864\unexpanded\def\typesetapublication#1
865 {\doifsomething{#1}
866 {\doifelse{\namedlistparameter{pubs}\c!criterium}\v!all
867 {\doplacepublicationindeed{#1}}
868 {\ctxlua{bibtex.hacks.doifalreadyplaced("#1")}
869 {}
870 {\doplacepublicationindeed{#1}}}
871 }}
872
873
874
875
876
877
878
879\unexpanded\def\doplacepublicationindeed#1
880 {\doifelsebibreferencefound{#1}
881 {\global\advance\bibtexcounter\plusone
882 \def\currentpublicationkey{#1}
883 \ctxlua{bibtex.hacks.registerplaced("#1")}
884 \def \currentlist {pubs}
885 \edef\currentlistentrynumber {\number\bibtexcounter}
886 \let \currentlistentrytitle \bibtexpubtext
887 \let \currentlistentrypagenumber\empty
888 \strc_lists_apply_renderingsetup}
889 {}}
890
891\unexpanded\def\bibtexpubtext
892 {\expanded{\reference[\bibrefprefix\currentpublicationkey]{\number\bibtexcounter}}
893 \strut\dotypesetapublication\currentpublicationkey\strut}
894
895\unexpanded\def\dotypesetapublication#1
896 {\bgroup
897 \the\initializebibdefinitions
898 \def\@@currentalternative{:l:}
899 \presetbibvariables
900 \let\biblanguage\empty
901 \ignorespaces
902 \bibgetvard{#1}
903 \removeunwantedspaces
904 \ignorespaces
905 \bibalternative{\bibgetvart{#1}}
906 \removeunwantedspaces
907 \egroup}
908
909
910
911\let\maybeyear\gobbleoneargument
912\let\noopsort \gobbleoneargument
913
914
915
916\unexpanded\def\setbiblanguage#1#2{\setvalue{\??pb\s!language#1}{#2}}
917
918\unexpanded\def\lang#1
919 {\edef\biblanguage{#1}
920 \ifcsname\??pb\s!language#1\endcsname
921 \language[\getvalue{\??pb\s!language#1}]
922 \fi
923 \ignorespaces}
924
925
926
927
928
929
930
931
932
933\unexpanded\def\cite
934 {\strictdoifelsenextoptional\dodocite\dobibref}
935
936\unexpanded\def\dobibref#1
937 {\docite[#1][]}
938
939\unexpanded\def\dodocite[#1]
940 {\strictdoifelsenextoptional{\docite[#1]}{\docite[#1][]}}
941
942\unexpanded\def\docite[#1][#2]
943 {\begingroup
944 \doifelsenothing{#2}\secondargumentfalse\secondargumenttrue
945 \ifsecondargument
946 \dowhatevercite{#1}{#2}
947 \else
948 \donumberedcite{#1}
949 \fi
950 \endgroup}
951
952\unexpanded\def\dowhatevercite#1#2
953 {\processcommalist[#2]\docitation
954 \setupinteraction[\c!style=]
955 \doifelseassignment
956 {#1}
957 {\getparameters[LO][\c!alternative=,\c!extras=,#1]
958 \edef\@@currentalternative{\LOalternative}
959 \ifx\@@currentalternative\empty
960 \edef\@@currentalternative{\@@citedefault}
961 \fi
962 \ifx\LOextras\empty
963 \setupcite[\@@currentalternative][#1]
964 \else
965 \expandafter\ifx\csname \??pv \@@currentalternative\c!right\endcsname\relax
966
967 \expandafter\let\csname \??pv \@@currentalternative\c!right\endcsname\empty
968 \fi
969 \expandafter\ifx\csname LOright\endcsname \relax
970 \edef\LOextras{{\LOextras\bibalternative\c!right}}
971 \else
972 \edef\LOextras{{\LOextras\LOright}}
973 \fi
974 \expanded{\setupcite[\@@currentalternative][#1,\c!right=\LOextras]}
975 \fi}
976 {\def\@@currentalternative{#1}}
977 \doifelsevalue{@@pv\@@currentalternative\c!compress}\v!no\bibcitecompressfalse\bibcitecompresstrue
978 \getvalue{bib\@@currentalternative ref}[#2]}
979
980\unexpanded\def\donumberedcite#1
981 {\processcommalist[#1]\docitation
982 \setupinteraction[\c!style=]
983 \edef\@@currentalternative{\@@citedefault}
984 \doifelsevalue{@@pv\@@currentalternative\c!compress}\v!no\bibcitecompressfalse\bibcitecompresstrue
985 \getvalue{bib\@@citedefault ref}[#1]}
986
987
988
989\unexpanded\def\nocite[#1]
990 {\processcommalist[#1]\docitation}
991
992
993
994\unexpanded\def\setupcite{\dodoubleempty\dosetupcite}
995
996\unexpanded\def\dosetupcite[#1][#2]
997 {\ifsecondargument
998 \def\dodosetupcite##1{\getparameters[\??pv##1][#2]}
999 \processcommalist[#1]\dodosetupcite
1000 \else
1001 \getparameters[\??pv\@@citedefault][#1]
1002 \fi}
1003
1004
1005
1006\unexpanded\def\getcitedata#1[#2]#3[#4]#5to#6
1007 {\bgroup
1008 \dofetchapublication{#4}
1009 \doifelsedefined{\??pb @bib#2}
1010 {\xdef#6{\getvalue{\??pb @bib#2}}}
1011 {\xdef#6{\getvalue{\??pb @#2}}}
1012 \egroup}
1013
1014\unexpanded\def\dofetchapublication#1
1015 {\def\currentpublicationkey{#1}
1016 \presetbibvariables
1017 \ignorespaces\bibgetvard{#1}}
1018
1019\unexpanded\def\docitation#1
1020 {\iftrialtypesetting \else
1021 \expanded{\writedatatolist[pubs][bibref=#1]}
1022 \fi}
1023
1024\let\addthisref\gobbleoneargument
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060\let\currentbibauthor\empty
1061
1062\unexpanded\def\ixbibauthoryear#1#2#3#4
1063 {\bgroup
1064 \gdef\ixlastcommand {#4}
1065 \gdef\ixsecondcommand{#3}
1066 \gdef\ixfirstcommand {#2}
1067 \glet\thebibauthors \empty
1068 \glet\thebibyears \empty
1069 \getcommalistsize[#1]
1070 \ifbibcitecompress
1071 \dorecurse\commalistsize{\xdef\thebibyears{\thebibyears,}}
1072 \processcommalist[#1]\docompressbibauthoryear
1073 \else
1074 \processcommalist[#1]\donormalbibauthoryear
1075 \fi
1076 \egroup
1077 \dobibauthoryear}
1078
1079
1080
1081
1082
1083
1084\unexpanded\def\dobibauthoryear
1085 {\scratchcounter\zerocount
1086 \getcommacommandsize[\thebibauthors]
1087 \edef\authorcount{\commalistsize}
1088 \expandafter\processcommalist\expandafter[\thebibauthors]\dodobibauthoryear}
1089
1090\unexpanded\def\dodobibauthoryear#1
1091 {\advance\scratchcounter\plusone
1092 \edef\wantednumber{\the\scratchcounter}
1093 \getfromcommacommand[\thebibyears][\wantednumber]
1094 \expandafter\def\expandafter\currentbibyear\expandafter{\commalistelement}
1095 \setcurrentbibauthor{#1}
1096 \ifnum\scratchcounter=\plusone
1097 \ixfirstcommand
1098 \else\ifnum \scratchcounter=\authorcount\relax
1099 \ixlastcommand
1100 \else
1101 \ixsecondcommand
1102 \fi\fi}
1103
1104\unexpanded\def\setcurrentbibauthor#1
1105 {\getcommacommandsize[#1]
1106 \ifcase\commalistsize
1107
1108 \let\currentbibauthor\empty
1109 \or
1110 \def\currentbibauthor{#1}
1111 \or
1112 \expanded{\docurrentbibauthor#1}
1113 \else
1114 \handlemultiplebibauthors{\commalistsize}{#1}
1115 \fi}
1116
1117\newcount\citescratchcounter
1118
1119\unexpanded\def\handlemultiplebibauthors#1#2
1120 {\citescratchcounter\zerocount
1121 \let\currentbibauthor\empty
1122 \unexpanded\def\bibprocessauthoritem##1
1123 {\advance\citescratchcounter\plusone
1124 \ifnum \citescratchcounter=#1\relax
1125 \edef\currentbibauthor{\currentbibauthor##1}
1126 \else\ifnum\numexpr\citescratchcounter\plusone\relax=#1\relax
1127 \edef\currentbibauthor{\currentbibauthor##1\bibalternative{andtext}}
1128 \else
1129 \edef\currentbibauthor{\currentbibauthor##1\bibalternative{namesep}}
1130 \fi\fi}
1131 \processcommalist[#2]\bibprocessauthoritem}
1132
1133\setupcite
1134 [author,authoryear,authoryears]
1135 [\c!namesep={, }]
1136
1137
1138
1139
1140\unexpanded\def\docurrentbibauthor#1,#2
1141 {\doifelseempty{#2}
1142 {\def\currentbibauthor{#1\bibalternative{otherstext}}}
1143 {\expandafter\ifx\csname\??pv\@@currentalternative authoretallimit\endcsname\relax
1144 \edef\currentbibauthor{#1\bibalternative{andtext}#2}
1145 \else
1146 \edef\currentbibauthor{#1
1147 \ifcase0\bibalternative{authoretallimit}\relax\or
1148 \bibalternative{otherstext}\else\bibalternative{andtext}#2\fi}
1149 \fi}}
1150
1151
1152
1153
1154
1155\pushoverloadmode
1156
1157 \unexpanded\def\robustaddtocommalist#1#2
1158 {\robustdoifelseinset{#1}#2\resetglobal
1159 {\dodoglobal\xdef#2{\ifx#2\empty\else#2,\fi#1}}}
1160
1161\popoverloadmode
1162
1163
1164
1165
1166
1167
1168\unexpanded\def\donormalbibauthoryear#1
1169 {\def\myauthor{Xxxxxxxxxx}
1170 \def\myyear{0000}
1171 \doifelsebibreferencefound{#1}
1172 {\def\myauthor{{\bibgetvara{#1}}}
1173 \def\myyear {\bibgetvary{#1}}}
1174 {}
1175 \expandafter\doglobal\expandafter\appendtocommalist\expandafter{\myauthor}\thebibauthors
1176 \expandafter\doglobal\expandafter\appendtocommalist\expandafter{\myyear }\thebibyears}
1177
1178
1179
1180
1181
1182
1183
1184\unexpanded\def\docompressbibauthoryear#1
1185 {\def\myauthor{Xxxxxxxxxx}
1186 \def\myyear {0000}
1187 \doifelsebibreferencefound{#1}
1188 {\xdef\myauthor{\bibgetvara{#1}}
1189 \xdef\myyear {\bibgetvary{#1}}}
1190 {}
1191 \ifx\myauthor\empty\else
1192 \checkifmyauthoralreadyexists
1193 \findmatchingyear
1194 \fi}
1195
1196
1197
1198
1199\newcount\bibitemcounter
1200\newcount\bibitemwanted
1201
1202
1203
1204
1205
1206
1207\unexpanded\def\checkifmyauthoralreadyexists
1208 {\doifelseemptyvalue{thebibauthors}
1209 {\global\bibitemwanted \plusone
1210 \global\bibitemcounter\plusone
1211 \xdef\thebibauthors{{\myauthor}}}
1212 {
1213
1214 \expandafter\getcommalistsize\expandafter[\thebibauthors,]
1215 \global\bibitemcounter\numexpr\commalistsize\minusone\relax
1216 \global\bibitemwanted \zerocount
1217 \processcommacommand[\thebibauthors]\docomparemyauthor}}
1218
1219
1220
1221
1222
1223
1224
1225
1226\unexpanded\def\docomparemyauthor#1
1227 {\global\advance\bibitemwanted \plusone
1228 \def\mytempc{#1}
1229 \ifx\mytempc\myauthor
1230 \quitcommalist
1231 \else\ifnum\bibitemwanted=\bibitemcounter\relax
1232 \global\advance\bibitemwanted \plusone
1233 \global\bibitemcounter\bibitemwanted\relax
1234 \expandafter\doglobal\expandafter\robustaddtocommalist\expandafter{{\myauthor}}\thebibauthors
1235 \fi\fi}
1236
1237
1238
1239\unexpanded\def\findmatchingyear
1240 {\edef\wantednumber{\the\bibitemwanted}
1241 \getfromcommacommand[\thebibyears][\wantednumber]
1242 \ifx\commalistelement\empty
1243 \edef\myyear{{\myyear}}
1244 \else
1245 \edef\myyear{{\commalistelement,\myyear}}
1246 \fi
1247 \edef\newcommalistelement{\myyear}
1248 \doglobal\replaceincommalist \thebibyears \wantednumber}
1249
1250
1251
1252
1253
1254
1255
1256\unexpanded\def\gotobiblink#1[#2]{\doifelsereferencefound{\bibrefprefix#2}{\goto{#1}[\bibrefprefix#2]}{#1}}
1257\unexpanded\def\atbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\at [\bibrefprefix#1]}{#1}}
1258\unexpanded\def\inbiblink [#1]{\doifelsereferencefound{\bibrefprefix#1}{\expanded{\goto{\currentreferencetext}}[\bibrefprefix#1]}{#1}}
1259
1260
1261
1262
1263
1264
1265
1266\unexpanded\def\doifelsebibinteraction
1267 {\iflocation
1268 \edef\test{\bibalternative\c!interaction}
1269 \ifx\test\v!stop
1270 \doubleexpandafter\secondoftwoarguments
1271 \else
1272 \doubleexpandafter\firstoftwoarguments
1273 \fi
1274 \else
1275 \expandafter\secondoftwoarguments
1276 \fi}
1277
1278\let\doifbibinteractionelse\doifelsebibinteraction
1279
1280\unexpanded\def\bibmaybeinteractive#1#2
1281 {\doifelsebibinteraction{\gotobiblink{#2}[#1]}{#2}}
1282
1283\unexpanded\def\bibauthoryearref[#1]
1284 {\ixbibauthoryear{#1}
1285 {\bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
1286 \bibalternative\v!left{\currentbibyear}\bibalternative\v!right}}
1287 {\bibalternative\c!pubsep
1288 \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
1289 \bibalternative\v!left {\currentbibyear}\bibalternative\v!right}}
1290 {\bibalternative\c!lastpubsep
1291 \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween
1292 \bibalternative\v!left {\currentbibyear}\bibalternative\v!right}}}
1293
1294\unexpanded\def\bibauthoryearsref[#1]
1295 {\bibalternative\v!left
1296 \ixbibauthoryear{#1}
1297 {\bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}
1298 {\bibalternative\c!pubsep
1299 \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}
1300 {\bibalternative\c!lastpubsep
1301 \bibmaybeinteractive{#1}{{\currentbibauthor}\bibalternative\c!inbetween{\currentbibyear}}}
1302 \bibalternative\v!right}
1303
1304\unexpanded\def\bibauthorref[#1]
1305 {\bibalternative\v!left
1306 \ixbibauthoryear{#1}
1307 {\bibmaybeinteractive{#1}{{\currentbibauthor}}}
1308 {\bibalternative\c!pubsep \bibmaybeinteractive{#1}{{\currentbibauthor}}}
1309 {\bibalternative\c!lastpubsep\bibmaybeinteractive{#1}{{\currentbibauthor}}}
1310 \bibalternative\v!right}
1311
1312\unexpanded\def\bibyearref[#1]
1313 {\bibalternative\v!left
1314 \ixbibauthoryear{#1}
1315 {\bibmaybeinteractive{#1}{{\currentbibyear}}}
1316 {\bibalternative\c!pubsep \bibmaybeinteractive{#1}{{\currentbibyear}}}
1317 {\bibalternative\c!lastpubsep\bibmaybeinteractive{#1}{{\currentbibyear}}}
1318 \bibalternative\v!right}
1319
1320
1321
1322
1323
1324
1325
1326
1327\newconditional\firstbibrefsep
1328
1329\unexpanded\def\bibresetrefsep
1330 {\settrue\firstbibrefsep}
1331
1332\unexpanded\def\bibinsertrefsep
1333 {\ifconditional\firstbibrefsep
1334 \setfalse\firstbibrefsep
1335 \else
1336 \bibalternative\c!pubsep
1337 \fi}
1338
1339\unexpanded\def\bibshortref[#1]
1340 {\bibalternative\v!left
1341 \bibresetrefsep\processcommalist[#1]\dobibshortref
1342 \bibalternative\v!right}
1343
1344\unexpanded\def\dobibshortref#1
1345 {\bibinsertrefsep
1346 \doifelsebibreferencefound{#1}
1347 {\gotobiblink{\bibgetvars{#1}}[#1]}
1348 {}}
1349
1350\unexpanded\def\bibserialref[#1]
1351 {\bibalternative\v!left
1352 \bibresetrefsep\processcommalist[#1]\dobibserialref
1353 \bibalternative\v!right}
1354
1355\unexpanded\def\dobibserialref#1
1356 {\bibinsertrefsep
1357 \doifelsebibreferencefound{#1}
1358 {\gotobiblink{\bibgetvarn{#1}}[#1]}
1359 {}}
1360
1361\unexpanded\def\bibkeyref[#1]
1362 {\bibalternative\v!left
1363 \bibresetrefsep\processcommalist[#1]\dobibkeyref
1364 \bibalternative\v!right}
1365
1366\unexpanded\def\dobibkeyref#1
1367 {\bibinsertrefsep
1368 \gotobiblink{#1}[#1]}
1369
1370\unexpanded\def\bibgotoDOI#1#2
1371 {\doifelsebibinteraction
1372 {\useURL[bibfooDoi#1][#2]
1373 \useURL[bibfoo#1][http:dx.doi.org#2]
1374 \goto{\url[bibfooDoi#1]}[url(bibfoo#1)]}
1375 {\hyphenatedurl{#2}}}
1376
1377\unexpanded\def\bibdoiref[#1]
1378 {\bibalternative\v!left
1379 \bibresetrefsep\processcommalist[#1]\dobibdoiref
1380 \bibalternative\v!right}
1381
1382\unexpanded\def\dobibdoiref#1
1383 {\bibinsertrefsep
1384 \doifelsebibreferencefound{#1}
1385 {\expanded{\bibgotoDOI{#1}{\bibgetvaro{#1}}}}
1386 {}}
1387
1388\unexpanded\def\biburlref[#1]
1389 {\bibalternative\v!left
1390 \bibresetrefsep\processcommalist[#1]\dobiburlref
1391 \bibalternative\v!right}
1392
1393\unexpanded\def\bibgotoURL#1#2
1394 {\doifelsebibinteraction
1395 {\useURL[bibfoo#1][#2]\goto{\url[bibfoo#1]}[url(bibfoo#1)]}
1396 {\hyphenatedurl{#2}}}
1397
1398\unexpanded\def\dobiburlref#1
1399 {\bibinsertrefsep
1400 \doifelsebibreferencefound{#1}
1401 {\expanded{\bibgotoURL{#1}{\bibgetvaru{#1}}}}
1402 {}}
1403
1404\unexpanded\def\bibtyperef[#1]
1405 {\bibalternative\v!left
1406 \bibresetrefsep\processcommalist[#1]\dobibtyperef
1407 \bibalternative\v!right}
1408
1409\unexpanded\def\dobibtyperef#1
1410 {\bibinsertrefsep
1411 \doifelsebibreferencefound{#1}
1412 {\gotobiblink{\bibgetvart{#1}}[#1]}
1413 {}}
1414
1415\unexpanded\def\bibpageref[#1]
1416 {\bibalternative\v!left
1417 \bibresetrefsep\processcommalist[#1]\dobibpageref
1418 \bibalternative\v!right}
1419
1420\unexpanded\def\dobibpageref#1
1421 {\bibinsertrefsep
1422 \doifelsebibinteraction
1423 {\atbiblink[#1]}
1424 {{\referencingfalse\at[#1]}}}
1425
1426\unexpanded\def\bibdataref[#1]
1427 {\bibalternative\v!left
1428 \bibresetrefsep\processcommalist[#1]\dobibdata
1429 \bibalternative\v!right}
1430
1431\unexpanded\def\dobibdata#1
1432 {\bibinsertrefsep
1433 \doifelsebibreferencefound{#1}
1434 {\dotypesetapublication{#1}}
1435 {}}
1436
1437\let\bibnoneref\nocite
1438
1439
1440
1441\unexpanded\def\bibnumref[#1]
1442 {\begingroup
1443 \bibalternative\v!left
1444 \penalty\plustenthousand
1445 \ctxlua{bibtex.hacks.resolve("","\number\bibtexblock","#1")}
1446 \bibalternative\v!right
1447 \endgroup}
1448
1449\unexpanded\def\dowithbibtexnumrefconnector#1#2
1450 {\ifnum#1>\plusone
1451 \ifnum#2>\plusone
1452 \ifnum#2=#1\relax
1453 \bibalternative{lastpubsep}
1454 \else
1455 \bibalternative{pubsep}
1456 \fi
1457 \fi
1458 \fi}
1459
1460\unexpanded\def\dowithbibtexnumref#1#2#3#4#5
1461 {\dowithbibtexnumrefconnector{#1}{#2}
1462 \def\bibrefprefix{#4:}
1463 \inbiblink[#5]}
1464
1465\unexpanded\def\dowithbibtexnumrefrange#1#2#3#4#5#6#7
1466 {\dowithbibtexnumrefconnector{#1}{#2}
1467 \def\bibrefprefix{#4:}
1468 \inbiblink[#5]
1469 \endash
1470 \def\bibrefprefix{#6:}
1471 \inbiblink[#7]}
1472
1473
1474
1475
1476\unexpanded\def\bibauthornumref[#1]
1477 {\getcommalistsize[#1]
1478 \global\bibitemcounter\commalistsize
1479 \bibresetrefsep
1480 \processcommalist[#1]\dobibauthornumref}
1481
1482\unexpanded\def\dobibauthornumref#1
1483 {\bibinsertrefsep
1484 \doifelsebibreferencefound{#1}
1485 {\begingroup
1486 \cite[\c!left=,\c!right=,\c!alternative=\v!author][#1]
1487 \bibalternative\c!inbetween
1488 \cite[num][#1]
1489 \endgroup}
1490 {}}
1491
1492
1493
1494\setuppublications
1495 [\c!monthconversion=,
1496 \c!alternative=apa,
1497 \c!method=\v!global,
1498
1499 \c!criterium=\v!cite,
1500 \c!refcommand=num,
1501 \c!numbercommand=\bibleftnumber]
1502
1503\unexpanded\def\preloadbiblist
1504 {\glet\preloadbiblist\relax
1505 \dousepublications\jobname}
1506
1507
1508
1509
1510\let\ifbibinteractionelse\doifbibinteractionelse
1511
1512\protect \endinput
1513 |