bibl-tra.mkiv /size: 53 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=bibl-tra,
3
%D version=2009.08.22,
4
%D title=\CONTEXT\ Publication Module,
5
%D subtitle=Publications,
6
%D author=Taco Hoekwater,
7
%D date=\currentdate,
8
%D copyright={Public Domain}]
9
%C
10
%C Donated to the public domain.
11 12 13
% % % % watch out ... bibl-tra-new.mkiv is work in progress % % % %
14 15
% % % % mlbibtex also supports context and we can run that instead of bibtex % % % %
16 17
%D This module has been adapted to \MKIV\ by Hans Hagen so if things go wrong,
18
%D he is to blame. The changes concern references and lists but teh rendering
19
%D itself is unchanged. Future versions might provide variants as we have plans
20
%D for an upgrade.
21
%D
22
%D We use a still somewhat experimental extension to the list
23
%D mechanism. Eventually the bibtex module will use the bibl loader
24
%D and access the data by means of lpath expressions. In that case we
25
%D don't need to process the bibliography but still need to track
26
%D usage as done here.
27
%D
28
%D A bit ongoing: make more local macros prefixed with bib, i.e. the bib
29
%D namespace is reserved.
30 31
%D Todo: commandhandler
32 33
\writestatus
{
loading
}{
ConTeXt
Bibliography
Support
/
BibTeX
}
34 35
\definefilesynonym
[
bib
][
obsolete
]
36 37
\registerctxluafile
{
bibl
-
tra
}{}
38 39
%D The original was developed independantly by Taco Hoekwater while still working for Kluwer
40
%D Academic publishers (it still used the dutch interface then). Development continued after
41
%D he left Kluwer, and in Januari 2005, the then already internationalized file was merged
42
%D with the core distribution by Hans Hagen. The current version is once again by Taco.
43
%D
44
%D More documentation and additional resources can be found on the contextgarden:
45
%D \hyphenatedurl{http://wiki.contextgarden.net//Bibliography}.
46 47
%D \subject{DONE (dd/mm/yyyy)}
48
%D
49
%D \startitemize
50
%D \item add author definition (and associated system variable) (26/05/2005)
51
%D \item add finalnamesep support for Oxford comma (17/09/2005)
52
%D \item add \type{\insert...} for: doi, eprint, howpublished (19/09/2005)
53
%D \item allow a defaulted \type{\setupcite} (19/11/2005)
54
%D \item renamed citation type 'number' to 'serial' (19/11/2005)
55
%D \item better definition of \type{\inverted...author} (19/11/2005)
56
%D \item don't reset [numbercommand] in \type {\setuppublication} by default (20/11/2005)
57
%D \item don't disable other \type {\setuppublication} keys if alternative is present (20/11/2005)
58
%D \item drop \type{\sanitizeaccents} (20/11/2005)
59
%D \item added \type{\nocite} and \type{\cite[none]} (21/11/2005)
60
%D \item added headtext for it (23/11/2005)
61
%D \item make \type{\cite[url]} and \type{\cite[doi]} interactive (23/11/2005)
62
%D \item make right-aligned labels in the list work even when autohang=no
63
%D \item use 'et al.' instead of 'et.al.'. Pointed out by Peter M\"unster (30/12/2005)
64
%D \item added headtext for cz (31/12/2005)
65
%D \item Keep whitespace after \type{\cite} with single argument (31/12/2005)
66
%D \item Fix broken \type{\cite{}} support (31/12/2005)
67
%D \item Use \type{\readfile} inside \type{\usepublications} instead of \type{\readsysfile} (12/01/2006)
68
%D \item Use \type{\currentbibyear} and \type{\currentbibauthor} instead of \type{\YR} and \type{\AU} (05/02/2006)
69
%D \item Fix compressed version of authoryear style (05/02/2006)
70
%D \item Rename the clashing data fields \type{\url} and \type{\type} to \type{\biburl} and \type{\bibtype} (05/02/2006)
71
%D \item Added two french bibl files from Renaud Aubin (06/02/2006)
72
%D \item Five new bib class and eight extra bib fields, for IEEEtran (07/02/2006)
73
%D \item French keyword translation, provided by Renaud (08/02/2006)
74
%D \item fix underscores in undefined keys (22/02/2006)
75
%D \item Destroy interactivity in labels of the publication list (13/03/2006)
76
%D \item fix multi-cite list compression (11/4/2006)
77
%D \item fix \type{\getcitedata} (11/4/2006)
78
%D \item magic for chapter bibs (18-25/4/2006)
79
%D \item language setting (25/4/2006)
80
%D \item use \type{\hyphenatedurl} for \type{\inserturl} (25/4/2006)
81
%D \item Add \type{\docitation} to \type{\nocite}(26/4/2006)
82
%D \item patents can have numbers, added to bst files (26/4/2006)
83
%D \item \type{\docitation} needs a \type{\iftrialtypesetting} (27/4/2006)
84
%D \item \type{\filllocalpublist}'s loop is bound by definedness, not resolvedness (27/4/2006)
85
%D \item \type{\setuppublications[monthconversion=]} added (15/5/2006)
86
%D \item use \type{\undefinedreference} instead of bare question marks (15/5/2006)
87
%D \item add grouping around \type{\placepublications} commands (16/5/2006)
88
%D \item fix a bug in \type{\cite{<item>}} (17/5/2006)
89
%D \item support \type{\cite[authornum]} (18/5/2006)
90
%D \item make \type{\cite} unexpandable (20/6/2006)
91
%D \item allow hyperlinks in author\&year combo's
92
%D (cite list compression has to be off) (20/6/2006)
93
%D \item fix duplicate labels for per-chapter style (20/6/2006)
94
%D \item allow \type{\setupcite[interaction=(start|stop)]}
95
%D \item fix the item number in the publication list with 'numbering=yes' (22/6/2006)
96
%D \item make the default criterium for \type{\placepublications} be \type{previous} (23/6/2006)
97
%D \item fix \type{\normalauthor} and \type{\normalshortauthor} spacing (29/6/2006)
98
%D \item do not typeset empty arguments to \type{\typesetapublication} (29/6/2006)
99
%D \item add \type{symbol=none} to \type{\setuplist} in unnumbered
100
%D mode to prevent typesetting of bare numbers (29/6/2006)
101
%D \item remove two incorrect spaces from bibl-num.tex (1/7/2006)
102
%D \item reset font styles within \type{\cite}, so that font switches
103
%D in \type{left} stay in effect (12/7/2006)
104
%D \item guard added against loading bbl files multiple times (13/7/2006)
105
%D \item fix \type{\cite[num]} with compression is on. (14/7/2006)
106
%D \item test \type{\iflocation} before deciding to use the
107
%D interactive version of cite (18/7/2006)
108
%D \item support \type{\setupcite[authoretallimit=1]} (18/7/2006)
109
%D \item support use of \type{\cite} within titles and captions by
110
%D saveguarding the list item extraction and reference placement
111
%D code (19/7/2006)
112
%D \item support \type{\setuppublicationlist[title=\chapter]} (4/8/2006)
113
%D \item use the expansion of \type{\headtext{pubs}} (4/8/2006)
114
%D \item hook added for repeated authors in publication list
115
%D \type{\setuppublicationlist[artauthorcommand=\mythreeargscommand]}
116
%D (4/8/2006)
117
%D \item make the bracketed arguments of \type{\artauthor}, \type{\author}
118
%D and \type{\editor} (bbl commands) optional (4/8/2006)
119
%D \item the constants \type{sorttype}, \type{compress} and
120
%D \type{autohang} have moved to the core (8/8/2006)
121
%D \item bibtex is now registered as a program to be run by texexec (8/8/2006)
122
%D \item fix a bug in \type{\setupcite[authoretallimit=1]} (9/8/2006)
123
%D \item fix a bug inside citations that prevented lastpubsep from ever being
124
%D used due to a volatile \type{\commalistsize} (25/8/2006).
125
%D \item added the possibility of \type{\placepublications[option=continue]}
126
%D (6/9/2006)
127
%D \item Mojca translated Master's Thesis to Masterarbeit (bibl-apa-de.tex)
128
%D (12/9/2006)
129
%D \item Added \type{\setuppublicationlist[maybeyear=off]} by request from
130
%D Thomas Schmitz (15/9/2006)
131
%D \item Removed some spurious spaces pointed out by willi egger (19/9/2006)
132
%D \item Add configuration of bibtex executable name (4/11/2006)
133
%D \item Fix numbering=short and numbering=bib (spotted by Matthias W\"achter) (4/11/2006)
134
%D \item third attempt to get a correct release (5/11/2006)
135
%D \item fix a few missing dots in bibl-num.tex (7/12/2006)
136
%D \item Patch for DOI's by Tobias Burnus (17/4/2007)
137
%D \item Patch for \type{\insertbiburl} and \type{\insertdoi} for Tobias Burnus (18/4/2007)
138
%D \item Added a missing \type{\relax} in \type{\dospecialbibinsert},
139
%D that made the space before the {\it et al.} text disappear. (18/4/2007)
140
%D \item Attempt to fix percent signs in bbl files. As a side-effect,
141
%D this prohibits comments in \tex{startpublication} blocks! (17/4/2008)
142
%D \item Patch from Matthias W\"achter that allows arbitrary .bst
143
%D files to be used with \tex{setupbibtex} (25/9/2008)
144
%D \item Extended for the new multilingual setups for the Oct 2008 current of ConTeXt (23/10/2008)
145
%D \item Multilingual setups needed another fix (27/10/2008)
146
%D \item Two fixes for bibl-apa by Michael Green (27/10/2008)
147
%D \item Catalan translation of 'References' (10/11/2008)
148
%D \item 'chapter' -> 'chapitre' in bibl-apa-fr (27/11/2008)
149
%D \item Run bibtex via os.execute in mkiv modee (01/12/2008)
150
%D \item Small correction in bibl-apa's placement of volume
151
%D information in articles (05/01/2009)
152
%D \item Handle multi-author (more than two) cases in \type{\cite}
153
%D (02/03/2009)
154
%D \item Suppress a syntax error in \type{cont-xp} mode. The output is
155
%D probably not right, though (02/03/2009)
156
%D \item Added a \tex{loadmarkfile} at the end, and two new files
157
%D from Hans. The \type{t-bib.mkiv} is needed to make the module
158
%D work with the new structure code (17/04/2009)
159
%D \item Added a patch to \type{t-bib.mkiv} from Hans to make the
160
%D cross referencing between multiple citations an
161
%D bibliographies work (27/04/2009)
162
%D \item Remove a superfluous \type{\unprotect} in t-bib.mkiv (11/05/2009).
163
%D \item Patch of incollection in bibl-ams.tex from Xan (08/06/2009).
164
%D \item Patch of unpublished in bibl-ams.tex from Xan (22/07/2009).
165
%D \item Modified \type{\bibdogetupsometextprefix} so it works for undefined
166
%D language labels, from Hans (13/08/2009).
167
%D \item Adapt referencing and list insertion to \MKIV. Update some code
168
%D to the latest \CONTEXT. Change some names in order to avoid conflicts
169
%D with existing core names (like \type {\insertpages}).
170
%D \item All constants, variables, message etc.\ are now in the core.
171
%D \item Added key: \type {method} (when \type {global}, previous shown entries are
172
%D not shown again, when \type {local} they are repeated).
173
%D \stopitemize
174
%D
175
%D \subject{WISHLIST}
176
%D
177
%D \startitemize
178
%D \item link back from publication list to citation
179
%D \item export \type {\citation{<cited item>}}
180
%D \item support mlbibtex
181
%D \item don't load the whole lot, but filter entries instead
182
%D \item 9 vs 10, 19 vs 20 ... prevent extra runs when only subtle changes in wd of reference
183
%D \stopitemize
184 185
\unprotect
186 187
\def
\biblistname
{
pubs
}
% for compatibility
188 189
\definelist
190
[
pubs
]
191 192
\setuplist
193
[
pubs
]
194
[
\c!state
=
\v!start
,
195
\c!criterium
=
\@@pbcriterium
,
196
\c!headnumber
=
\v!always
,
% needed as we provide our own and need to force
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
%D \macros{bibdoif,bibdoifnot,bibdoifelse}
206
%D
207
%D Here are a few small helpers that are used a lot in all the typesetting commands
208
%D (\type{\bibinsert...}) we will encounter later.
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
%D Unfortunately, \BIBTEX\ is not the best configurable program
235
%D around. The names of the commands it parses as well as the \type{.aux}
236
%D extension to the file name are both hardwired.
237
%D
238
%D This means \CONTEXT\ has to write a \LATEX-style auxiliary file, yuk!
239
%D The good news is that it can be rather short. We'll just ask
240
%D \BIBTEX\ to output the entire database(s) into the \type{bbl} file.
241
%D
242
%D The \type{\bibstyle} command controls how the \type{bbl} file will
243
%D be sorted. The possibilities are:
244
%D
245
%D \startitemize[packed]
246
%D \item by author (+year, title): cont-au.bst
247
%D \item by title (+author, year): cont-ti.bst
248
%D \item by short key as in abbrev.bst: cont-ab.bst
249
%D \item not sorted at all: cont-no.bst
250
%D \stopitemize
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
%D \macros{iftypesetall,ifbibcitecompress}
285
%D
286
%D The module needs some new \type{\if} statements.
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
% overloaded in bibl-num ... vadjust needs to be done with option
301
\getparameters
[
\??pb
][#
1
]
% as bibl-* can have set things back
302
\the
\everysetuppublications
303
\ignorespaces
}
304 305
%D We can omit already shown references (\v!global) or use fresh
306
%D lists each time (\v!local).
307 308
\setnewconstant
\bibtexoncemode
\plusone
% 0=disable, 1=local, 2=global
309 310
\appendtoks
311
\doifelse
\@@pbmethod
\v!local
312
{
\bibtexoncemode
\plusone
}
%
313
{
\bibtexoncemode
\plustwo
}
%
314
\to
\everysetuppublications
315 316
%D Cite lists are compressed, if possible. This is set later on.
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
% to be tested
328
%
329
% \setvalue{\??pb:\c!numbercommand:\v!short}{\bibgetvars\currentpublicationkey\firstofoneargument}
330
% \setvalue{\??pb:\c!numbercommand:\v!bib }{\bibgetvarn\currentpublicationkey\firstofoneargument}
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
%D \macros{usepublications}
342
%D
343
%D After discussing it with Thomas Schmitz it became clear that using external
344
%D references makes no sense as one needs to refer to it in special ways and
345
%D because similar numbers can be confusing. So, for the moment this is not
346
%D supported in \MKIV. (So no: see reference [3-5,9] in "some other document")
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
% brr, this par stuff
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
%D \macros{setuppublicationlist}
368
%D
369
%D This will be the first command in (\BIBTEX-generated) \type{bbl}
370
%D files. `samplesize' is a sample value (in case of \BIBTEX-generated
371
%D files, this will be the longest `short' key). `totalnumber'
372
%D is the total number of entries that will follow in this
373
%D file.
374
%D
375
%D Both values are only needed for the label calculation
376
%D if `autohang' is `true', so by default the command is
377
%D not even needed, and therefore I saw no need to give
378
%D it it's own system variable and it just re-uses \type{pb}.
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
=
{
AA
9
9
}
,
\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
%D \macros{bibalternative}
400
%D
401
%D A nice little shorthand that will be used so we don't have to
402
%D key in the weird \type{\@@pv} parameter names all the time.
403 404
\def
\bibalternative
#
1
%
405
{
\csname
\??pv
\@@currentalternative
#
1
\endcsname
}
406 407
%D \macros{simplebibdef,bibcommandlist}
408
%D
409
%D \type{\simplebibdef} defines \type{bib@#1}, which in turn will
410
%D use one argument that is stored in \type{@@pb@#1}.
411
%D
412
%D \type{\simplebibdef} also defines \type{bibinsert#1}, which can be
413
%D used in the argument of \type{\setuppublicationlayout} to fetch
414
%D one of the \type{@@pb@} data entries. \type{bibinsert#1} then has
415
%D three arguments: \type{#1} are commands to be executed before the
416
%D data, \type{#2} are commands to be executed after the data, and
417
%D \type{#3} are commands to be executed if the data is not found.
418
%D
419
%D \type{\bibcommandlist} is the list of commands that is affected
420
%D by this approach. Later on, it will be used to do a series
421
%D of assignments from \type{#1} to \type{bib@#1}: e.g
422
%D \type{\title} becomes \type{\bib@title} when used within
423
%D a publication.
424 425
\newtoks
\initializebibdefinitions
% we need to prevent clashes
426 427
\unexpanded
\def
\simplebibdef
#
1
% hh: funny expansion ?
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
% let's see how this fails
446
{
\bibdoifelse
{
\@@pb@doi
}{
#
1
\expanded
{
\bibgotoDOI
{
\@@pb@thekey
}{
\@@pb@doi
}}
#
2
}{
#
3
}}
447 448
\unexpanded
\def
\bibinsertbiburl
#
1
#
2
#
3
% let's see how this fails
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
% for backward compat.
461
\let
\inserttype
\bibinsertbibtype
% for backward compat.
462
\to
\initializebibdefinitions
463 464
\unexpanded
\def
\newbibfield
[#
1
]
%
465
{
\simplebibdef
{
#
1
}
%
466
\edef
\bibcommandlist
{
\bibcommandlist
,
#
1
}}
467 468
%D \macros{complexbibdef,specialbibinsert}
469
%D
470
%D The commands \type{\artauthor}, \type{\author} and
471
%D \type{\editor} are more complex than the other commands.
472
%D Their argument lists have this form:
473
%D
474
%D \type{\author[junior]{firstnames}[inits]{von}{surname}}
475
%D
476
%D (bracketed stuff is optional)
477
%D
478
%D And not only that, but there also might be more than one of each of
479
%D these commands. This is why a special command is needed to insert
480
%D them, as well as one extra counter for each command.
481 482
% todo: instead of \getvalue{bla@num} in specs we should do
483
% \bibentrynum{bla} so that we can create a better namespace
484 485
%D All of these \type{\expandafter}'s and \type{\csnames} make this code
486
%D look far more complex than it really is. For example, the argument
487
%D \type{author} defines the macro \type{\bib@author} to do two
488
%D things: increment the counter \type{\author@num} (let's say to 2)
489
%D and next store it's arguments in the macro \type{\@@pb@author2}.
490
%D And it defines \type{\bibinsertauthors} to expand into
491
%D \starttyping
492
%D \specialbibinsert{author}{\author@num}{<before>}{<after>}{<not>}
493
%D \stoptyping
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
% todo: bib in name
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
#
1
s
\expandafter\endcsname\csname
bibinsert
#
1
s
\endcsname
510
\to
\initializebibdefinitions
511
\expandafter\def\csname
bibinsert
#
1
s
\endcsname
##
1
##
2
##
3
{
\specialbibinsert
{
#
1
}{
\csname
#
1
@
num
\endcsname
}{
##
1
}{
\unskip
##
2
}{
##
3
}}}
512 513
\processcommalist
[
author
,
artauthor
,
editor
]
\complexbibdef
514 515
%D Another level of indirection is needed to control the
516
%D typesetting of all of these arguments.
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
{
#
1
etallimit
}
\relax
526
\etaldisplaycounter
=
0
\bibalternative
{
#
1
etaldisplay
}
\relax
527
\ifnum
#
2
>
\etallimitcounter
528
\todocounter
\etaldisplaycounter
529
% just in case ...
530
\ifnum
\todocounter
>
\etallimitcounter
531
\todocounter
\etallimitcounter
532
\fi
533
\else
534
\todocounter
#
2
\relax
535
\fi
536
\ifnum
\todocounter
>
\zerocount
537
% find the current author list
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
%D This macro does the hard work of inserting a list of people in the
552
%D output, with proper regard of all the inbetween strings that can
553
%D arise depending on length of the list of people.
554 555
%D \#1 = type
556
%D \#2 = number of items to be typeset
557
%D \#3 = commacommand containing authors
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
{
#
1
etaltext
}
%
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
%D \macros{invertedauthor,normalauthor,invertedshortauthor,normalshortauthor}
584
%D
585
%D Just some commands that can be used in \type{\setuppublicationparameters}
586
%D If you want to write an extension to the styles, you might
587
%D as well define some of these commands yourself.
588
%D
589
%D The argument list has been reordered here, and the meanings
590
%D are:
591
%D
592
%D \startlines
593
%D \type{#1} firstnames
594
%D \type{#2} von
595
%D \type{#3} surname
596
%D \type{#4} inits
597
%D \type{#5} junior
598
%D \stoplines
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
%D \macros{clearbibitem,clearbibitemtwo,bibitemdefs}
625
%D
626
%D These are used in \type{\typesetapublication} to do
627
%D initializations and cleanups.
628 629
\unexpanded
\def
\clearbibitem
#
1
{
\setvalue
{
\??pb
@
#
1
}{}}
%
630 631
\unexpanded
\def
\clearbibitemtwo
#
1
% is this reset really needed? after all we reset the counter and we are local
632
{
%\dofastrecurse\plusone{\csname#1@num\endcsname}\plusone{\expandafter\let\csname\??pb @#1\recurselevel\undefined}%
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
% make a fast resetter (toks)
639
{
\processcommacommand
[
\bibcommandlist
,
crossref
]
\clearbibitem
640
\processcommalist
[
artauthor
,
author
,
editor
]
\clearbibitemtwo
641
\processcommacommand
[
\bibcommandlist
]
\bibitemdefs
642
\processcommalist
[
artauthor
,
author
,
editor
,
crossref
]
\bibitemdefs
}
643 644
%D \macros{startpublication}
645
%D
646
%D We are coming to the end of this module, to the macros that
647
%D do typesetting and read the \type{bbl} file.
648 649
%D Just a \type{\dosingleempty} is the most friendly
650
%D of doing this: there need not even be an argument
651
%D to \type{\startpublication}. Of course, then there
652
%D is no key either, and it had better be an
653
%D article (otherwise the layout will be all screwed up).
654
%D
655
%D Only specifying the key in the argument is also
656
%D legal. In storing this stuff into macros, some trickery with
657
%D token registers is needed to fix the expansion problems. Even so,
658
%D this appears to not always be 100\% safe, so people are
659
%D urgently advised to use \ETEX\ instead of traditional \TEX.
660
%D
661
%D In \ETEX, all expansion problems are conveniently solved by
662
%D the primitive \type{\protected}. To put that another way:
663
%D
664
%D It's not a bug in this module if it does not appear in \ETEX!
665
%D
666
%D Now prohibits comments, so % can be used for urls
667 668
\unexpanded
\def
\startpublication
669
{
\dosingleempty
\dostartpublication
}
670 671
\let
\stoppublication
\relax
672 673
% this is rather memory hungry; some day i will rewrite this so that
674
% we use the database instead
675 676
%D \macros{doifbibreferencefoundelse}
677
%D
678
%D Some macros to fetch the information provided by
679
%D \type{\startpublication}.
680 681
% we can consider a faster variant in the bbl file; we can also consider
682
% storing the keys in lua (and then do more in lua) and use calls to
683
% fetch the variables
684 685
% hm, we can store at the lua end ...
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
%D \macros{bib@crossref}
729
%D
730
%D \type{\crossref} is used in database files to point to another
731
%D entry. Because of this special situation, it has to be defined
732
%D separately. Since this command will not be seen until at
733
%D \type{\placepublications}, it may force extra runs. The same is
734
%D true for \type{\cite} commands inside of publications.
735 736
% used in bib self
737 738
\unexpanded
\def
\bib@crossref
#
1
% called via \csname \endcsname
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
%D The next macro is needed because the number command of the
749
%D publist sometimes needs to fetch something from the current
750
%D item (like the 'short' key). For this, the ID of the current
751
%D item is passed in the implict parameter \type{\currentpublicationkey}
752 753
\unexpanded
\def
\doprocessbibtexentry
#
1
{
\typesetapublication
{
#
1
}}
754 755
\unexpanded
\def
\typesetpubslist
756
{
\begingroup
757
\startpacked
[
\v!blank
]
%
758
\preloadbiblist
759
% \the\initializebibdefinitions % COMMENTED
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
\unexpanded
\def
\outdented
#
1
% move to supp-box ?
819
{
\hskip
-
\hangindent
#
1
\relax
}
820 821
%D The full list of publications
822 823
\unexpanded
\def
\completepublications
824
{
\dosingleempty
\docompletepublications
}
825 826
\unexpanded
\def
\docompletepublications
[#
1
]
%
827
{
\begingroup
828
\setuplist
[
pubs
][#
1
]
%
829
\edef
\currentbibtexsessiontitle
{
\publicationlistparameter
\c!title
}
%
830
\ifx
\currentbibtexsessiontitle
\empty
831
\normalexpanded
{
\startnamedsection
[
\v!chapter
][
\c!reference
=
pubs
,
\c!title
=
{
\headtext
{
pubs
}}
]
}
%
832
\else
833
\normalexpanded
{
\startnamedsection
[
\v!chapter
][
\c!reference
=
pubs
,
\c!title
=
{
\currentbibtexsessiontitle
}
]
}
%
834
\fi
835
\dodoplacepublications
836
\stopnamedsection
837
\endgroup
}
838 839
%D And the portion with the entries only.
840 841
\def
\bibrefprefix
{
\number
\bibtexblock
:
}
842 843
\unexpanded
\def
\placepublications
844
{
\dosingleempty
\doplacepublications
}
845 846
\unexpanded
\def
\doplacepublications
[#
1
]
%
847
{
\begingroup
848
\setuplist
[
pubs
][#
1
]
%
849
\dodoplacepublications
850
\endgroup
}
851 852
\unexpanded
\def
\dodoplacepublications
853
{
\determinelistcharacteristics
[
pubs
]
%
854
\initializepubslist
855
\doifnot
{
\namedlistparameter
{
pubs
}
\c!option
}
\v!continue
856
{
\global
\bibtexcounter
\zerocount
}
%
857
\inpublisttrue
858
\typesetpubslist
859
\inpublistfalse
860
\global\advance
\bibtexblock
\plusone
}
861 862
%D \subsubject{What's in a publication}
863
%D
864
%D Watch out: here all means all publications in database, so use
865
%D text when you want text only.
866 867
\unexpanded
\def
\typesetapublication
#
1
%
868
{
\doifsomething
{
#
1
}
869
{
\doifelse
{
\namedlistparameter
{
pubs
}
\c!criterium
}
\v!all
870
{
\doplacepublicationindeed
{
#
1
}}
%
871
{
\ctxlua{
bibtex
.
hacks
.
doifalreadyplaced
(
"
#1
"
)
}
872
{}
873
{
\doplacepublicationindeed
{
#
1
}}}
%
874
}}
875 876
% for the moment we don't access the data directly but we will do that
877
% later when we get away from storing the data and only deal with
878
% references
879 880
% we'll define proper handlers later
881 882
\unexpanded
\def
\doplacepublicationindeed
#
1
%
883
{
\doifelsebibreferencefound
{
#
1
}
884
{
\global\advance
\bibtexcounter
\plusone
885
\def
\currentpublicationkey
{
#
1
}
%
886
\ctxlua{
bibtex
.
hacks
.
registerplaced
(
"
#1
"
)
}
%
887
\def
\currentlist
{
pubs
}
%
888
\edef
\currentlistentrynumber
{
\number
\bibtexcounter
}
%
889
\let
\currentlistentrytitle
\bibtexpubtext
890
\let
\currentlistentrypagenumber
\empty
891
\strc_lists_apply_renderingsetup
}
892
{}}
% invalid
893 894
\unexpanded
\def
\bibtexpubtext
895
{
\expanded
{
\reference
[
\bibrefprefix
\currentpublicationkey
]
{
\number
\bibtexcounter
}}
%
896
\strut
\dotypesetapublication
\currentpublicationkey
\strut
}
897 898
\unexpanded
\def
\dotypesetapublication
#
1
%
899
{
\bgroup
900
\the
\initializebibdefinitions
% NEW
901
\def
\@@currentalternative
{
:
l
:
}
%
902
\presetbibvariables
903
\let
\biblanguage
\empty
904
\ignorespaces
905
\bibgetvard
{
#
1
}
%
906
\removeunwantedspaces
907
\ignorespaces
908
\bibalternative
{
\bibgetvart
{
#
1
}}
%
909
\removeunwantedspaces
910
\egroup
}
911 912
%D An few afterthoughts:
913 914
\let
\maybeyear
\gobbleoneargument
915
\let
\noopsort
\gobbleoneargument
916 917
%D This is the result of bibtex's `language' field.
918 919
\unexpanded
\def
\setbiblanguage
#
1
#
2
{
\setvalue
{
\??pb\s!language
#
1
}{
#
2
}}
920 921
\unexpanded
\def
\lang
#
1
%
922
{
\edef
\biblanguage
{
#
1
}
%
923
\ifcsname
\??pb\s!language
#
1
\endcsname
924
\language
[
\getvalue
{
\??pb\s!language
#
1
}
]
%
925
\fi
926
\ignorespaces
}
927 928
%D \subject{Citations}
929 930
%D \macros{cite,bibref}
931
%D
932
%D The indirection with \type{\dobibref} allows \LATEX\ style
933
%D \type{\cite} commands with a braced argument (these might appear
934
%D in included data from the \type{.bib} file).
935 936
\unexpanded
\def
\cite
937
{
\strictdoifelsenextoptional
\dodocite
\dobibref
}
938 939
\unexpanded
\def
\dobibref
#
1
%
940
{
\docite
[#
1
][]
}
941 942
\unexpanded
\def
\dodocite
[#
1
]
%
943
{
\strictdoifelsenextoptional
{
\docite
[#
1
]
}{
\docite
[#
1
][]
}}
944 945
\unexpanded
\def
\docite
[#
1
][#
2
]
%
946
{
\begingroup
947
\doifelsenothing
{
#
2
}
\secondargumentfalse\secondargumenttrue
948
\ifsecondargument
949
\dowhatevercite
{
#
1
}{
#
2
}
%
950
\else
951
\donumberedcite
{
#
1
}
%
952
\fi
953
\endgroup
}
954 955
\unexpanded
\def
\dowhatevercite
#
1
#
2
%
956
{
\processcommalist
[#
2
]
\docitation
957
\setupinteraction
[
\c!style
=]
%
958
\doifelseassignment
959
{
#
1
}
%
960
{
\getparameters
[
LO
][
\c!alternative
=
,
\c!extras
=
,
#
1
]
%
961
\edef
\@@currentalternative
{
\LOalternative
}
%
962
\ifx
\@@currentalternative
\empty
963
\edef
\@@currentalternative
{
\@@citedefault
}
%
964
\fi
965
\ifx
\LOextras
\empty
966
\setupcite
[
\@@currentalternative
][#
1
]
%
967
\else
968
\expandafter\ifx\csname
\??pv
\@@currentalternative
\c!right
\endcsname\relax
969
% avoids tail recursion
970
\expandafter\let\csname
\??pv
\@@currentalternative
\c!right
\endcsname
\empty
971
\fi
972
\expandafter\ifx\csname
LOright
\endcsname
\relax
973
\edef
\LOextras
{{
\LOextras
\bibalternative
\c!right
}}
%
974
\else
975
\edef
\LOextras
{{
\LOextras
\LOright
}}
%
976
\fi
977
\expanded
{
\setupcite
[
\@@currentalternative
][#
1
,
\c!right
=
\LOextras
]
}
%
978
\fi
}
%
979
{
\def
\@@currentalternative
{
#
1
}}
%
980
\doifelsevalue
{
@
@
pv
\@@currentalternative
\c!compress
}
\v!no
\bibcitecompressfalse
\bibcitecompresstrue
981
\getvalue
{
bib
\@@currentalternative
ref
}
[#
2
]
}
982 983
\unexpanded
\def
\donumberedcite
#
1
%
984
{
\processcommalist
[#
1
]
\docitation
985
\setupinteraction
[
\c!style
=]
%
986
\edef
\@@currentalternative
{
\@@citedefault
}
%
987
\doifelsevalue
{
@
@
pv
\@@currentalternative
\c!compress
}
\v!no
\bibcitecompressfalse
\bibcitecompresstrue
988
\getvalue
{
bib
\@@citedefault
ref
}
[#
1
]
}
989 990
%D \macros{nocite}
991 992
\unexpanded
\def
\nocite
[#
1
]
%
993
{
\processcommalist
[#
1
]
\docitation
}
994 995
%D \macros{setupcite}
996 997
\unexpanded
\def
\setupcite
{
\dodoubleempty
\dosetupcite
}
998 999
\unexpanded
\def
\dosetupcite
[#
1
][#
2
]
%
1000
{
\ifsecondargument
1001
\def
\dodosetupcite
##
1
{
\getparameters
[
\??pv
##
1
][#
2
]
}
%
1002
\processcommalist
[#
1
]
\dodosetupcite
1003
\else
% default case
1004
\getparameters
[
\??pv
\@@citedefault
][#
1
]
%
1005
\fi
}
1006 1007
%D Low-level stuff
1008 1009
\unexpanded
\def
\getcitedata
#
1
[#
2
]#
3
[#
4
]#
5
to
#
6
%
1010
{
\bgroup
1011
\dofetchapublication
{
#
4
}
%
1012
\doifelsedefined
{
\??pb
@
bib
#
2
}
%
1013
{
\xdef
#
6
{
\getvalue
{
\??pb
@
bib
#
2
}}}
%
1014
{
\xdef
#
6
{
\getvalue
{
\??pb
@
#
2
}}}
%
1015
\egroup
}
1016 1017
\unexpanded
\def
\dofetchapublication
#
1
%
1018
{
\def
\currentpublicationkey
{
#
1
}
%
1019
\presetbibvariables
1020
\ignorespaces
\bibgetvard
{
#
1
}}
1021 1022
\unexpanded
\def
\docitation
#
1
%
1023
{
\iftrialtypesetting
\else
1024
\expanded
{
\writedatatolist
[
pubs
][
bibref
=#
1
]
}
%
1025
\fi
}
1026 1027
\let
\addthisref
\gobbleoneargument
% keep this for compatibility
1028 1029
%D \macros{ixbibauthoryear,thebibauthors,thebibyears}
1030
%D
1031
%D If compression of \type{\cite}'s argument expansion is on,
1032
%D the macros that deal with authors and years call this internal
1033
%D command to do the actual typesetting.
1034
%D
1035
%D Two entries with same author but with different years may
1036
%D be condensed into ``Author (year1,year2)''. This is about the
1037
%D only optimization that makes sense for the (author,year)
1038
%D style of citations (years within one author have to be unique
1039
%D anyway so no need to test for that, and ``Author1, Author2 (year)''
1040
%D creates more confusion than it does good).
1041
%D
1042
%D In the code below,
1043
%D the macro \type{\thebibauthors} holds the names of the alternative
1044
%D author info fields for the current list. This is a commalist,
1045
%D and \type{\thebibyears} holds the (collection of) year(s) that go with
1046
%D this author (possibly as a nested commalist).
1047
%D
1048
%D There had better be an author for all cases, but there
1049
%D does not have to be year info always. \type{\thebibyears} is
1050
%D pre-initialized because this makes the insertion macros simpler.
1051
%D
1052
%D In normal \TEX, of course there are expansion problems again.
1053 1054
%D Delegate this to \LUA.
1055 1056
% \let\ixlastcommand \relax
1057
% \let\ixsecondcomman \relax
1058
% \let\ixfirstcommand \relax
1059
% \let\thebibauthors \empty
1060
% \let\thebibyears \empty
1061
% \let\authorcount \!!zerocount
1062 1063
\let
\currentbibauthor
\empty
1064 1065
\unexpanded
\def
\ixbibauthoryear
#
1
#
2
#
3
#
4
%
1066
{
\bgroup
1067
\gdef
\ixlastcommand
{
#
4
}
%
1068
\gdef
\ixsecondcommand
{
#
3
}
%
1069
\gdef
\ixfirstcommand
{
#
2
}
%
1070
\glet
\thebibauthors
\empty
1071
\glet
\thebibyears
\empty
1072
\getcommalistsize
[#
1
]
%
1073
\ifbibcitecompress
1074
\dorecurse
\commalistsize
{
\xdef
\thebibyears
{
\thebibyears
,
}}
%
1075
\processcommalist
[#
1
]
\docompressbibauthoryear
1076
\else
1077
\processcommalist
[#
1
]
\donormalbibauthoryear
1078
\fi
1079
\egroup
1080
\dobibauthoryear
}
1081 1082
%D \macros{dodobibauthoryear}
1083
%D
1084
%D This macro only has to make sure that the lists
1085
%D \type{\thebibauthors} and \type{\thebibyears} are printed.
1086 1087
\unexpanded
\def
\dobibauthoryear
1088
{
\scratchcounter
\zerocount
1089
\getcommacommandsize
[
\thebibauthors
]
%
1090
\edef
\authorcount
{
\commalistsize
}
%
1091
\expandafter
\processcommalist
\expandafter
[
\thebibauthors
]
\dodobibauthoryear
}
1092 1093
\unexpanded
\def
\dodobibauthoryear
#
1
%
1094
{
\advance
\scratchcounter
\plusone
1095
\edef
\wantednumber
{
\the
\scratchcounter
}
%
1096
\getfromcommacommand
[
\thebibyears
][
\wantednumber
]
%
1097
\expandafter\def\expandafter
\currentbibyear
\expandafter
{
\commalistelement
}
%
1098
\setcurrentbibauthor
{
#
1
}
%
1099
\ifnum
\scratchcounter
=
\plusone
1100
\ixfirstcommand
1101
\else\ifnum
\scratchcounter
=
\authorcount
\relax
1102
\ixlastcommand
1103
\else
1104
\ixsecondcommand
1105
\fi\fi
}
1106 1107
\unexpanded
\def
\setcurrentbibauthor
#
1
% sensitive for empty entries but I don't want to touch this
1108
{
\getcommacommandsize
[#
1
]
%
1109
\ifcase
\commalistsize
1110
% anonymous?
1111
\let
\currentbibauthor
\empty
1112
\or
1113
\def
\currentbibauthor
{
#
1
}
%
1114
\or
1115
\expanded
{
\docurrentbibauthor
#
1
}
%
1116
\else
1117
\handlemultiplebibauthors
{
\commalistsize
}{
#
1
}
%
1118
\fi
}
1119 1120
\newcount
\citescratchcounter
1121 1122
\unexpanded
\def
\handlemultiplebibauthors
#
1
#
2
%
1123
{
\citescratchcounter
\zerocount
1124
\let
\currentbibauthor
\empty
1125
\unexpanded
\def
\bibprocessauthoritem
##
1
%
1126
{
\advance
\citescratchcounter
\plusone
1127
\ifnum
\citescratchcounter
=#
1
\relax
1128
\edef
\currentbibauthor
{
\currentbibauthor
##
1
}
%
1129
\else\ifnum\numexpr
\citescratchcounter
+
\plusone
\relax
=#
1
\relax
1130
\edef
\currentbibauthor
{
\currentbibauthor
##
1
\bibalternative
{
andtext
}}
%
1131
\else
1132
\edef
\currentbibauthor
{
\currentbibauthor
##
1
\bibalternative
{
namesep
}}
%
1133
\fi\fi
}
%
1134
\processcommalist
[#
2
]
\bibprocessauthoritem
}
1135 1136
\setupcite
1137
[
author
,
authoryear
,
authoryears
]
1138
[
\c!namesep
=
{
,
}
]
1139 1140
%D This discovery of authoretallimit is not the best one,
1141
%D but it will do for now.
1142 1143
\unexpanded
\def
\docurrentbibauthor
#
1
,
#
2
%
1144
{
\doifelseempty
{
#
2
}
1145
{
\def
\currentbibauthor
{
#
1
\bibalternative
{
otherstext
}}}
1146
{
\expandafter\ifx\csname
\??pv
\@@currentalternative
authoretallimit
\endcsname\relax
1147
\edef
\currentbibauthor
{
#
1
\bibalternative
{
andtext
}
#
2
}
%
1148
\else
1149
\edef
\currentbibauthor
{
#
1
%
1150
\ifcase
0
\bibalternative
{
authoretallimit
}
\relax\or
1151
\bibalternative
{
otherstext
}
\else
\bibalternative
{
andtext
}
#
2
\fi
}
%
1152
\fi
}}
1153 1154
%D This is not the one Hans made for me, because I need a global
1155
%D edef, and the \type{\robustdoifinsetelse} doesn't listen to
1156
%D \type{\doglobal }
1157 1158
\unexpanded
\def
\robustaddtocommalist
#
1
#
2
% {item} \cs
1159
{
\robustdoifelseinset
{
#
1
}
#
2
\resetglobal
1160
{
\dodoglobal
\xdef
#
2
{
\ifx
#
2
\empty
\else
#
2
,
\fi
#
1
}}}
1161 1162
%D \macros{donormalbibauthoryear}
1163
%D
1164
%D Now we get to the macros that fill the two lists.
1165
%D The `simple' one really is quite simple.
1166 1167
\unexpanded
\def
\donormalbibauthoryear
#
1
%
1168
{
\def
\myauthor
{
Xxxxxxxxxx
}
%
1169
\def
\myyear
{
0
0
0
0
}
%
1170
\doifelsebibreferencefound
{
#
1
}
1171
{
\def
\myauthor
{{
\bibgetvara
{
#
1
}}}
%
1172
\def
\myyear
{
\bibgetvary
{
#
1
}}}
%
1173
{}
%
1174
\expandafter
\doglobal
\expandafter
\appendtocommalist
\expandafter
{
\myauthor
}
\thebibauthors
1175
\expandafter
\doglobal
\expandafter
\appendtocommalist
\expandafter
{
\myyear
}
\thebibyears
}
1176 1177
%D \macros{docompressbibauthoryear}
1178
%D
1179
%D So much for the easy parts. Nothing at all will be done if
1180
%D the reference is not found or the reference does not contain
1181
%D author data. No questions marks o.s.s. (to be fixed later)
1182 1183
\unexpanded
\def
\docompressbibauthoryear
#
1
%
1184
{
\def
\myauthor
{
Xxxxxxxxxx
}
%
1185
\def
\myyear
{
0
0
0
0
}
%
1186
\doifelsebibreferencefound
{
#
1
}
1187
{
\xdef
\myauthor
{
\bibgetvara
{
#
1
}}
%
1188
\xdef
\myyear
{
\bibgetvary
{
#
1
}}}
1189
{}
%
1190
\ifx
\myauthor
\empty
\else
1191
\checkifmyauthoralreadyexists
1192
\findmatchingyear
1193
\fi
}
1194 1195
%D two temporary counters. One of these two can possibly be replaced
1196
%D by \type{\scratchcounter}.
1197 1198
\newcount
\bibitemcounter
1199
\newcount
\bibitemwanted
1200 1201
%D The first portion is simple enough: if this is the very first author
1202
%D it is quite straightforward to add it. \type{\bibitemcounter} and
1203
%D \type{\bibitemwanted} are needed later to insert the year
1204
%D information in the correct item of \type{\thebibyears}
1205 1206
\unexpanded
\def
\checkifmyauthoralreadyexists
1207
{
\doifelseemptyvalue
{
thebibauthors
}
1208
{
\global
\bibitemwanted
\plusone
1209
\global
\bibitemcounter
\plusone
1210
\xdef
\thebibauthors
{{
\myauthor
}}}
1211
{
% the next weirdness is because according to \getcommalistsize,
1212
% the length of \type{[{{},{}}]} is 2.
1213
\expandafter
\getcommalistsize
\expandafter
[
\thebibauthors
,
]
%
1214
\global
\bibitemcounter
\numexpr
\commalistsize
+
\minusone
\relax
1215
\global
\bibitemwanted
\zerocount
1216
\processcommacommand
[
\thebibauthors
]
\docomparemyauthor
}}
1217 1218
%D The outer \type{\ifnum} accomplishes the addition of
1219
%D a new author to \type{\thebibauthors}. The messing about with
1220
%D the two counters is again to make sure that \type{\thebibyears}
1221
%D will be updated correctly.If the author {\it was} found,
1222
%D the counters will stay at their present values and everything
1223
%D will be setup properly to insert the year info.
1224 1225
\unexpanded
\def
\docomparemyauthor
#
1
%
1226
{
\global\advance
\bibitemwanted
\plusone
1227
\def
\mytempc
{
#
1
}
%
1228
\ifx
\mytempc
\myauthor
1229
\quitcommalist
1230
\else\ifnum
\bibitemwanted
=
\bibitemcounter
\relax
1231
\global\advance
\bibitemwanted
\plusone
1232
\global
\bibitemcounter
\bibitemwanted
\relax
1233
\expandafter
\doglobal
\expandafter
\robustaddtocommalist
\expandafter
{{
\myauthor
}}
\thebibauthors
1234
\fi\fi
}
1235 1236
%D This macro should be clear now.
1237 1238
\unexpanded
\def
\findmatchingyear
1239
{
\edef
\wantednumber
{
\the
\bibitemwanted
}
%
1240
\getfromcommacommand
[
\thebibyears
][
\wantednumber
]
%
1241
\ifx
\commalistelement
\empty
1242
\edef
\myyear
{{
\myyear
}}
%
1243
\else
1244
\edef
\myyear
{{
\commalistelement
,
\myyear
}}
%
1245
\fi
1246
\edef
\newcommalistelement
{
\myyear
}
%
1247
\doglobal
\replaceincommalist
\thebibyears
\wantednumber
}
1248 1249
%D \macros{gotobiblink,inbiblink,atbiblink}
1250
%D
1251
%D The final task is looping over that list until a match is found.
1252 1253
%D Beware, we can have cites without reference match.
1254 1255
\unexpanded
\def
\gotobiblink
#
1
[#
2
]
{
\doifelsereferencefound
{
\bibrefprefix
#
2
}{
\goto
{
#
1
}
[
\bibrefprefix
#
2
]
}{
#
1
}}
1256
\unexpanded
\def
\atbiblink
[#
1
]
{
\doifelsereferencefound
{
\bibrefprefix
#
1
}{
\at
[
\bibrefprefix
#
1
]
}{
#
1
}}
1257
\unexpanded
\def
\inbiblink
[#
1
]
{
\doifelsereferencefound
{
\bibrefprefix
#
1
}{
\expanded
{
\goto
{
\currentreferencetext
}}
[
\bibrefprefix
#
1
]
}{
#
1
}}
1258 1259
%D \macros{bibauthoryearref,bibauthoryearsref,bibauthorref,bibyearref}
1260
%D
1261
%D Now that all the hard work has been done, these are simple.
1262
%D \type{\ixbibauthoryearref} stores the data in the macros
1263
%D \type{\currentbibauthor} and \type{\currentbibyear}.
1264 1265
\unexpanded
\def
\doifelsebibinteraction
1266
{
\iflocation
1267
\edef
\test
{
\bibalternative
\c!interaction
}
%
1268
\ifx
\test
\v!stop
1269
\doubleexpandafter\secondoftwoarguments
1270
\else
1271
\doubleexpandafter\firstoftwoarguments
1272
\fi
1273
\else
1274
\expandafter
\secondoftwoarguments
1275
\fi
}
1276 1277
\let
\doifbibinteractionelse
\doifelsebibinteraction
1278 1279
\unexpanded
\def
\bibmaybeinteractive
#
1
#
2
%
1280
{
\doifelsebibinteraction
{
\gotobiblink
{
#
2
}
[#
1
]
}{
#
2
}}
1281 1282
\unexpanded
\def
\bibauthoryearref
[#
1
]
%
1283
{
\ixbibauthoryear
{
#
1
}
%
1284
{
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
1285
\bibalternative
\v!left
{
\currentbibyear
}
\bibalternative
\v!right
}}
1286
{
\bibalternative
\c!pubsep
1287
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
1288
\bibalternative
\v!left
{
\currentbibyear
}
\bibalternative
\v!right
}}
1289
{
\bibalternative
\c!lastpubsep
1290
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
1291
\bibalternative
\v!left
{
\currentbibyear
}
\bibalternative
\v!right
}}}
1292 1293
\unexpanded
\def
\bibauthoryearsref
[#
1
]
%
1294
{
\bibalternative
\v!left
1295
\ixbibauthoryear
{
#
1
}
1296
{
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
{
\currentbibyear
}}}
1297
{
\bibalternative
\c!pubsep
1298
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
{
\currentbibyear
}}}
1299
{
\bibalternative
\c!lastpubsep
1300
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}
\bibalternative
\c!inbetween
{
\currentbibyear
}}}
%
1301
\bibalternative
\v!right
}
1302 1303
\unexpanded
\def
\bibauthorref
[#
1
]
%
1304
{
\bibalternative
\v!left
1305
\ixbibauthoryear
{
#
1
}
%
1306
{
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}}}
1307
{
\bibalternative
\c!pubsep
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}}}
1308
{
\bibalternative
\c!lastpubsep
\bibmaybeinteractive
{
#
1
}{{
\currentbibauthor
}}}
%
1309
\bibalternative
\v!right
}
1310 1311
\unexpanded
\def
\bibyearref
[#
1
]
%
1312
{
\bibalternative
\v!left
1313
\ixbibauthoryear
{
#
1
}
%
1314
{
\bibmaybeinteractive
{
#
1
}{{
\currentbibyear
}}}
1315
{
\bibalternative
\c!pubsep
\bibmaybeinteractive
{
#
1
}{{
\currentbibyear
}}}
1316
{
\bibalternative
\c!lastpubsep
\bibmaybeinteractive
{
#
1
}{{
\currentbibyear
}}}
%
1317
\bibalternative
\v!right
}
1318 1319
%D \macros{bibshortref,bibkeyref,bibpageref,bibtyperef,bibserialref}
1320
%D
1321
%D There is hardly any point in trying to compress these. The only
1322
%D thing that needs to be done is making sure that
1323
%D the separations are inserted correctly. And that is
1324
%D what \type{\bibinsertrefsep} does.
1325 1326
\newconditional
\firstbibrefsep
1327 1328
\unexpanded
\def
\bibresetrefsep
1329
{
\settrue
\firstbibrefsep
}
1330 1331
\unexpanded
\def
\bibinsertrefsep
1332
{
\ifconditional
\firstbibrefsep
1333
\setfalse
\firstbibrefsep
1334
\else
1335
\bibalternative
\c!pubsep
1336
\fi
}
1337 1338
\unexpanded
\def
\bibshortref
[#
1
]
%
1339
{
\bibalternative
\v!left
1340
\bibresetrefsep
\processcommalist
[#
1
]
\dobibshortref
1341
\bibalternative
\v!right
}
1342 1343
\unexpanded
\def
\dobibshortref
#
1
%
1344
{
\bibinsertrefsep
1345
\doifelsebibreferencefound
{
#
1
}
1346
{
\gotobiblink
{
\bibgetvars
{
#
1
}}
[#
1
]
}
1347
{}}
1348 1349
\unexpanded
\def
\bibserialref
[#
1
]
%
1350
{
\bibalternative
\v!left
1351
\bibresetrefsep
\processcommalist
[#
1
]
\dobibserialref
1352
\bibalternative
\v!right
}
1353 1354
\unexpanded
\def
\dobibserialref
#
1
%
1355
{
\bibinsertrefsep
1356
\doifelsebibreferencefound
{
#
1
}
1357
{
\gotobiblink
{
\bibgetvarn
{
#
1
}}
[#
1
]
}
1358
{}}
1359 1360
\unexpanded
\def
\bibkeyref
[#
1
]
%
1361
{
\bibalternative
\v!left
1362
\bibresetrefsep
\processcommalist
[#
1
]
\dobibkeyref
1363
\bibalternative
\v!right
}
1364 1365
\unexpanded
\def
\dobibkeyref
#
1
%
1366
{
\bibinsertrefsep
1367
\gotobiblink
{
#
1
}
[#
1
]
}
1368 1369
\unexpanded
\def
\bibgotoDOI
#
1
#
2
%
1370
{
\doifelsebibinteraction
1371
{
\useURL
[
bibfooDoi
#
1
][#
2
]
%
1372
\useURL
[
bibfoo
#
1
][
http
:
//
dx
.
doi
.
org
/
#
2
]
%
1373
\goto
{
\url
[
bibfooDoi
#
1
]
}
[
url
(
bibfoo
#
1
)]
}
1374
{
\hyphenatedurl
{
#
2
}}}
1375 1376
\unexpanded
\def
\bibdoiref
[#
1
]
%
1377
{
\bibalternative
\v!left
1378
\bibresetrefsep
\processcommalist
[#
1
]
\dobibdoiref
1379
\bibalternative
\v!right
}
1380 1381
\unexpanded
\def
\dobibdoiref
#
1
%
1382
{
\bibinsertrefsep
1383
\doifelsebibreferencefound
{
#
1
}
1384
{
\expanded
{
\bibgotoDOI
{
#
1
}{
\bibgetvaro
{
#
1
}}}}
1385
{}}
1386 1387
\unexpanded
\def
\biburlref
[#
1
]
%
1388
{
\bibalternative
\v!left
1389
\bibresetrefsep
\processcommalist
[#
1
]
\dobiburlref
1390
\bibalternative
\v!right
}
1391 1392
\unexpanded
\def
\bibgotoURL
#
1
#
2
%
1393
{
\doifelsebibinteraction
1394
{
\useURL
[
bibfoo
#
1
][#
2
]
\goto
{
\url
[
bibfoo
#
1
]
}
[
url
(
bibfoo
#
1
)]
}
1395
{
\hyphenatedurl
{
#
2
}}}
1396 1397
\unexpanded
\def
\dobiburlref
#
1
%
1398
{
\bibinsertrefsep
1399
\doifelsebibreferencefound
{
#
1
}
1400
{
\expanded
{
\bibgotoURL
{
#
1
}{
\bibgetvaru
{
#
1
}}}}
1401
{}}
1402 1403
\unexpanded
\def
\bibtyperef
[#
1
]
%
1404
{
\bibalternative
\v!left
1405
\bibresetrefsep
\processcommalist
[#
1
]
\dobibtyperef
1406
\bibalternative
\v!right
}
1407 1408
\unexpanded
\def
\dobibtyperef
#
1
%
1409
{
\bibinsertrefsep
1410
\doifelsebibreferencefound
{
#
1
}
1411
{
\gotobiblink
{
\bibgetvart
{
#
1
}}
[#
1
]
}
1412
{}}
1413 1414
\unexpanded
\def
\bibpageref
[#
1
]
%
1415
{
\bibalternative
\v!left
1416
\bibresetrefsep
\processcommalist
[#
1
]
\dobibpageref
1417
\bibalternative
\v!right
}
1418 1419
\unexpanded
\def
\dobibpageref
#
1
%
1420
{
\bibinsertrefsep
1421
\doifelsebibinteraction
1422
{
\atbiblink
[#
1
]
}
1423
{{
\referencingfalse
\at
[#
1
]
}}}
1424 1425
\unexpanded
\def
\bibdataref
[#
1
]
%
1426
{
\bibalternative
\v!left
1427
\bibresetrefsep
\processcommalist
[#
1
]
\dobibdata
1428
\bibalternative
\v!right
}
1429 1430
\unexpanded
\def
\dobibdata
#
1
%
1431
{
\bibinsertrefsep
1432
\doifelsebibreferencefound
{
#
1
}
1433
{
\dotypesetapublication
{
#
1
}}
1434
{}}
1435 1436
\let
\bibnoneref
\nocite
1437 1438
%D \macros{bibnumref}
1439 1440
\unexpanded
\def
\bibnumref
[#
1
]
%
1441
{
\begingroup
1442
\bibalternative
\v!left
1443
\penalty
\plustenthousand
1444
\ctxlua{
bibtex
.
hacks
.
resolve
(
"
"
,
"
\number\bibtexblock
"
,
"
#1
"
)
}
%
1445
\bibalternative
\v!right
1446
\endgroup
}
1447 1448
\unexpanded
\def
\dowithbibtexnumrefconnector
#
1
#
2
%
1449
{
\ifnum
#
1
>
\plusone
1450
\ifnum
#
2
>
\plusone
1451
\ifnum
#
2
=#
1
\relax
1452
\bibalternative
{
lastpubsep
}
%
1453
\else
1454
\bibalternative
{
pubsep
}
%
1455
\fi
1456
\fi
1457
\fi
}
1458 1459
\unexpanded
\def
\dowithbibtexnumref
#
1
#
2
#
3
#
4
#
5
% n, i, prefix block ref
1460
{
\dowithbibtexnumrefconnector
{
#
1
}{
#
2
}
%
1461
\def
\bibrefprefix
{
#
4
:
}
%
1462
\inbiblink
[#
5
]
}
1463 1464
\unexpanded
\def
\dowithbibtexnumrefrange
#
1
#
2
#
3
#
4
#
5
#
6
#
7
% n, i, prefix block ref
1465
{
\dowithbibtexnumrefconnector
{
#
1
}{
#
2
}
%
1466
\def
\bibrefprefix
{
#
4
:
}
%
1467
\inbiblink
[#
5
]
%
1468
\endash
1469
\def
\bibrefprefix
{
#
6
:
}
%
1470
\inbiblink
[#
7
]
}
1471 1472
%D By request from Sanjoy. This makes it easier to implement
1473
%D \type{\citeasnoun}.
1474 1475
\unexpanded
\def
\bibauthornumref
[#
1
]
%
1476
{
\getcommalistsize
[#
1
]
%
1477
\global
\bibitemcounter
\commalistsize
1478
\bibresetrefsep
1479
\processcommalist
[#
1
]
\dobibauthornumref
}
1480 1481
\unexpanded
\def
\dobibauthornumref
#
1
%
1482
{
\bibinsertrefsep
1483
\doifelsebibreferencefound
{
#
1
}
1484
{
\begingroup
1485
\cite
[
\c!left
=
,
\c!right
=
,
\c!alternative
=
\v!author
][#
1
]
%
1486
\bibalternative
\c!inbetween
1487
\cite
[
num
][#
1
]
%
1488
\endgroup
}
1489
{}}
1490 1491
%D And some defaults are loaded from bibl-apa:
1492 1493
\setuppublications
1494
[
\c!monthconversion
=
,
1495
\c!alternative
=
apa
,
1496
\c!method
=
\v!global
,
1497
%\c!criterium=\v!previous,
1498
\c!criterium
=
\v!cite
,
% mojca wants this so bother her, not me
1499
\c!refcommand
=
num
,
1500
\c!numbercommand
=
\bibleftnumber
]
1501 1502
\unexpanded
\def
\preloadbiblist
1503
{
\glet
\preloadbiblist
\relax
1504
\dousepublications
\jobname
}
1505 1506
% \appendtoks \preloadbiblist \to \everysetuppublications
1507
% \appendtoks \preloadbiblist \to \everystarttext
1508 1509
\let
\ifbibinteractionelse
\doifbibinteractionelse
1510 1511
\protect
\endinput
1512